@fluidframework/tree 2.51.0-347100 → 2.52.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 (609) hide show
  1. package/.eslintrc.cjs +3 -2
  2. package/.vscode/settings.json +0 -1
  3. package/CHANGELOG.md +92 -0
  4. package/api-report/tree.alpha.api.md +3 -2
  5. package/dist/codec/codec.d.ts +2 -1
  6. package/dist/codec/codec.d.ts.map +1 -1
  7. package/dist/codec/codec.js +4 -3
  8. package/dist/codec/codec.js.map +1 -1
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +3 -2
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/rebase/index.d.ts +1 -1
  14. package/dist/core/rebase/index.d.ts.map +1 -1
  15. package/dist/core/rebase/index.js +2 -1
  16. package/dist/core/rebase/index.js.map +1 -1
  17. package/dist/core/rebase/types.d.ts +3 -1
  18. package/dist/core/rebase/types.d.ts.map +1 -1
  19. package/dist/core/rebase/types.js +2 -1
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +1 -23
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +2 -2
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  26. package/dist/core/tree/detachedFieldIndex.js +2 -3
  27. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  29. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  30. package/dist/core/tree/detachedFieldIndexCodecCommon.js +68 -0
  31. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  32. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  33. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  34. package/dist/core/tree/detachedFieldIndexCodecV1.js +55 -0
  35. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  36. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  37. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  38. package/dist/core/tree/detachedFieldIndexCodecV2.js +49 -0
  39. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  40. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  41. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  42. package/dist/core/tree/detachedFieldIndexCodecs.js +26 -0
  43. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  44. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  45. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  46. package/dist/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +18 -13
  47. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  48. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  49. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  50. package/dist/core/tree/detachedFieldIndexFormatV1.js +12 -0
  51. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  52. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  53. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  54. package/dist/core/tree/detachedFieldIndexFormatV2.js +14 -0
  55. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  56. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  57. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +21 -21
  59. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  61. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  63. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  65. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +74 -61
  67. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  69. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/format.js +18 -12
  71. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  72. package/{lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts → dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  73. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  74. package/dist/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +23 -17
  75. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  76. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  77. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -22
  79. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  81. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  83. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  84. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
  85. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  87. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -2
  88. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  89. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  90. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  91. package/dist/feature-libraries/default-schema/index.js +2 -2
  92. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  93. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  94. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  95. package/dist/feature-libraries/default-schema/schemaChecker.js +31 -26
  96. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  97. package/dist/feature-libraries/index.d.ts +2 -3
  98. package/dist/feature-libraries/index.d.ts.map +1 -1
  99. package/dist/feature-libraries/index.js +3 -11
  100. package/dist/feature-libraries/index.js.map +1 -1
  101. package/dist/feature-libraries/modular-schema/comparison.d.ts +5 -6
  102. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  103. package/dist/feature-libraries/modular-schema/comparison.js +15 -19
  104. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  105. package/dist/feature-libraries/modular-schema/index.d.ts +0 -1
  106. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  107. package/dist/feature-libraries/modular-schema/index.js +1 -8
  108. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  109. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  110. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  111. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  112. package/dist/feature-libraries/object-forest/objectForest.js +2 -3
  113. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  114. package/dist/index.d.ts +1 -1
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +6 -2
  117. package/dist/index.js.map +1 -1
  118. package/dist/packageVersion.d.ts +1 -1
  119. package/dist/packageVersion.d.ts.map +1 -1
  120. package/dist/packageVersion.js +1 -1
  121. package/dist/packageVersion.js.map +1 -1
  122. package/dist/shared-tree/independentView.d.ts +8 -0
  123. package/dist/shared-tree/independentView.d.ts.map +1 -1
  124. package/dist/shared-tree/independentView.js +23 -11
  125. package/dist/shared-tree/independentView.js.map +1 -1
  126. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  127. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  128. package/dist/shared-tree/schematizeTree.js +5 -4
  129. package/dist/shared-tree/schematizeTree.js.map +1 -1
  130. package/dist/shared-tree/schematizingTreeView.d.ts +0 -1
  131. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  132. package/dist/shared-tree/schematizingTreeView.js +7 -10
  133. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  134. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  135. package/dist/shared-tree/sharedTree.js +1 -29
  136. package/dist/shared-tree/sharedTree.js.map +1 -1
  137. package/dist/shared-tree/tree.js +1 -1
  138. package/dist/shared-tree/tree.js.map +1 -1
  139. package/dist/shared-tree/treeAlpha.d.ts +20 -6
  140. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  141. package/dist/shared-tree/treeAlpha.js +9 -4
  142. package/dist/shared-tree/treeAlpha.js.map +1 -1
  143. package/dist/shared-tree/treeCheckout.d.ts +2 -1
  144. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  145. package/dist/shared-tree/treeCheckout.js +33 -1
  146. package/dist/shared-tree/treeCheckout.js.map +1 -1
  147. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  148. package/dist/shared-tree-core/branch.js +1 -1
  149. package/dist/shared-tree-core/branch.js.map +1 -1
  150. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  151. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  152. package/dist/simple-tree/api/conciseTree.js +6 -6
  153. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  154. package/dist/simple-tree/api/configuration.d.ts +8 -2
  155. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  156. package/dist/simple-tree/api/configuration.js.map +1 -1
  157. package/dist/simple-tree/api/create.d.ts +8 -7
  158. package/dist/simple-tree/api/create.d.ts.map +1 -1
  159. package/dist/simple-tree/api/create.js +35 -22
  160. package/dist/simple-tree/api/create.js.map +1 -1
  161. package/dist/simple-tree/api/customTree.d.ts +25 -4
  162. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  163. package/dist/simple-tree/api/customTree.js +42 -16
  164. package/dist/simple-tree/api/customTree.js.map +1 -1
  165. package/dist/simple-tree/api/discrepancies.d.ts +98 -0
  166. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -0
  167. package/dist/simple-tree/api/discrepancies.js +255 -0
  168. package/dist/simple-tree/api/discrepancies.js.map +1 -0
  169. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +8 -21
  170. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  171. package/dist/simple-tree/api/schemaCompatibilityTester.js +19 -169
  172. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  173. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  174. package/dist/simple-tree/api/schemaCreationUtilities.js +2 -2
  175. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  176. package/dist/simple-tree/api/schemaFactory.d.ts +7 -4
  177. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  178. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  179. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  180. package/dist/simple-tree/api/storedSchema.js +5 -1
  181. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  182. package/dist/simple-tree/api/treeBeta.d.ts +2 -2
  183. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  184. package/dist/simple-tree/api/treeBeta.js +10 -4
  185. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  186. package/dist/simple-tree/api/verboseTree.d.ts +2 -2
  187. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  188. package/dist/simple-tree/api/verboseTree.js +15 -15
  189. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  190. package/dist/simple-tree/core/allowedTypes.d.ts +20 -4
  191. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  192. package/dist/simple-tree/core/allowedTypes.js +45 -13
  193. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  194. package/dist/simple-tree/core/context.d.ts +13 -2
  195. package/dist/simple-tree/core/context.d.ts.map +1 -1
  196. package/dist/simple-tree/core/context.js +22 -9
  197. package/dist/simple-tree/core/context.js.map +1 -1
  198. package/dist/simple-tree/core/index.d.ts +2 -2
  199. package/dist/simple-tree/core/index.d.ts.map +1 -1
  200. package/dist/simple-tree/core/index.js +3 -1
  201. package/dist/simple-tree/core/index.js.map +1 -1
  202. package/dist/simple-tree/core/treeNodeKernel.d.ts +1 -1
  203. package/dist/simple-tree/core/treeNodeKernel.js +1 -1
  204. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  205. package/dist/simple-tree/core/treeNodeValid.d.ts +1 -1
  206. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  207. package/dist/simple-tree/core/treeNodeValid.js +8 -1
  208. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  209. package/dist/simple-tree/core/walkSchema.d.ts +3 -0
  210. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  211. package/dist/simple-tree/core/walkSchema.js +2 -0
  212. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  213. package/dist/simple-tree/createContext.d.ts +2 -0
  214. package/dist/simple-tree/createContext.d.ts.map +1 -1
  215. package/dist/simple-tree/createContext.js +3 -1
  216. package/dist/simple-tree/createContext.js.map +1 -1
  217. package/dist/simple-tree/fieldSchema.d.ts +1 -0
  218. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  219. package/dist/simple-tree/fieldSchema.js +1 -0
  220. package/dist/simple-tree/fieldSchema.js.map +1 -1
  221. package/dist/simple-tree/index.d.ts +5 -4
  222. package/dist/simple-tree/index.d.ts.map +1 -1
  223. package/dist/simple-tree/index.js +8 -3
  224. package/dist/simple-tree/index.js.map +1 -1
  225. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  226. package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
  227. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  228. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  229. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  230. package/dist/simple-tree/node-kinds/index.js +1 -2
  231. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  232. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  233. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  234. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  235. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  236. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
  237. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  238. package/dist/simple-tree/node-kinds/object/objectNode.js +4 -18
  239. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  240. package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
  241. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  242. package/dist/simple-tree/prepareForInsertion.js +9 -3
  243. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  244. package/dist/simple-tree/toStoredSchema.d.ts +3 -0
  245. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  246. package/dist/simple-tree/toStoredSchema.js +3 -0
  247. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  248. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  249. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  250. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  251. package/dist/simple-tree/walkFieldSchema.d.ts +1 -0
  252. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  253. package/dist/simple-tree/walkFieldSchema.js +1 -0
  254. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  255. package/lib/codec/codec.d.ts +2 -1
  256. package/lib/codec/codec.d.ts.map +1 -1
  257. package/lib/codec/codec.js +4 -3
  258. package/lib/codec/codec.js.map +1 -1
  259. package/lib/core/index.d.ts +1 -1
  260. package/lib/core/index.d.ts.map +1 -1
  261. package/lib/core/index.js +1 -1
  262. package/lib/core/index.js.map +1 -1
  263. package/lib/core/rebase/index.d.ts +1 -1
  264. package/lib/core/rebase/index.d.ts.map +1 -1
  265. package/lib/core/rebase/index.js +1 -1
  266. package/lib/core/rebase/index.js.map +1 -1
  267. package/lib/core/rebase/types.d.ts +3 -1
  268. package/lib/core/rebase/types.d.ts.map +1 -1
  269. package/lib/core/rebase/types.js +1 -0
  270. package/lib/core/rebase/types.js.map +1 -1
  271. package/lib/core/schema-stored/schema.d.ts +1 -23
  272. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  273. package/lib/core/schema-stored/schema.js +2 -2
  274. package/lib/core/schema-stored/schema.js.map +1 -1
  275. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  276. package/lib/core/tree/detachedFieldIndex.js +2 -3
  277. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  278. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  279. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  280. package/lib/core/tree/detachedFieldIndexCodecCommon.js +64 -0
  281. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  282. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  283. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  284. package/lib/core/tree/detachedFieldIndexCodecV1.js +51 -0
  285. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  286. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  287. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  288. package/lib/core/tree/detachedFieldIndexCodecV2.js +45 -0
  289. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  290. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  291. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  292. package/lib/core/tree/detachedFieldIndexCodecs.js +21 -0
  293. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  294. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  295. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  296. package/lib/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +13 -10
  297. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  298. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  299. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  300. package/lib/core/tree/detachedFieldIndexFormatV1.js +9 -0
  301. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  302. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  303. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  304. package/lib/core/tree/detachedFieldIndexFormatV2.js +11 -0
  305. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  306. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  307. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +19 -19
  309. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  310. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  311. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  313. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  314. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  315. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  316. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +70 -57
  317. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  319. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  320. package/lib/feature-libraries/chunked-forest/codec/format.js +17 -11
  321. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  322. package/{dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts → lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  323. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  324. package/lib/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +21 -15
  325. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  326. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  327. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  328. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +19 -19
  329. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  330. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  331. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  332. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  333. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  334. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
  335. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  336. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  337. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -2
  338. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  339. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  340. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  341. package/lib/feature-libraries/default-schema/index.js +1 -1
  342. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  343. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  344. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  345. package/lib/feature-libraries/default-schema/schemaChecker.js +29 -24
  346. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  347. package/lib/feature-libraries/index.d.ts +2 -3
  348. package/lib/feature-libraries/index.d.ts.map +1 -1
  349. package/lib/feature-libraries/index.js +2 -3
  350. package/lib/feature-libraries/index.js.map +1 -1
  351. package/lib/feature-libraries/modular-schema/comparison.d.ts +5 -6
  352. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  353. package/lib/feature-libraries/modular-schema/comparison.js +14 -17
  354. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  355. package/lib/feature-libraries/modular-schema/index.d.ts +0 -1
  356. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  357. package/lib/feature-libraries/modular-schema/index.js +0 -1
  358. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  359. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  360. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  361. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  362. package/lib/feature-libraries/object-forest/objectForest.js +3 -4
  363. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  364. package/lib/index.d.ts +1 -1
  365. package/lib/index.d.ts.map +1 -1
  366. package/lib/index.js +2 -2
  367. package/lib/index.js.map +1 -1
  368. package/lib/packageVersion.d.ts +1 -1
  369. package/lib/packageVersion.d.ts.map +1 -1
  370. package/lib/packageVersion.js +1 -1
  371. package/lib/packageVersion.js.map +1 -1
  372. package/lib/shared-tree/independentView.d.ts +8 -0
  373. package/lib/shared-tree/independentView.d.ts.map +1 -1
  374. package/lib/shared-tree/independentView.js +21 -10
  375. package/lib/shared-tree/independentView.js.map +1 -1
  376. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  377. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  378. package/lib/shared-tree/schematizeTree.js +3 -2
  379. package/lib/shared-tree/schematizeTree.js.map +1 -1
  380. package/lib/shared-tree/schematizingTreeView.d.ts +0 -1
  381. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  382. package/lib/shared-tree/schematizingTreeView.js +8 -11
  383. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  384. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  385. package/lib/shared-tree/sharedTree.js +2 -30
  386. package/lib/shared-tree/sharedTree.js.map +1 -1
  387. package/lib/shared-tree/tree.js +1 -1
  388. package/lib/shared-tree/tree.js.map +1 -1
  389. package/lib/shared-tree/treeAlpha.d.ts +20 -6
  390. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  391. package/lib/shared-tree/treeAlpha.js +10 -5
  392. package/lib/shared-tree/treeAlpha.js.map +1 -1
  393. package/lib/shared-tree/treeCheckout.d.ts +2 -1
  394. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  395. package/lib/shared-tree/treeCheckout.js +34 -2
  396. package/lib/shared-tree/treeCheckout.js.map +1 -1
  397. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  398. package/lib/shared-tree-core/branch.js +1 -1
  399. package/lib/shared-tree-core/branch.js.map +1 -1
  400. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  401. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  402. package/lib/simple-tree/api/conciseTree.js +6 -6
  403. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  404. package/lib/simple-tree/api/configuration.d.ts +8 -2
  405. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  406. package/lib/simple-tree/api/configuration.js.map +1 -1
  407. package/lib/simple-tree/api/create.d.ts +8 -7
  408. package/lib/simple-tree/api/create.d.ts.map +1 -1
  409. package/lib/simple-tree/api/create.js +38 -25
  410. package/lib/simple-tree/api/create.js.map +1 -1
  411. package/lib/simple-tree/api/customTree.d.ts +25 -4
  412. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  413. package/lib/simple-tree/api/customTree.js +43 -17
  414. package/lib/simple-tree/api/customTree.js.map +1 -1
  415. package/lib/simple-tree/api/discrepancies.d.ts +98 -0
  416. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -0
  417. package/lib/simple-tree/api/discrepancies.js +250 -0
  418. package/lib/simple-tree/api/discrepancies.js.map +1 -0
  419. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +8 -21
  420. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  421. package/lib/simple-tree/api/schemaCompatibilityTester.js +19 -169
  422. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  423. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  424. package/lib/simple-tree/api/schemaCreationUtilities.js +2 -2
  425. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  426. package/lib/simple-tree/api/schemaFactory.d.ts +7 -4
  427. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  428. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  429. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  430. package/lib/simple-tree/api/storedSchema.js +6 -2
  431. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  432. package/lib/simple-tree/api/treeBeta.d.ts +2 -2
  433. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  434. package/lib/simple-tree/api/treeBeta.js +8 -2
  435. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  436. package/lib/simple-tree/api/verboseTree.d.ts +2 -2
  437. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  438. package/lib/simple-tree/api/verboseTree.js +9 -9
  439. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  440. package/lib/simple-tree/core/allowedTypes.d.ts +20 -4
  441. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  442. package/lib/simple-tree/core/allowedTypes.js +42 -12
  443. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  444. package/lib/simple-tree/core/context.d.ts +13 -2
  445. package/lib/simple-tree/core/context.d.ts.map +1 -1
  446. package/lib/simple-tree/core/context.js +22 -9
  447. package/lib/simple-tree/core/context.js.map +1 -1
  448. package/lib/simple-tree/core/index.d.ts +2 -2
  449. package/lib/simple-tree/core/index.d.ts.map +1 -1
  450. package/lib/simple-tree/core/index.js +2 -2
  451. package/lib/simple-tree/core/index.js.map +1 -1
  452. package/lib/simple-tree/core/treeNodeKernel.d.ts +1 -1
  453. package/lib/simple-tree/core/treeNodeKernel.js +1 -1
  454. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  455. package/lib/simple-tree/core/treeNodeValid.d.ts +1 -1
  456. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  457. package/lib/simple-tree/core/treeNodeValid.js +8 -1
  458. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  459. package/lib/simple-tree/core/walkSchema.d.ts +3 -0
  460. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  461. package/lib/simple-tree/core/walkSchema.js +2 -0
  462. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  463. package/lib/simple-tree/createContext.d.ts +2 -0
  464. package/lib/simple-tree/createContext.d.ts.map +1 -1
  465. package/lib/simple-tree/createContext.js +3 -1
  466. package/lib/simple-tree/createContext.js.map +1 -1
  467. package/lib/simple-tree/fieldSchema.d.ts +1 -0
  468. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  469. package/lib/simple-tree/fieldSchema.js +1 -0
  470. package/lib/simple-tree/fieldSchema.js.map +1 -1
  471. package/lib/simple-tree/index.d.ts +5 -4
  472. package/lib/simple-tree/index.d.ts.map +1 -1
  473. package/lib/simple-tree/index.js +5 -4
  474. package/lib/simple-tree/index.js.map +1 -1
  475. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  476. package/lib/simple-tree/node-kinds/array/arrayNode.js +1 -1
  477. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  478. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  479. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  480. package/lib/simple-tree/node-kinds/index.js +1 -1
  481. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  482. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  483. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  484. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  485. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  486. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
  487. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  488. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -16
  489. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  490. package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
  491. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  492. package/lib/simple-tree/prepareForInsertion.js +11 -5
  493. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  494. package/lib/simple-tree/toStoredSchema.d.ts +3 -0
  495. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  496. package/lib/simple-tree/toStoredSchema.js +3 -0
  497. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  498. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  499. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  500. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
  501. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  502. package/lib/simple-tree/walkFieldSchema.d.ts +1 -0
  503. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  504. package/lib/simple-tree/walkFieldSchema.js +1 -0
  505. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  506. package/package.json +23 -23
  507. package/src/codec/codec.ts +4 -3
  508. package/src/core/index.ts +2 -0
  509. package/src/core/rebase/index.ts +2 -0
  510. package/src/core/rebase/types.ts +4 -0
  511. package/src/core/schema-stored/schema.ts +2 -26
  512. package/src/core/tree/detachedFieldIndex.ts +4 -6
  513. package/src/core/tree/detachedFieldIndexCodecCommon.ts +87 -0
  514. package/src/core/tree/{detachedFieldIndexCodec.ts → detachedFieldIndexCodecV1.ts} +22 -68
  515. package/src/core/tree/detachedFieldIndexCodecV2.ts +72 -0
  516. package/src/core/tree/detachedFieldIndexCodecs.ts +44 -0
  517. package/src/core/tree/{detachedFieldIndexFormat.ts → detachedFieldIndexFormatCommon.ts} +32 -23
  518. package/src/core/tree/detachedFieldIndexFormatV1.ts +15 -0
  519. package/src/core/tree/detachedFieldIndexFormatV2.ts +17 -0
  520. package/src/feature-libraries/chunked-forest/codec/README.md +1 -1
  521. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +25 -25
  522. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -6
  523. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +96 -73
  524. package/src/feature-libraries/chunked-forest/codec/format.ts +20 -14
  525. package/src/feature-libraries/chunked-forest/codec/{nodeShape.ts → nodeEncoder.ts} +23 -17
  526. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +34 -34
  527. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +5 -5
  528. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +10 -0
  529. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -2
  530. package/src/feature-libraries/default-schema/index.ts +1 -1
  531. package/src/feature-libraries/default-schema/schemaChecker.ts +47 -30
  532. package/src/feature-libraries/index.ts +1 -18
  533. package/src/feature-libraries/modular-schema/comparison.ts +14 -33
  534. package/src/feature-libraries/modular-schema/index.ts +0 -17
  535. package/src/feature-libraries/object-forest/objectForest.ts +10 -6
  536. package/src/index.ts +5 -0
  537. package/src/packageVersion.ts +1 -1
  538. package/src/shared-tree/independentView.ts +45 -19
  539. package/src/shared-tree/schematizeTree.ts +3 -3
  540. package/src/shared-tree/schematizingTreeView.ts +17 -17
  541. package/src/shared-tree/sharedTree.ts +2 -42
  542. package/src/shared-tree/tree.ts +1 -1
  543. package/src/shared-tree/treeAlpha.ts +30 -18
  544. package/src/shared-tree/treeCheckout.ts +55 -11
  545. package/src/shared-tree-core/branch.ts +1 -6
  546. package/src/simple-tree/api/conciseTree.ts +9 -7
  547. package/src/simple-tree/api/configuration.ts +8 -2
  548. package/src/simple-tree/api/create.ts +49 -36
  549. package/src/simple-tree/api/customTree.ts +59 -20
  550. package/src/simple-tree/api/discrepancies.ts +473 -0
  551. package/src/simple-tree/api/schemaCompatibilityTester.ts +28 -242
  552. package/src/simple-tree/api/schemaCreationUtilities.ts +5 -2
  553. package/src/simple-tree/api/schemaFactory.ts +7 -4
  554. package/src/simple-tree/api/storedSchema.ts +6 -10
  555. package/src/simple-tree/api/treeBeta.ts +17 -4
  556. package/src/simple-tree/api/verboseTree.ts +17 -8
  557. package/src/simple-tree/core/allowedTypes.ts +54 -21
  558. package/src/simple-tree/core/context.ts +24 -22
  559. package/src/simple-tree/core/index.ts +2 -1
  560. package/src/simple-tree/core/treeNodeKernel.ts +1 -1
  561. package/src/simple-tree/core/treeNodeValid.ts +9 -2
  562. package/src/simple-tree/core/walkSchema.ts +3 -0
  563. package/src/simple-tree/createContext.ts +6 -1
  564. package/src/simple-tree/fieldSchema.ts +1 -0
  565. package/src/simple-tree/index.ts +6 -3
  566. package/src/simple-tree/node-kinds/array/arrayNode.ts +32 -19
  567. package/src/simple-tree/node-kinds/index.ts +1 -1
  568. package/src/simple-tree/node-kinds/object/index.ts +1 -1
  569. package/src/simple-tree/node-kinds/object/objectNode.ts +9 -27
  570. package/src/simple-tree/prepareForInsertion.ts +17 -9
  571. package/src/simple-tree/toStoredSchema.ts +3 -0
  572. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +6 -2
  573. package/src/simple-tree/walkFieldSchema.ts +1 -0
  574. package/dist/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  575. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  576. package/dist/core/tree/detachedFieldIndexCodec.js +0 -100
  577. package/dist/core/tree/detachedFieldIndexCodec.js.map +0 -1
  578. package/dist/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  579. package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  580. package/dist/core/tree/detachedFieldIndexFormat.js.map +0 -1
  581. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  582. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  583. package/dist/feature-libraries/initializeForest.d.ts +0 -18
  584. package/dist/feature-libraries/initializeForest.d.ts.map +0 -1
  585. package/dist/feature-libraries/initializeForest.js +0 -35
  586. package/dist/feature-libraries/initializeForest.js.map +0 -1
  587. package/dist/feature-libraries/modular-schema/discrepancies.d.ts +0 -174
  588. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +0 -1
  589. package/dist/feature-libraries/modular-schema/discrepancies.js +0 -361
  590. package/dist/feature-libraries/modular-schema/discrepancies.js.map +0 -1
  591. package/lib/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  592. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  593. package/lib/core/tree/detachedFieldIndexCodec.js +0 -96
  594. package/lib/core/tree/detachedFieldIndexCodec.js.map +0 -1
  595. package/lib/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  596. package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  597. package/lib/core/tree/detachedFieldIndexFormat.js.map +0 -1
  598. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  599. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  600. package/lib/feature-libraries/initializeForest.d.ts +0 -18
  601. package/lib/feature-libraries/initializeForest.d.ts.map +0 -1
  602. package/lib/feature-libraries/initializeForest.js +0 -31
  603. package/lib/feature-libraries/initializeForest.js.map +0 -1
  604. package/lib/feature-libraries/modular-schema/discrepancies.d.ts +0 -174
  605. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +0 -1
  606. package/lib/feature-libraries/modular-schema/discrepancies.js +0 -354
  607. package/lib/feature-libraries/modular-schema/discrepancies.js.map +0 -1
  608. package/src/feature-libraries/initializeForest.ts +0 -55
  609. package/src/feature-libraries/modular-schema/discrepancies.ts +0 -567
@@ -1,18 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { IIdCompressor } from "@fluidframework/id-compressor";
6
- import { type IEditableForest, type ITreeCursorSynchronous, type RevisionTagCodec } from "../core/index.js";
7
- /**
8
- * Initializes the given forest with the given content.
9
- * @remarks The forest must be empty when this function is called.
10
- * This does not perform an edit in the typical sense.
11
- * Instead, it creates a delta expressing a creation and insertion of the `content` under the {@link rootFieldKey}, and then applies the delta to the forest.
12
- * If `visitAnchors` is enabled, then the delta will also be applied to the forest's {@link AnchorSet} (in which case there must be no existing anchors when this function is called).
13
- *
14
- * @remarks
15
- * This does not perform an edit: it updates the forest content as if there was an edit that did that.
16
- */
17
- export declare function initializeForest(forest: IEditableForest, content: ITreeCursorSynchronous, revisionTagCodec: RevisionTagCodec, idCompressor: IIdCompressor, visitAnchors?: boolean): void;
18
- //# sourceMappingURL=initializeForest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initializeForest.d.ts","sourceRoot":"","sources":["../../src/feature-libraries/initializeForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE7F,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EAKrB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,sBAAsB,EAC/B,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,aAAa,EAC3B,YAAY,UAAQ,GAClB,IAAI,CAmBN"}
@@ -1,31 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { assert } from "@fluidframework/core-utils/internal";
6
- import { combineVisitors, deltaForRootInitialization, makeDetachedFieldIndex, visitDelta, } from "../core/index.js";
7
- /**
8
- * Initializes the given forest with the given content.
9
- * @remarks The forest must be empty when this function is called.
10
- * This does not perform an edit in the typical sense.
11
- * Instead, it creates a delta expressing a creation and insertion of the `content` under the {@link rootFieldKey}, and then applies the delta to the forest.
12
- * If `visitAnchors` is enabled, then the delta will also be applied to the forest's {@link AnchorSet} (in which case there must be no existing anchors when this function is called).
13
- *
14
- * @remarks
15
- * This does not perform an edit: it updates the forest content as if there was an edit that did that.
16
- */
17
- export function initializeForest(forest, content, revisionTagCodec, idCompressor, visitAnchors = false) {
18
- assert(forest.isEmpty, 0x747 /* forest must be empty */);
19
- const delta = deltaForRootInitialization(forest.chunkField(content));
20
- let visitor = forest.acquireVisitor();
21
- if (visitAnchors) {
22
- assert(forest.anchors.isEmpty(), 0x9b7 /* anchor set must be empty */);
23
- const anchorVisitor = forest.anchors.acquireVisitor();
24
- visitor = combineVisitors([visitor, anchorVisitor]);
25
- }
26
- // any detached trees built here are immediately attached so the revision used here doesn't matter
27
- // we use a dummy revision to make correctness checks in the detached field index easier
28
- visitDelta(delta, visitor, makeDetachedFieldIndex("init", revisionTagCodec, idCompressor), 0);
29
- visitor.free();
30
- }
31
- //# sourceMappingURL=initializeForest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initializeForest.js","sourceRoot":"","sources":["../../src/feature-libraries/initializeForest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAG7D,OAAO,EAKN,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,UAAU,GACV,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAAuB,EACvB,OAA+B,EAC/B,gBAAkC,EAClC,YAA2B,EAC3B,YAAY,GAAG,KAAK;IAEpB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACzD,MAAM,KAAK,GAAc,0BAA0B,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAChF,IAAI,OAAO,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACtC,IAAI,YAAY,EAAE,CAAC;QAClB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACvE,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QACtD,OAAO,GAAG,eAAe,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,kGAAkG;IAClG,wFAAwF;IACxF,UAAU,CACT,KAAK,EACL,OAAO,EACP,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAC9D,CAA6B,CAC7B,CAAC;IACF,OAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { SessionSpaceCompressedId, IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype DeltaRoot,\n\ttype IEditableForest,\n\ttype ITreeCursorSynchronous,\n\ttype RevisionTagCodec,\n\tcombineVisitors,\n\tdeltaForRootInitialization,\n\tmakeDetachedFieldIndex,\n\tvisitDelta,\n} from \"../core/index.js\";\n\n/**\n * Initializes the given forest with the given content.\n * @remarks The forest must be empty when this function is called.\n * This does not perform an edit in the typical sense.\n * Instead, it creates a delta expressing a creation and insertion of the `content` under the {@link rootFieldKey}, and then applies the delta to the forest.\n * If `visitAnchors` is enabled, then the delta will also be applied to the forest's {@link AnchorSet} (in which case there must be no existing anchors when this function is called).\n *\n * @remarks\n * This does not perform an edit: it updates the forest content as if there was an edit that did that.\n */\nexport function initializeForest(\n\tforest: IEditableForest,\n\tcontent: ITreeCursorSynchronous,\n\trevisionTagCodec: RevisionTagCodec,\n\tidCompressor: IIdCompressor,\n\tvisitAnchors = false,\n): void {\n\tassert(forest.isEmpty, 0x747 /* forest must be empty */);\n\tconst delta: DeltaRoot = deltaForRootInitialization(forest.chunkField(content));\n\tlet visitor = forest.acquireVisitor();\n\tif (visitAnchors) {\n\t\tassert(forest.anchors.isEmpty(), 0x9b7 /* anchor set must be empty */);\n\t\tconst anchorVisitor = forest.anchors.acquireVisitor();\n\t\tvisitor = combineVisitors([visitor, anchorVisitor]);\n\t}\n\n\t// any detached trees built here are immediately attached so the revision used here doesn't matter\n\t// we use a dummy revision to make correctness checks in the detached field index easier\n\tvisitDelta(\n\t\tdelta,\n\t\tvisitor,\n\t\tmakeDetachedFieldIndex(\"init\", revisionTagCodec, idCompressor),\n\t\t0 as SessionSpaceCompressedId,\n\t);\n\tvisitor.free();\n}\n"]}
@@ -1,174 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { type FieldKey, type FieldKindIdentifier, type TreeNodeSchemaIdentifier, type TreeStoredSchema, type ValueSchema } from "../../core/index.js";
6
- /**
7
- * Discriminated union (keyed on `mismatch`) of discrepancies between a view and stored schema.
8
- * @remarks
9
- *
10
- * 1. FieldDiscrepancy
11
- *
12
- * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of
13
- * three types of incompatibilities:
14
- *
15
- * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`
16
- * objects (e.g., optional, required, sequence, etc.).
17
- * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.
18
- * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two
19
- * `LeafNodeStoredSchema` objects.
20
- *
21
- * 2. NodeDiscrepancy
22
- *
23
- * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:
24
- *
25
- * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports
26
- * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).
27
- * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two
28
- * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.
29
- *
30
- * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of
31
- * the same kind (map, object, leaf).
32
- *
33
- * 3. Discrepancy
34
- *
35
- * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of
36
- * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it
37
- * and the ordering.
38
- */
39
- export type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;
40
- export type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;
41
- /**
42
- * A discrepancy in the declaration of a field.
43
- */
44
- export type FieldDiscrepancy = AllowedTypeDiscrepancy | FieldKindDiscrepancy | ValueSchemaDiscrepancy;
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 {
70
- mismatch: "allowedTypes";
71
- /**
72
- * List of allowed type identifiers in viewed schema which are not allowed in stored schema
73
- */
74
- view: TreeNodeSchemaIdentifier[];
75
- /**
76
- * List of allowed type identifiers in stored schema which are not allowed in view schema
77
- */
78
- stored: TreeNodeSchemaIdentifier[];
79
- }
80
- export interface FieldKindDiscrepancy extends FieldDiscrepancyLocation {
81
- mismatch: "fieldKind";
82
- view: FieldKindIdentifier;
83
- stored: FieldKindIdentifier;
84
- }
85
- export interface ValueSchemaDiscrepancy {
86
- identifier: TreeNodeSchemaIdentifier;
87
- mismatch: "valueSchema";
88
- view: ValueSchema | undefined;
89
- stored: ValueSchema | undefined;
90
- }
91
- export interface NodeKindDiscrepancy {
92
- identifier: TreeNodeSchemaIdentifier;
93
- mismatch: "nodeKind";
94
- view: SchemaFactoryNodeKind | undefined;
95
- stored: SchemaFactoryNodeKind | undefined;
96
- }
97
- export interface NodeFieldsDiscrepancy {
98
- identifier: TreeNodeSchemaIdentifier;
99
- mismatch: "fields";
100
- differences: FieldDiscrepancy[];
101
- }
102
- type SchemaFactoryNodeKind = "object" | "leaf" | "map";
103
- /**
104
- * Finds and reports discrepancies between a view schema and a stored schema.
105
- *
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.
111
- *
112
- * It is up to the caller to determine whether such discrepancies matter.
113
- */
114
- export declare function getAllowedContentDiscrepancies(view: TreeStoredSchema, stored: TreeStoredSchema): Iterable<Discrepancy>;
115
- /**
116
- * @remarks
117
- *
118
- * This function uses incompatibilities to determine if changes to a document schema are backward-compatible, i.e., it determines
119
- * whether the `view` schema allows a superset of the documents that the `stored` schema allows.
120
- * According to the policy of schema evolution, `isRepoSuperset` supports three types of changes:
121
- * 1. Adding an optional field to an object node.
122
- * 2. Expanding the set of allowed types for a field.
123
- * 3. Relaxing a field kind to a more general field kind.
124
- *
125
- * Notes: We expect isRepoSuperset to return consistent results with allowsRepoSuperset. However, currently there are some scenarios
126
- * where the inconsistency will occur:
127
- *
128
- * - Different Node Kinds: If a and b have different node kinds (e.g., a is an objectNodeSchema and b is a mapNodeSchema),
129
- * `isRepoSuperset` will determine that a can never be the superset of b. In contrast, `allowsRepoSuperset` will continue
130
- * validating internal fields.
131
- */
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;
173
- export {};
174
- //# sourceMappingURL=discrepancies.d.ts.map
@@ -1 +0,0 @@
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,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LD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAkCxF;AAqBD;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;AAgB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,mBAAmB,CAegC,CAAC;AAEzF,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AACX,KAAK,qBAAqB,GACzB,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAEpE,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,CAAC,EAAE,CAAC,EACJ,CAAC,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"}
@@ -1,354 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { assert } from "@fluidframework/core-utils/internal";
6
- import { LeafNodeStoredSchema, MapNodeStoredSchema, ObjectNodeStoredSchema, storedEmptyFieldSchema, } from "../../core/index.js";
7
- import { brand } from "../../util/index.js";
8
- function getNodeSchemaType(nodeSchema) {
9
- if (nodeSchema instanceof ObjectNodeStoredSchema) {
10
- return "object";
11
- }
12
- else if (nodeSchema instanceof MapNodeStoredSchema) {
13
- return "map";
14
- }
15
- else if (nodeSchema instanceof LeafNodeStoredSchema) {
16
- return "leaf";
17
- }
18
- throwUnsupportedNodeType(nodeSchema.constructor.name);
19
- }
20
- /**
21
- * Finds and reports discrepancies between a view schema and a stored schema.
22
- *
23
- * See documentation on {@link Discrepancy} for details of possible discrepancies.
24
- * @remarks
25
- * This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.
26
- * For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,
27
- * as well as an optional field with an allowed type set containing only unconstructable types.
28
- *
29
- * It is up to the caller to determine whether such discrepancies matter.
30
- */
31
- export function* getAllowedContentDiscrepancies(view, stored) {
32
- // check root schema discrepancies
33
- yield* getFieldDiscrepancies(view.rootFieldSchema, stored.rootFieldSchema, undefined, undefined);
34
- for (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {
35
- switch (result.type) {
36
- case "aExtra": {
37
- const viewType = getNodeSchemaType(result.value);
38
- yield {
39
- identifier: result.key,
40
- mismatch: "nodeKind",
41
- view: viewType,
42
- stored: undefined,
43
- };
44
- break;
45
- }
46
- case "bExtra": {
47
- const storedType = getNodeSchemaType(result.value);
48
- yield {
49
- identifier: result.key,
50
- mismatch: "nodeKind",
51
- view: undefined,
52
- stored: storedType,
53
- };
54
- break;
55
- }
56
- case "both": {
57
- yield* getNodeDiscrepancies(result.key, result.valueA, result.valueB);
58
- break;
59
- }
60
- default:
61
- break;
62
- }
63
- }
64
- }
65
- function* getNodeDiscrepancies(identifier, view, stored) {
66
- const viewType = getNodeSchemaType(view);
67
- const storedType = getNodeSchemaType(stored);
68
- if (viewType !== storedType) {
69
- yield {
70
- identifier,
71
- mismatch: "nodeKind",
72
- view: viewType,
73
- stored: storedType,
74
- };
75
- return;
76
- }
77
- switch (viewType) {
78
- case "object": {
79
- const differences = Array.from(trackObjectNodeDiscrepancies(identifier, view, stored));
80
- if (differences.length > 0) {
81
- yield {
82
- identifier,
83
- mismatch: "fields",
84
- differences,
85
- };
86
- }
87
- break;
88
- }
89
- case "map":
90
- yield* getFieldDiscrepancies(view.mapFields, stored.mapFields, identifier, undefined);
91
- break;
92
- case "leaf": {
93
- const viewValue = view.leafValue;
94
- const storedValue = stored.leafValue;
95
- if (viewValue !== storedValue) {
96
- yield {
97
- identifier,
98
- mismatch: "valueSchema",
99
- view: viewValue,
100
- stored: storedValue,
101
- };
102
- }
103
- break;
104
- }
105
- default:
106
- break;
107
- }
108
- }
109
- /**
110
- * The function to track the discrepancies between two field stored schemas.
111
- *
112
- * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.
113
- */
114
- function* getFieldDiscrepancies(view, stored, identifier, fieldKey) {
115
- // Only track the symmetric differences of two sets.
116
- const findSetDiscrepancies = (a, b) => {
117
- const aDiff = [...a].filter((value) => !b.has(value));
118
- const bDiff = [...b].filter((value) => !a.has(value));
119
- return [aDiff, bDiff];
120
- };
121
- const [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);
122
- if (viewExtra.length > 0 || storedExtra.length > 0) {
123
- yield {
124
- identifier,
125
- fieldKey,
126
- mismatch: "allowedTypes",
127
- view: viewExtra,
128
- stored: storedExtra,
129
- };
130
- }
131
- if (view.kind !== stored.kind) {
132
- yield {
133
- identifier,
134
- fieldKey,
135
- mismatch: "fieldKind",
136
- view: view.kind,
137
- stored: stored.kind,
138
- };
139
- }
140
- }
141
- function* trackObjectNodeDiscrepancies(identifier, view, stored) {
142
- /**
143
- * Similar to the logic used for tracking discrepancies between two node schemas, we will identify
144
- * three types of differences:
145
- * 1. Fields that exist in the view schema but not in the stored schema.
146
- * 2. Fields that exist in both schemas but have different contents.
147
- * 3. Fields that exist in the stored schema but not in the view schema.
148
- *
149
- * First, the view schema is iterated to track the first two types of differences.
150
- * Then, the stored schema is iterated to find the third type.
151
- */
152
- for (const result of compareMaps(view.objectNodeFields, stored.objectNodeFields)) {
153
- const fieldKey = result.key;
154
- switch (result.type) {
155
- case "aExtra": {
156
- if (result.value.kind === storedEmptyFieldSchema.kind) {
157
- // In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden
158
- // (by way of omission). We treat these identically anyway.
159
- break;
160
- }
161
- yield {
162
- identifier,
163
- fieldKey,
164
- mismatch: "fieldKind",
165
- view: result.value.kind,
166
- stored: storedEmptyFieldSchema.kind,
167
- };
168
- break;
169
- }
170
- case "bExtra": {
171
- if (result.value.kind === storedEmptyFieldSchema.kind) {
172
- // In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden
173
- // (by way of omission). We treat these identically anyway.
174
- break;
175
- }
176
- yield {
177
- identifier,
178
- fieldKey,
179
- mismatch: "fieldKind",
180
- view: storedEmptyFieldSchema.kind,
181
- stored: result.value.kind,
182
- };
183
- break;
184
- }
185
- case "both": {
186
- yield* getFieldDiscrepancies(result.valueA, result.valueB, identifier, fieldKey);
187
- break;
188
- }
189
- default:
190
- break;
191
- }
192
- }
193
- }
194
- function* compareMaps(a, b) {
195
- for (const [key, valueA] of a) {
196
- const valueB = b.get(key);
197
- yield valueB === undefined
198
- ? { type: "aExtra", key, value: valueA }
199
- : { type: "both", key, valueA, valueB };
200
- }
201
- for (const [key, valueB] of b) {
202
- if (!a.has(key)) {
203
- yield { type: "bExtra", key, value: valueB };
204
- }
205
- }
206
- }
207
- /**
208
- * @remarks
209
- *
210
- * This function uses incompatibilities to determine if changes to a document schema are backward-compatible, i.e., it determines
211
- * whether the `view` schema allows a superset of the documents that the `stored` schema allows.
212
- * According to the policy of schema evolution, `isRepoSuperset` supports three types of changes:
213
- * 1. Adding an optional field to an object node.
214
- * 2. Expanding the set of allowed types for a field.
215
- * 3. Relaxing a field kind to a more general field kind.
216
- *
217
- * Notes: We expect isRepoSuperset to return consistent results with allowsRepoSuperset. However, currently there are some scenarios
218
- * where the inconsistency will occur:
219
- *
220
- * - Different Node Kinds: If a and b have different node kinds (e.g., a is an objectNodeSchema and b is a mapNodeSchema),
221
- * `isRepoSuperset` will determine that a can never be the superset of b. In contrast, `allowsRepoSuperset` will continue
222
- * validating internal fields.
223
- */
224
- export function isRepoSuperset(view, stored) {
225
- const discrepancies = getAllowedContentDiscrepancies(view, stored);
226
- for (const discrepancy of discrepancies) {
227
- switch (discrepancy.mismatch) {
228
- case "nodeKind": {
229
- if (discrepancy.stored !== undefined) {
230
- // It's fine for the view schema to know of a node type that the stored schema doesn't know about.
231
- return false;
232
- }
233
- break;
234
- }
235
- case "valueSchema":
236
- case "allowedTypes":
237
- case "fieldKind": {
238
- if (!isFieldDiscrepancyCompatible(discrepancy)) {
239
- return false;
240
- }
241
- break;
242
- }
243
- case "fields": {
244
- if (discrepancy.differences.some((difference) => !isFieldDiscrepancyCompatible(difference))) {
245
- return false;
246
- }
247
- break;
248
- }
249
- // No default
250
- }
251
- }
252
- return true;
253
- }
254
- function isFieldDiscrepancyCompatible(discrepancy) {
255
- switch (discrepancy.mismatch) {
256
- case "allowedTypes": {
257
- // Since we only track the symmetric difference between the allowed types in the view and
258
- // stored schemas, it's sufficient to check if any extra allowed types still exist in the
259
- // stored schema.
260
- return discrepancy.stored.length === 0;
261
- }
262
- case "fieldKind": {
263
- return posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);
264
- }
265
- case "valueSchema": {
266
- return false;
267
- }
268
- // No default
269
- }
270
- return false;
271
- }
272
- /**
273
- * @privateRemarks
274
- * TODO: Knowledge of specific field kinds is not appropriate for modular schema.
275
- * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema
276
- * (this is analogous to what is done in comparison.ts).
277
- */
278
- const FieldKindIdentifiers = {
279
- forbidden: brand("Forbidden"),
280
- required: brand("Value"),
281
- identifier: brand("Identifier"),
282
- optional: brand("Optional"),
283
- sequence: brand("Sequence"),
284
- };
285
- /**
286
- * A realizer for the partial order of field kind relaxability.
287
- *
288
- * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized
289
- * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds
290
- * without excessive casework.
291
- *
292
- * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):
293
- * ```
294
- * sequence
295
- * |
296
- * optional
297
- * | \
298
- * required forbidden
299
- * |
300
- * identifier
301
- * ```
302
- */
303
- export const fieldRealizer = [
304
- [
305
- FieldKindIdentifiers.forbidden,
306
- FieldKindIdentifiers.identifier,
307
- FieldKindIdentifiers.required,
308
- FieldKindIdentifiers.optional,
309
- FieldKindIdentifiers.sequence,
310
- ],
311
- [
312
- FieldKindIdentifiers.identifier,
313
- FieldKindIdentifiers.required,
314
- FieldKindIdentifiers.forbidden,
315
- FieldKindIdentifiers.optional,
316
- FieldKindIdentifiers.sequence,
317
- ],
318
- ].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));
319
- export const PosetComparisonResult = {
320
- Less: "<",
321
- Greater: ">",
322
- Equal: "=",
323
- Incomparable: "||",
324
- };
325
- export function comparePosetElements(a, b, realizer) {
326
- let hasLessThanResult = false;
327
- let hasGreaterThanResult = false;
328
- for (const extension of realizer) {
329
- const aIndex = extension.get(a);
330
- const bIndex = extension.get(b);
331
- assert(aIndex !== undefined && bIndex !== undefined, 0xa72 /* Invalid realizer */);
332
- if (aIndex < bIndex) {
333
- hasLessThanResult = true;
334
- }
335
- else if (aIndex > bIndex) {
336
- hasGreaterThanResult = true;
337
- }
338
- }
339
- return hasLessThanResult
340
- ? hasGreaterThanResult
341
- ? PosetComparisonResult.Incomparable
342
- : PosetComparisonResult.Less
343
- : hasGreaterThanResult
344
- ? PosetComparisonResult.Greater
345
- : PosetComparisonResult.Equal;
346
- }
347
- export function posetLte(a, b, realizer) {
348
- const comparison = comparePosetElements(a, b, realizer);
349
- return (comparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal);
350
- }
351
- function throwUnsupportedNodeType(type) {
352
- throw new TypeError(`Unsupported node stored schema type: ${type}`);
353
- }
354
- //# sourceMappingURL=discrepancies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discrepancies.js","sourceRoot":"","sources":["../../../src/feature-libraries/modular-schema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M,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACnF,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;YACrB,iBAAiB,GAAG,IAAI,CAAC;QAC1B,CAAC;aAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;YAC5B,oBAAoB,GAAG,IAAI,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,OAAO,iBAAiB;QACvB,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,YAAY;YACpC,CAAC,CAAC,qBAAqB,CAAC,IAAI;QAC7B,CAAC,CAAC,oBAAoB;YACrB,CAAC,CAAC,qBAAqB,CAAC,OAAO;YAC/B,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAI,CAAI,EAAE,CAAI,EAAE,QAAqB;IAC5D,MAAM,UAAU,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACxD,OAAO,CACN,UAAU,KAAK,qBAAqB,CAAC,IAAI,IAAI,UAAU,KAAK,qBAAqB,CAAC,KAAK,CACvF,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAY;IAC7C,MAAM,IAAI,SAAS,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\tstoredEmptyFieldSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n\ttype ValueSchema,\n} from \"../../core/index.js\";\nimport { brand } from \"../../util/index.js\";\n\n// TODO:\n// The comparisons in this file seem redundant with those in comparison.ts.\n// Rather than both existing, one of which just returns boolean and the other which returns additional details, a simple comparison which returns everything needed should be used.\n\n/**\n * Discriminated union (keyed on `mismatch`) of discrepancies between a view and stored schema.\n * @remarks\n *\n * 1. FieldDiscrepancy\n *\n * `FieldDiscrepancy` represents the differences between two `TreeFieldStoredSchema` objects. It consists of\n * three types of incompatibilities:\n *\n * - FieldKindDiscrepancy: Indicates the differences in `FieldKindIdentifier` between two `TreeFieldStoredSchema`\n * objects (e.g., optional, required, sequence, etc.).\n * - AllowedTypesDiscrepancy: Indicates the differences in the allowed child types between the two schemas.\n * - ValueSchemaDiscrepancy: Specifically indicates the differences in the `ValueSchema` of two\n * `LeafNodeStoredSchema` objects.\n *\n * 2. NodeDiscrepancy\n *\n * `NodeDiscrepancy` represents the differences between two `TreeNodeStoredSchema` objects and includes:\n *\n * - NodeKindDiscrepancy: Indicates the differences in the types of `TreeNodeStoredSchema` (currently supports\n * `ObjectNodeStoredSchema`, `MapNodeStoredSchema`, and `LeafNodeStoredSchema`).\n * - NodeFieldsDiscrepancy: Indicates the `FieldDiscrepancy` of `TreeFieldStoredSchema` within two\n * `TreeNodeStoredSchema`. It includes an array of `FieldDiscrepancy` instances in the `differences` field.\n *\n * When comparing two nodes for compatibility, it only makes sense to compare their fields if the nodes are of\n * the same kind (map, object, leaf).\n *\n * 3. Discrepancy\n *\n * Discrepancy consists of both `NodeDiscrepancy` and `FieldDiscrepancy`, representing any kind of\n * schema differences. See {@link getAllowedContentDiscrepancies} for more details about how we process it\n * and the ordering.\n */\nexport type Discrepancy = FieldDiscrepancy | NodeDiscrepancy;\n\nexport type NodeDiscrepancy = NodeKindDiscrepancy | NodeFieldsDiscrepancy;\n\n/**\n * A discrepancy in the declaration of a field.\n */\nexport type FieldDiscrepancy =\n\t| AllowedTypeDiscrepancy\n\t| FieldKindDiscrepancy\n\t| ValueSchemaDiscrepancy;\n\n/**\n * Information about where a field discrepancy is located within a collection of schema.\n */\nexport interface FieldDiscrepancyLocation {\n\t/**\n\t * The {@link TreeNodeSchemaIdentifier} that contains the discrepancy.\n\t *\n\t * Undefined iff the discrepancy is part of the root field schema.\n\t */\n\tidentifier: TreeNodeSchemaIdentifier | undefined;\n\t/**\n\t * The {@link FieldKey} for the field that contains the discrepancy.\n\t * Undefined when:\n\t * - the discrepancy is part of the root field schema\n\t * - the discrepancy is for 'all fields' of a map node\n\t */\n\tfieldKey: FieldKey | undefined;\n}\n\n/**\n * A discrepancy in the allowed types of a field.\n *\n * @remarks\n * This reports the symmetric difference of allowed types in view/stored to enable more efficient checks for compatibility\n */\nexport interface AllowedTypeDiscrepancy extends FieldDiscrepancyLocation {\n\tmismatch: \"allowedTypes\";\n\t/**\n\t * List of allowed type identifiers in viewed schema which are not allowed in stored schema\n\t */\n\tview: TreeNodeSchemaIdentifier[];\n\t/**\n\t * List of allowed type identifiers in stored schema which are not allowed in view schema\n\t */\n\tstored: TreeNodeSchemaIdentifier[];\n}\n\nexport interface FieldKindDiscrepancy extends FieldDiscrepancyLocation {\n\tmismatch: \"fieldKind\";\n\tview: FieldKindIdentifier;\n\tstored: FieldKindIdentifier;\n}\n\nexport interface ValueSchemaDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"valueSchema\";\n\tview: ValueSchema | undefined;\n\tstored: ValueSchema | undefined;\n}\n\nexport interface NodeKindDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"nodeKind\";\n\tview: SchemaFactoryNodeKind | undefined;\n\tstored: SchemaFactoryNodeKind | undefined;\n}\n\nexport interface NodeFieldsDiscrepancy {\n\tidentifier: TreeNodeSchemaIdentifier;\n\tmismatch: \"fields\";\n\tdifferences: FieldDiscrepancy[];\n}\n\ntype SchemaFactoryNodeKind = \"object\" | \"leaf\" | \"map\";\n\nfunction getNodeSchemaType(nodeSchema: TreeNodeStoredSchema): SchemaFactoryNodeKind {\n\tif (nodeSchema instanceof ObjectNodeStoredSchema) {\n\t\treturn \"object\";\n\t} else if (nodeSchema instanceof MapNodeStoredSchema) {\n\t\treturn \"map\";\n\t} else if (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\treturn \"leaf\";\n\t}\n\tthrowUnsupportedNodeType(nodeSchema.constructor.name);\n}\n\n/**\n * Finds and reports discrepancies between a view schema and a stored schema.\n *\n * See documentation on {@link Discrepancy} for details of possible discrepancies.\n * @remarks\n * This function does not attempt to distinguish between equivalent representations of a node/field involving extraneous never trees.\n * For example, a Forbidden field with allowed type set `[]` is equivalent to an optional field with allowed type set `[]`,\n * as well as an optional field with an allowed type set containing only unconstructable types.\n *\n * It is up to the caller to determine whether such discrepancies matter.\n */\nexport function* getAllowedContentDiscrepancies(\n\tview: TreeStoredSchema,\n\tstored: TreeStoredSchema,\n): Iterable<Discrepancy> {\n\t// check root schema discrepancies\n\tyield* getFieldDiscrepancies(\n\t\tview.rootFieldSchema,\n\t\tstored.rootFieldSchema,\n\t\tundefined,\n\t\tundefined,\n\t);\n\n\tfor (const result of compareMaps(view.nodeSchema, stored.nodeSchema)) {\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tconst viewType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: viewType,\n\t\t\t\t\tstored: undefined,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tconst storedType = getNodeSchemaType(result.value);\n\t\t\t\tyield {\n\t\t\t\t\tidentifier: result.key,\n\t\t\t\t\tmismatch: \"nodeKind\",\n\t\t\t\t\tview: undefined,\n\t\t\t\t\tstored: storedType,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getNodeDiscrepancies(result.key, result.valueA, result.valueB);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction* getNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: TreeNodeStoredSchema,\n\tstored: TreeNodeStoredSchema,\n): Iterable<Discrepancy> {\n\tconst viewType = getNodeSchemaType(view);\n\tconst storedType = getNodeSchemaType(stored);\n\tif (viewType !== storedType) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tmismatch: \"nodeKind\",\n\t\t\tview: viewType,\n\t\t\tstored: storedType,\n\t\t};\n\t\treturn;\n\t}\n\n\tswitch (viewType) {\n\t\tcase \"object\": {\n\t\t\tconst differences = Array.from(\n\t\t\t\ttrackObjectNodeDiscrepancies(\n\t\t\t\t\tidentifier,\n\t\t\t\t\tview as ObjectNodeStoredSchema,\n\t\t\t\t\tstored as ObjectNodeStoredSchema,\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (differences.length > 0) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"fields\",\n\t\t\t\t\tdifferences,\n\t\t\t\t} satisfies NodeFieldsDiscrepancy;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"map\":\n\t\t\tyield* getFieldDiscrepancies(\n\t\t\t\t(view as MapNodeStoredSchema).mapFields,\n\t\t\t\t(stored as MapNodeStoredSchema).mapFields,\n\t\t\t\tidentifier,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"leaf\": {\n\t\t\tconst viewValue = (view as LeafNodeStoredSchema).leafValue;\n\t\t\tconst storedValue = (stored as LeafNodeStoredSchema).leafValue;\n\t\t\tif (viewValue !== storedValue) {\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tmismatch: \"valueSchema\",\n\t\t\t\t\tview: viewValue,\n\t\t\t\t\tstored: storedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/**\n * The function to track the discrepancies between two field stored schemas.\n *\n * @param keyOrRoot - If the key is missing, it indicates that this is the root field schema.\n */\nfunction* getFieldDiscrepancies(\n\tview: TreeFieldStoredSchema,\n\tstored: TreeFieldStoredSchema,\n\tidentifier: TreeNodeSchemaIdentifier | undefined,\n\tfieldKey: FieldKey | undefined,\n): Iterable<FieldDiscrepancy> {\n\t// Only track the symmetric differences of two sets.\n\tconst findSetDiscrepancies = (\n\t\ta: TreeTypeSet,\n\t\tb: TreeTypeSet,\n\t): [TreeNodeSchemaIdentifier[], TreeNodeSchemaIdentifier[]] => {\n\t\tconst aDiff = [...a].filter((value) => !b.has(value));\n\t\tconst bDiff = [...b].filter((value) => !a.has(value));\n\t\treturn [aDiff, bDiff];\n\t};\n\n\tconst [viewExtra, storedExtra] = findSetDiscrepancies(view.types, stored.types);\n\tif (viewExtra.length > 0 || storedExtra.length > 0) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"allowedTypes\",\n\t\t\tview: viewExtra,\n\t\t\tstored: storedExtra,\n\t\t} satisfies AllowedTypeDiscrepancy;\n\t}\n\n\tif (view.kind !== stored.kind) {\n\t\tyield {\n\t\t\tidentifier,\n\t\t\tfieldKey,\n\t\t\tmismatch: \"fieldKind\",\n\t\t\tview: view.kind,\n\t\t\tstored: stored.kind,\n\t\t} satisfies FieldKindDiscrepancy;\n\t}\n}\n\nfunction* trackObjectNodeDiscrepancies(\n\tidentifier: TreeNodeSchemaIdentifier,\n\tview: ObjectNodeStoredSchema,\n\tstored: ObjectNodeStoredSchema,\n): Iterable<FieldDiscrepancy> {\n\t/**\n\t * Similar to the logic used for tracking discrepancies between two node schemas, we will identify\n\t * three types of differences:\n\t * 1. Fields that exist in the view schema but not in the stored schema.\n\t * 2. Fields that exist in both schemas but have different contents.\n\t * 3. Fields that exist in the stored schema but not in the view schema.\n\t *\n\t * First, the view schema is iterated to track the first two types of differences.\n\t * Then, the stored schema is iterated to find the third type.\n\t */\n\n\tfor (const result of compareMaps(view.objectNodeFields, stored.objectNodeFields)) {\n\t\tconst fieldKey = result.key;\n\t\tswitch (result.type) {\n\t\t\tcase \"aExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tfieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: result.value.kind,\n\t\t\t\t\tstored: storedEmptyFieldSchema.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"bExtra\": {\n\t\t\t\tif (result.value.kind === storedEmptyFieldSchema.kind) {\n\t\t\t\t\t// In one of view/stored, this field is explicitly forbidden, but in the other it is implicitly forbidden\n\t\t\t\t\t// (by way of omission). We treat these identically anyway.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tidentifier,\n\t\t\t\t\tfieldKey,\n\t\t\t\t\tmismatch: \"fieldKind\",\n\t\t\t\t\tview: storedEmptyFieldSchema.kind,\n\t\t\t\t\tstored: result.value.kind,\n\t\t\t\t} satisfies FieldKindDiscrepancy;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"both\": {\n\t\t\t\tyield* getFieldDiscrepancies(result.valueA, result.valueB, identifier, fieldKey);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction* compareMaps<K, V1, V2>(\n\ta: ReadonlyMap<K, V1>,\n\tb: ReadonlyMap<K, V2>,\n): Iterable<\n\t| { type: \"aExtra\"; key: K; value: V1 }\n\t| { type: \"bExtra\"; key: K; value: V2 }\n\t| { type: \"both\"; key: K; valueA: V1; valueB: V2 }\n> {\n\tfor (const [key, valueA] of a) {\n\t\tconst valueB = b.get(key);\n\t\tyield valueB === undefined\n\t\t\t? { type: \"aExtra\", key, value: valueA }\n\t\t\t: { type: \"both\", key, valueA, valueB };\n\t}\n\tfor (const [key, valueB] of b) {\n\t\tif (!a.has(key)) {\n\t\t\tyield { type: \"bExtra\", key, value: valueB };\n\t\t}\n\t}\n}\n/**\n * @remarks\n *\n * This function uses incompatibilities to determine if changes to a document schema are backward-compatible, i.e., it determines\n * whether the `view` schema allows a superset of the documents that the `stored` schema allows.\n * According to the policy of schema evolution, `isRepoSuperset` supports three types of changes:\n * 1. Adding an optional field to an object node.\n * 2. Expanding the set of allowed types for a field.\n * 3. Relaxing a field kind to a more general field kind.\n *\n * Notes: We expect isRepoSuperset to return consistent results with allowsRepoSuperset. However, currently there are some scenarios\n * where the inconsistency will occur:\n *\n * - Different Node Kinds: If a and b have different node kinds (e.g., a is an objectNodeSchema and b is a mapNodeSchema),\n * `isRepoSuperset` will determine that a can never be the superset of b. In contrast, `allowsRepoSuperset` will continue\n * validating internal fields.\n */\nexport function isRepoSuperset(view: TreeStoredSchema, stored: TreeStoredSchema): boolean {\n\tconst discrepancies = getAllowedContentDiscrepancies(view, stored);\n\n\tfor (const discrepancy of discrepancies) {\n\t\tswitch (discrepancy.mismatch) {\n\t\t\tcase \"nodeKind\": {\n\t\t\t\tif (discrepancy.stored !== undefined) {\n\t\t\t\t\t// It's fine for the view schema to know of a node type that the stored schema doesn't know about.\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"valueSchema\":\n\t\t\tcase \"allowedTypes\":\n\t\t\tcase \"fieldKind\": {\n\t\t\t\tif (!isFieldDiscrepancyCompatible(discrepancy)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"fields\": {\n\t\t\t\tif (\n\t\t\t\t\tdiscrepancy.differences.some(\n\t\t\t\t\t\t(difference) => !isFieldDiscrepancyCompatible(difference),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// No default\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isFieldDiscrepancyCompatible(discrepancy: FieldDiscrepancy): boolean {\n\tswitch (discrepancy.mismatch) {\n\t\tcase \"allowedTypes\": {\n\t\t\t// Since we only track the symmetric difference between the allowed types in the view and\n\t\t\t// stored schemas, it's sufficient to check if any extra allowed types still exist in the\n\t\t\t// stored schema.\n\t\t\treturn discrepancy.stored.length === 0;\n\t\t}\n\t\tcase \"fieldKind\": {\n\t\t\treturn posetLte(discrepancy.stored, discrepancy.view, fieldRealizer);\n\t\t}\n\t\tcase \"valueSchema\": {\n\t\t\treturn false;\n\t\t}\n\t\t// No default\n\t}\n\treturn false;\n}\n\n/**\n * A linear extension of a partially-ordered set of `T`s. See:\n * https://en.wikipedia.org/wiki/Linear_extension\n *\n * The linear extension is represented as a lookup from each poset element to its index in the linear extension.\n */\nexport type LinearExtension<T> = Map<T, number>;\n\n/**\n * A realizer for a partially-ordered set. See:\n * https://en.wikipedia.org/wiki/Order_dimension\n */\nexport type Realizer<T> = LinearExtension<T>[];\n\n/**\n * @privateRemarks\n * TODO: Knowledge of specific field kinds is not appropriate for modular schema.\n * This bit of field comparison should be dependency injected by default-schema if this comparison logic remains in modular-schema\n * (this is analogous to what is done in comparison.ts).\n */\nconst FieldKindIdentifiers = {\n\tforbidden: brand<FieldKindIdentifier>(\"Forbidden\"),\n\trequired: brand<FieldKindIdentifier>(\"Value\"),\n\tidentifier: brand<FieldKindIdentifier>(\"Identifier\"),\n\toptional: brand<FieldKindIdentifier>(\"Optional\"),\n\tsequence: brand<FieldKindIdentifier>(\"Sequence\"),\n};\n\n/**\n * A realizer for the partial order of field kind relaxability.\n *\n * It seems extremely likely that this partial order will remain dimension 2 over time (i.e. the set of allowed relaxations can be visualized\n * with a [dominance drawing](https://en.wikipedia.org/wiki/Dominance_drawing)), so this strategy allows efficient comarison between field kinds\n * without excessive casework.\n *\n * Hasse diagram for the partial order is shown below (lower fields can be relaxed to higher fields):\n * ```\n * sequence\n * |\n * optional\n * | \\\n * required forbidden\n * |\n * identifier\n * ```\n */\nexport const fieldRealizer: Realizer<FieldKindIdentifier> = [\n\t[\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n\t[\n\t\tFieldKindIdentifiers.identifier,\n\t\tFieldKindIdentifiers.required,\n\t\tFieldKindIdentifiers.forbidden,\n\t\tFieldKindIdentifiers.optional,\n\t\tFieldKindIdentifiers.sequence,\n\t],\n].map((extension) => new Map(extension.map((identifier, index) => [identifier, index])));\n\nexport const PosetComparisonResult = {\n\tLess: \"<\",\n\tGreater: \">\",\n\tEqual: \"=\",\n\tIncomparable: \"||\",\n} as const;\ntype PosetComparisonResult =\n\t(typeof PosetComparisonResult)[keyof typeof PosetComparisonResult];\n\nexport function comparePosetElements<T>(\n\ta: T,\n\tb: T,\n\trealizer: Realizer<T>,\n): PosetComparisonResult {\n\tlet hasLessThanResult = false;\n\tlet hasGreaterThanResult = false;\n\tfor (const extension of realizer) {\n\t\tconst aIndex = extension.get(a);\n\t\tconst bIndex = extension.get(b);\n\t\tassert(aIndex !== undefined && bIndex !== undefined, 0xa72 /* Invalid realizer */);\n\t\tif (aIndex < bIndex) {\n\t\t\thasLessThanResult = true;\n\t\t} else if (aIndex > bIndex) {\n\t\t\thasGreaterThanResult = true;\n\t\t}\n\t}\n\n\treturn hasLessThanResult\n\t\t? hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Incomparable\n\t\t\t: PosetComparisonResult.Less\n\t\t: hasGreaterThanResult\n\t\t\t? PosetComparisonResult.Greater\n\t\t\t: PosetComparisonResult.Equal;\n}\n\nexport function posetLte<T>(a: T, b: T, realizer: Realizer<T>): boolean {\n\tconst comparison = comparePosetElements(a, b, realizer);\n\treturn (\n\t\tcomparison === PosetComparisonResult.Less || comparison === PosetComparisonResult.Equal\n\t);\n}\n\nfunction throwUnsupportedNodeType(type: string): never {\n\tthrow new TypeError(`Unsupported node stored schema type: ${type}`);\n}\n"]}