@fluidframework/tree 2.51.0 → 2.53.0-350190

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 (730) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/CHANGELOG.md +43 -0
  3. package/api-report/tree.alpha.api.md +40 -30
  4. package/dist/alpha.d.ts +2 -1
  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 +15 -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 +1 -2
  98. package/dist/feature-libraries/index.d.ts.map +1 -1
  99. package/dist/feature-libraries/index.js +2 -4
  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 -16
  104. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  105. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  106. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  107. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  108. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  109. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  110. package/dist/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  111. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  113. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  114. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +49 -20
  115. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  116. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  117. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  118. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  119. package/dist/feature-libraries/object-forest/objectForest.js +2 -3
  120. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  121. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  122. package/dist/feature-libraries/optional-field/optionalField.js +3 -0
  123. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  124. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  125. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  126. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  127. package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  128. package/dist/index.d.ts +1 -1
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +6 -2
  131. package/dist/index.js.map +1 -1
  132. package/dist/jsonDomainSchema.d.ts +5 -3
  133. package/dist/jsonDomainSchema.d.ts.map +1 -1
  134. package/dist/jsonDomainSchema.js.map +1 -1
  135. package/dist/packageVersion.d.ts +1 -1
  136. package/dist/packageVersion.d.ts.map +1 -1
  137. package/dist/packageVersion.js +1 -1
  138. package/dist/packageVersion.js.map +1 -1
  139. package/dist/shared-tree/independentView.d.ts +8 -0
  140. package/dist/shared-tree/independentView.d.ts.map +1 -1
  141. package/dist/shared-tree/independentView.js +23 -11
  142. package/dist/shared-tree/independentView.js.map +1 -1
  143. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  144. package/dist/shared-tree/schematizeTree.js +1 -1
  145. package/dist/shared-tree/schematizeTree.js.map +1 -1
  146. package/dist/shared-tree/schematizingTreeView.d.ts +0 -1
  147. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  148. package/dist/shared-tree/schematizingTreeView.js +9 -12
  149. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  150. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  151. package/dist/shared-tree/sharedTree.js +1 -29
  152. package/dist/shared-tree/sharedTree.js.map +1 -1
  153. package/dist/shared-tree/treeAlpha.d.ts +20 -6
  154. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  155. package/dist/shared-tree/treeAlpha.js +18 -7
  156. package/dist/shared-tree/treeAlpha.js.map +1 -1
  157. package/dist/shared-tree/treeCheckout.d.ts +2 -1
  158. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  159. package/dist/shared-tree/treeCheckout.js +32 -0
  160. package/dist/shared-tree/treeCheckout.js.map +1 -1
  161. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  162. package/dist/shared-tree-core/branch.js +1 -1
  163. package/dist/shared-tree-core/branch.js.map +1 -1
  164. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  165. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  166. package/dist/simple-tree/api/conciseTree.js +6 -6
  167. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  168. package/dist/simple-tree/api/configuration.d.ts +11 -2
  169. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  170. package/dist/simple-tree/api/configuration.js +5 -1
  171. package/dist/simple-tree/api/configuration.js.map +1 -1
  172. package/dist/simple-tree/api/create.d.ts +8 -7
  173. package/dist/simple-tree/api/create.d.ts.map +1 -1
  174. package/dist/simple-tree/api/create.js +33 -23
  175. package/dist/simple-tree/api/create.js.map +1 -1
  176. package/dist/simple-tree/api/customTree.d.ts +25 -4
  177. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  178. package/dist/simple-tree/api/customTree.js +42 -16
  179. package/dist/simple-tree/api/customTree.js.map +1 -1
  180. package/dist/simple-tree/api/discrepancies.d.ts +94 -0
  181. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -0
  182. package/dist/simple-tree/api/discrepancies.js +256 -0
  183. package/dist/simple-tree/api/discrepancies.js.map +1 -0
  184. package/dist/simple-tree/api/index.d.ts +3 -2
  185. package/dist/simple-tree/api/index.d.ts.map +1 -1
  186. package/dist/simple-tree/api/index.js +3 -2
  187. package/dist/simple-tree/api/index.js.map +1 -1
  188. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  189. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  190. package/dist/simple-tree/api/schemaCompatibilityTester.js +17 -117
  191. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  192. package/dist/simple-tree/api/schemaFactory.d.ts +16 -159
  193. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  194. package/dist/simple-tree/api/schemaFactory.js +4 -47
  195. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  196. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  197. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  198. package/dist/simple-tree/api/schemaFactoryAlpha.js +33 -11
  199. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  200. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  201. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  202. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -7
  203. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  204. package/dist/simple-tree/api/schemaStatics.d.ts +158 -0
  205. package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -0
  206. package/dist/simple-tree/api/schemaStatics.js +59 -0
  207. package/dist/simple-tree/api/schemaStatics.js.map +1 -0
  208. package/dist/simple-tree/api/storedSchema.d.ts +5 -3
  209. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  210. package/dist/simple-tree/api/storedSchema.js +9 -3
  211. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  212. package/dist/simple-tree/api/treeBeta.d.ts +2 -2
  213. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  214. package/dist/simple-tree/api/treeBeta.js +16 -4
  215. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  216. package/dist/simple-tree/api/verboseTree.d.ts +2 -2
  217. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  218. package/dist/simple-tree/api/verboseTree.js +15 -15
  219. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  220. package/dist/simple-tree/core/allowedTypes.d.ts +43 -11
  221. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  222. package/dist/simple-tree/core/allowedTypes.js +51 -11
  223. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  224. package/dist/simple-tree/core/context.d.ts +13 -2
  225. package/dist/simple-tree/core/context.d.ts.map +1 -1
  226. package/dist/simple-tree/core/context.js +22 -9
  227. package/dist/simple-tree/core/context.js.map +1 -1
  228. package/dist/simple-tree/core/index.d.ts +6 -4
  229. package/dist/simple-tree/core/index.d.ts.map +1 -1
  230. package/dist/simple-tree/core/index.js +8 -1
  231. package/dist/simple-tree/core/index.js.map +1 -1
  232. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  233. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  234. package/dist/simple-tree/core/simpleNodeSchemaBase.js +7 -0
  235. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  236. package/dist/simple-tree/core/toStored.d.ts +32 -0
  237. package/dist/simple-tree/core/toStored.d.ts.map +1 -0
  238. package/dist/simple-tree/core/toStored.js +37 -0
  239. package/dist/simple-tree/core/toStored.js.map +1 -0
  240. package/dist/simple-tree/core/treeNodeKernel.d.ts +1 -1
  241. package/dist/simple-tree/core/treeNodeKernel.js +1 -1
  242. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  243. package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -2
  244. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  245. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  246. package/dist/simple-tree/core/treeNodeValid.d.ts +7 -2
  247. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  248. package/dist/simple-tree/core/treeNodeValid.js +19 -4
  249. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  250. package/dist/simple-tree/core/walkSchema.d.ts +22 -5
  251. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  252. package/dist/simple-tree/core/walkSchema.js +6 -2
  253. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  254. package/dist/simple-tree/createContext.d.ts +2 -0
  255. package/dist/simple-tree/createContext.d.ts.map +1 -1
  256. package/dist/simple-tree/createContext.js +4 -2
  257. package/dist/simple-tree/createContext.js.map +1 -1
  258. package/dist/simple-tree/fieldSchema.d.ts +1 -0
  259. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  260. package/dist/simple-tree/fieldSchema.js +2 -1
  261. package/dist/simple-tree/fieldSchema.js.map +1 -1
  262. package/dist/simple-tree/index.d.ts +7 -7
  263. package/dist/simple-tree/index.d.ts.map +1 -1
  264. package/dist/simple-tree/index.js +13 -8
  265. package/dist/simple-tree/index.js.map +1 -1
  266. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  267. package/dist/simple-tree/leafNodeSchema.js +1 -0
  268. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  269. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  270. package/dist/simple-tree/node-kinds/array/arrayNode.js +18 -4
  271. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  272. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  273. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  274. package/dist/simple-tree/node-kinds/index.js +1 -2
  275. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  276. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  277. package/dist/simple-tree/node-kinds/map/mapNode.js +9 -2
  278. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  279. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  280. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  281. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  282. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  283. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +3 -8
  284. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  285. package/dist/simple-tree/node-kinds/object/objectNode.js +41 -44
  286. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  287. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  288. package/dist/simple-tree/node-kinds/record/recordNode.js +9 -2
  289. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  290. package/dist/simple-tree/prepareForInsertion.d.ts +6 -6
  291. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  292. package/dist/simple-tree/prepareForInsertion.js +19 -13
  293. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  294. package/dist/simple-tree/simpleSchema.d.ts +6 -21
  295. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  296. package/dist/simple-tree/simpleSchema.js.map +1 -1
  297. package/dist/simple-tree/toStoredSchema.d.ts +38 -11
  298. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  299. package/dist/simple-tree/toStoredSchema.js +71 -33
  300. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  301. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  302. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  303. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  304. package/dist/simple-tree/walkFieldSchema.d.ts +1 -0
  305. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  306. package/dist/simple-tree/walkFieldSchema.js +1 -0
  307. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  308. package/lib/alpha.d.ts +2 -1
  309. package/lib/codec/codec.d.ts +2 -1
  310. package/lib/codec/codec.d.ts.map +1 -1
  311. package/lib/codec/codec.js +4 -3
  312. package/lib/codec/codec.js.map +1 -1
  313. package/lib/core/index.d.ts +1 -1
  314. package/lib/core/index.d.ts.map +1 -1
  315. package/lib/core/index.js +1 -1
  316. package/lib/core/index.js.map +1 -1
  317. package/lib/core/rebase/index.d.ts +1 -1
  318. package/lib/core/rebase/index.d.ts.map +1 -1
  319. package/lib/core/rebase/index.js +1 -1
  320. package/lib/core/rebase/index.js.map +1 -1
  321. package/lib/core/rebase/types.d.ts +3 -1
  322. package/lib/core/rebase/types.d.ts.map +1 -1
  323. package/lib/core/rebase/types.js +1 -0
  324. package/lib/core/rebase/types.js.map +1 -1
  325. package/lib/core/schema-stored/schema.d.ts +1 -23
  326. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  327. package/lib/core/schema-stored/schema.js +2 -2
  328. package/lib/core/schema-stored/schema.js.map +1 -1
  329. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  330. package/lib/core/tree/detachedFieldIndex.js +2 -3
  331. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  332. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  333. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  334. package/lib/core/tree/detachedFieldIndexCodecCommon.js +64 -0
  335. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  336. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  337. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  338. package/lib/core/tree/detachedFieldIndexCodecV1.js +51 -0
  339. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  340. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  341. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  342. package/lib/core/tree/detachedFieldIndexCodecV2.js +45 -0
  343. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  344. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  345. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  346. package/lib/core/tree/detachedFieldIndexCodecs.js +21 -0
  347. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  348. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  349. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  350. package/lib/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +13 -10
  351. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  352. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  353. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  354. package/lib/core/tree/detachedFieldIndexFormatV1.js +9 -0
  355. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  356. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  357. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  358. package/lib/core/tree/detachedFieldIndexFormatV2.js +11 -0
  359. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  360. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  361. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  362. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +19 -19
  363. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  364. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  365. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  366. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  367. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  368. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  369. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  370. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +70 -57
  371. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  372. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  373. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  374. package/lib/feature-libraries/chunked-forest/codec/format.js +17 -11
  375. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  376. package/{dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts → lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  377. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  378. package/lib/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +21 -15
  379. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  380. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  381. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  382. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +19 -19
  383. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  384. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  385. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  386. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  387. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  388. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +15 -2
  389. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  390. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  391. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -2
  392. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  393. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  394. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  395. package/lib/feature-libraries/default-schema/index.js +1 -1
  396. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  397. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  398. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  399. package/lib/feature-libraries/default-schema/schemaChecker.js +29 -24
  400. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  401. package/lib/feature-libraries/index.d.ts +1 -2
  402. package/lib/feature-libraries/index.d.ts.map +1 -1
  403. package/lib/feature-libraries/index.js +1 -2
  404. package/lib/feature-libraries/index.js.map +1 -1
  405. package/lib/feature-libraries/modular-schema/comparison.d.ts +5 -6
  406. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  407. package/lib/feature-libraries/modular-schema/comparison.js +14 -14
  408. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  409. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
  410. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  411. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
  412. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  413. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  414. package/lib/feature-libraries/modular-schema/genericFieldKind.js +1 -0
  415. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  416. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
  417. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  418. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +50 -21
  419. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  420. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  421. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  422. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  423. package/lib/feature-libraries/object-forest/objectForest.js +3 -4
  424. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  425. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  426. package/lib/feature-libraries/optional-field/optionalField.js +3 -0
  427. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  428. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
  429. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
  430. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
  431. package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
  432. package/lib/index.d.ts +1 -1
  433. package/lib/index.d.ts.map +1 -1
  434. package/lib/index.js +2 -2
  435. package/lib/index.js.map +1 -1
  436. package/lib/jsonDomainSchema.d.ts +5 -3
  437. package/lib/jsonDomainSchema.d.ts.map +1 -1
  438. package/lib/jsonDomainSchema.js.map +1 -1
  439. package/lib/packageVersion.d.ts +1 -1
  440. package/lib/packageVersion.d.ts.map +1 -1
  441. package/lib/packageVersion.js +1 -1
  442. package/lib/packageVersion.js.map +1 -1
  443. package/lib/shared-tree/independentView.d.ts +8 -0
  444. package/lib/shared-tree/independentView.d.ts.map +1 -1
  445. package/lib/shared-tree/independentView.js +21 -10
  446. package/lib/shared-tree/independentView.js.map +1 -1
  447. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  448. package/lib/shared-tree/schematizeTree.js +2 -2
  449. package/lib/shared-tree/schematizeTree.js.map +1 -1
  450. package/lib/shared-tree/schematizingTreeView.d.ts +0 -1
  451. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  452. package/lib/shared-tree/schematizingTreeView.js +10 -13
  453. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  454. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  455. package/lib/shared-tree/sharedTree.js +2 -30
  456. package/lib/shared-tree/sharedTree.js.map +1 -1
  457. package/lib/shared-tree/treeAlpha.d.ts +20 -6
  458. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  459. package/lib/shared-tree/treeAlpha.js +19 -8
  460. package/lib/shared-tree/treeAlpha.js.map +1 -1
  461. package/lib/shared-tree/treeCheckout.d.ts +2 -1
  462. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  463. package/lib/shared-tree/treeCheckout.js +33 -1
  464. package/lib/shared-tree/treeCheckout.js.map +1 -1
  465. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  466. package/lib/shared-tree-core/branch.js +1 -1
  467. package/lib/shared-tree-core/branch.js.map +1 -1
  468. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  469. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  470. package/lib/simple-tree/api/conciseTree.js +6 -6
  471. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  472. package/lib/simple-tree/api/configuration.d.ts +11 -2
  473. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  474. package/lib/simple-tree/api/configuration.js +6 -2
  475. package/lib/simple-tree/api/configuration.js.map +1 -1
  476. package/lib/simple-tree/api/create.d.ts +8 -7
  477. package/lib/simple-tree/api/create.d.ts.map +1 -1
  478. package/lib/simple-tree/api/create.js +35 -25
  479. package/lib/simple-tree/api/create.js.map +1 -1
  480. package/lib/simple-tree/api/customTree.d.ts +25 -4
  481. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  482. package/lib/simple-tree/api/customTree.js +43 -17
  483. package/lib/simple-tree/api/customTree.js.map +1 -1
  484. package/lib/simple-tree/api/discrepancies.d.ts +94 -0
  485. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -0
  486. package/lib/simple-tree/api/discrepancies.js +251 -0
  487. package/lib/simple-tree/api/discrepancies.js.map +1 -0
  488. package/lib/simple-tree/api/index.d.ts +3 -2
  489. package/lib/simple-tree/api/index.d.ts.map +1 -1
  490. package/lib/simple-tree/api/index.js +2 -1
  491. package/lib/simple-tree/api/index.js.map +1 -1
  492. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  493. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  494. package/lib/simple-tree/api/schemaCompatibilityTester.js +19 -119
  495. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  496. package/lib/simple-tree/api/schemaFactory.d.ts +16 -159
  497. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  498. package/lib/simple-tree/api/schemaFactory.js +2 -45
  499. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  500. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
  501. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  502. package/lib/simple-tree/api/schemaFactoryAlpha.js +23 -1
  503. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  504. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
  505. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  506. package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -5
  507. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  508. package/lib/simple-tree/api/schemaStatics.d.ts +158 -0
  509. package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -0
  510. package/lib/simple-tree/api/schemaStatics.js +56 -0
  511. package/lib/simple-tree/api/schemaStatics.js.map +1 -0
  512. package/lib/simple-tree/api/storedSchema.d.ts +5 -3
  513. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  514. package/lib/simple-tree/api/storedSchema.js +12 -6
  515. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  516. package/lib/simple-tree/api/treeBeta.d.ts +2 -2
  517. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  518. package/lib/simple-tree/api/treeBeta.js +14 -2
  519. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  520. package/lib/simple-tree/api/verboseTree.d.ts +2 -2
  521. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  522. package/lib/simple-tree/api/verboseTree.js +9 -9
  523. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  524. package/lib/simple-tree/core/allowedTypes.d.ts +43 -11
  525. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  526. package/lib/simple-tree/core/allowedTypes.js +52 -11
  527. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  528. package/lib/simple-tree/core/context.d.ts +13 -2
  529. package/lib/simple-tree/core/context.d.ts.map +1 -1
  530. package/lib/simple-tree/core/context.js +22 -9
  531. package/lib/simple-tree/core/context.js.map +1 -1
  532. package/lib/simple-tree/core/index.d.ts +6 -4
  533. package/lib/simple-tree/core/index.d.ts.map +1 -1
  534. package/lib/simple-tree/core/index.js +4 -3
  535. package/lib/simple-tree/core/index.js.map +1 -1
  536. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
  537. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
  538. package/lib/simple-tree/core/simpleNodeSchemaBase.js +6 -0
  539. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
  540. package/lib/simple-tree/core/toStored.d.ts +32 -0
  541. package/lib/simple-tree/core/toStored.d.ts.map +1 -0
  542. package/lib/simple-tree/core/toStored.js +32 -0
  543. package/lib/simple-tree/core/toStored.js.map +1 -0
  544. package/lib/simple-tree/core/treeNodeKernel.d.ts +1 -1
  545. package/lib/simple-tree/core/treeNodeKernel.js +1 -1
  546. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  547. package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -2
  548. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  549. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  550. package/lib/simple-tree/core/treeNodeValid.d.ts +7 -2
  551. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  552. package/lib/simple-tree/core/treeNodeValid.js +17 -3
  553. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  554. package/lib/simple-tree/core/walkSchema.d.ts +22 -5
  555. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  556. package/lib/simple-tree/core/walkSchema.js +6 -2
  557. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  558. package/lib/simple-tree/createContext.d.ts +2 -0
  559. package/lib/simple-tree/createContext.d.ts.map +1 -1
  560. package/lib/simple-tree/createContext.js +5 -3
  561. package/lib/simple-tree/createContext.js.map +1 -1
  562. package/lib/simple-tree/fieldSchema.d.ts +1 -0
  563. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  564. package/lib/simple-tree/fieldSchema.js +2 -1
  565. package/lib/simple-tree/fieldSchema.js.map +1 -1
  566. package/lib/simple-tree/index.d.ts +7 -7
  567. package/lib/simple-tree/index.d.ts.map +1 -1
  568. package/lib/simple-tree/index.js +5 -5
  569. package/lib/simple-tree/index.js.map +1 -1
  570. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  571. package/lib/simple-tree/leafNodeSchema.js +2 -1
  572. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  573. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  574. package/lib/simple-tree/node-kinds/array/arrayNode.js +21 -7
  575. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  576. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  577. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  578. package/lib/simple-tree/node-kinds/index.js +1 -1
  579. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  580. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  581. package/lib/simple-tree/node-kinds/map/mapNode.js +12 -5
  582. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  583. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  584. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  585. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  586. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  587. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +3 -8
  588. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  589. package/lib/simple-tree/node-kinds/object/objectNode.js +19 -21
  590. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  591. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  592. package/lib/simple-tree/node-kinds/record/recordNode.js +12 -5
  593. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  594. package/lib/simple-tree/prepareForInsertion.d.ts +6 -6
  595. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  596. package/lib/simple-tree/prepareForInsertion.js +21 -15
  597. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  598. package/lib/simple-tree/simpleSchema.d.ts +6 -21
  599. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  600. package/lib/simple-tree/simpleSchema.js.map +1 -1
  601. package/lib/simple-tree/toStoredSchema.d.ts +38 -11
  602. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  603. package/lib/simple-tree/toStoredSchema.js +70 -34
  604. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  605. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  606. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  607. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
  608. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  609. package/lib/simple-tree/walkFieldSchema.d.ts +1 -0
  610. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  611. package/lib/simple-tree/walkFieldSchema.js +1 -0
  612. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  613. package/package.json +23 -23
  614. package/src/codec/codec.ts +4 -3
  615. package/src/core/index.ts +2 -0
  616. package/src/core/rebase/index.ts +2 -0
  617. package/src/core/rebase/types.ts +4 -0
  618. package/src/core/schema-stored/schema.ts +2 -26
  619. package/src/core/tree/detachedFieldIndex.ts +4 -6
  620. package/src/core/tree/detachedFieldIndexCodecCommon.ts +87 -0
  621. package/src/core/tree/{detachedFieldIndexCodec.ts → detachedFieldIndexCodecV1.ts} +22 -68
  622. package/src/core/tree/detachedFieldIndexCodecV2.ts +72 -0
  623. package/src/core/tree/detachedFieldIndexCodecs.ts +44 -0
  624. package/src/core/tree/{detachedFieldIndexFormat.ts → detachedFieldIndexFormatCommon.ts} +32 -23
  625. package/src/core/tree/detachedFieldIndexFormatV1.ts +15 -0
  626. package/src/core/tree/detachedFieldIndexFormatV2.ts +17 -0
  627. package/src/feature-libraries/chunked-forest/codec/README.md +1 -1
  628. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +25 -25
  629. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -6
  630. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +96 -73
  631. package/src/feature-libraries/chunked-forest/codec/format.ts +20 -14
  632. package/src/feature-libraries/chunked-forest/codec/{nodeShape.ts → nodeEncoder.ts} +23 -17
  633. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +34 -34
  634. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +5 -5
  635. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +11 -0
  636. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -2
  637. package/src/feature-libraries/default-schema/index.ts +1 -1
  638. package/src/feature-libraries/default-schema/schemaChecker.ts +47 -30
  639. package/src/feature-libraries/index.ts +1 -3
  640. package/src/feature-libraries/modular-schema/comparison.ts +14 -29
  641. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +9 -0
  642. package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -0
  643. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +61 -19
  644. package/src/feature-libraries/object-forest/objectForest.ts +10 -6
  645. package/src/feature-libraries/optional-field/optionalField.ts +4 -0
  646. package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +4 -0
  647. package/src/index.ts +7 -1
  648. package/src/jsonDomainSchema.ts +4 -0
  649. package/src/packageVersion.ts +1 -1
  650. package/src/shared-tree/independentView.ts +45 -19
  651. package/src/shared-tree/schematizeTree.ts +2 -2
  652. package/src/shared-tree/schematizingTreeView.ts +24 -15
  653. package/src/shared-tree/sharedTree.ts +2 -42
  654. package/src/shared-tree/treeAlpha.ts +48 -22
  655. package/src/shared-tree/treeCheckout.ts +54 -10
  656. package/src/shared-tree-core/branch.ts +1 -6
  657. package/src/simple-tree/api/conciseTree.ts +9 -7
  658. package/src/simple-tree/api/configuration.ts +18 -4
  659. package/src/simple-tree/api/create.ts +44 -36
  660. package/src/simple-tree/api/customTree.ts +59 -20
  661. package/src/simple-tree/api/discrepancies.ts +474 -0
  662. package/src/simple-tree/api/index.ts +2 -3
  663. package/src/simple-tree/api/schemaCompatibilityTester.ts +23 -151
  664. package/src/simple-tree/api/schemaFactory.ts +13 -254
  665. package/src/simple-tree/api/schemaFactoryAlpha.ts +174 -1
  666. package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -25
  667. package/src/simple-tree/api/schemaStatics.ts +291 -0
  668. package/src/simple-tree/api/storedSchema.ts +18 -14
  669. package/src/simple-tree/api/treeBeta.ts +24 -4
  670. package/src/simple-tree/api/verboseTree.ts +17 -8
  671. package/src/simple-tree/core/allowedTypes.ts +87 -34
  672. package/src/simple-tree/core/context.ts +24 -22
  673. package/src/simple-tree/core/index.ts +11 -2
  674. package/src/simple-tree/core/simpleNodeSchemaBase.ts +30 -0
  675. package/src/simple-tree/core/toStored.ts +58 -0
  676. package/src/simple-tree/core/treeNodeKernel.ts +1 -1
  677. package/src/simple-tree/core/treeNodeSchema.ts +8 -2
  678. package/src/simple-tree/core/treeNodeValid.ts +23 -4
  679. package/src/simple-tree/core/walkSchema.ts +26 -6
  680. package/src/simple-tree/createContext.ts +11 -3
  681. package/src/simple-tree/fieldSchema.ts +3 -1
  682. package/src/simple-tree/index.ts +19 -13
  683. package/src/simple-tree/leafNodeSchema.ts +2 -1
  684. package/src/simple-tree/node-kinds/array/arrayNode.ts +64 -23
  685. package/src/simple-tree/node-kinds/index.ts +0 -1
  686. package/src/simple-tree/node-kinds/map/mapNode.ts +23 -2
  687. package/src/simple-tree/node-kinds/object/index.ts +0 -1
  688. package/src/simple-tree/node-kinds/object/objectNode.ts +42 -30
  689. package/src/simple-tree/node-kinds/record/recordNode.ts +20 -2
  690. package/src/simple-tree/prepareForInsertion.ts +28 -15
  691. package/src/simple-tree/simpleSchema.ts +6 -26
  692. package/src/simple-tree/toStoredSchema.ts +110 -44
  693. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +6 -2
  694. package/src/simple-tree/walkFieldSchema.ts +1 -0
  695. package/dist/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  696. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  697. package/dist/core/tree/detachedFieldIndexCodec.js +0 -100
  698. package/dist/core/tree/detachedFieldIndexCodec.js.map +0 -1
  699. package/dist/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  700. package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  701. package/dist/core/tree/detachedFieldIndexFormat.js.map +0 -1
  702. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  703. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  704. package/dist/feature-libraries/initializeForest.d.ts +0 -18
  705. package/dist/feature-libraries/initializeForest.d.ts.map +0 -1
  706. package/dist/feature-libraries/initializeForest.js +0 -35
  707. package/dist/feature-libraries/initializeForest.js.map +0 -1
  708. package/dist/simple-tree/discrepancies.d.ts +0 -167
  709. package/dist/simple-tree/discrepancies.d.ts.map +0 -1
  710. package/dist/simple-tree/discrepancies.js +0 -382
  711. package/dist/simple-tree/discrepancies.js.map +0 -1
  712. package/lib/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  713. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  714. package/lib/core/tree/detachedFieldIndexCodec.js +0 -96
  715. package/lib/core/tree/detachedFieldIndexCodec.js.map +0 -1
  716. package/lib/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  717. package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  718. package/lib/core/tree/detachedFieldIndexFormat.js.map +0 -1
  719. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  720. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  721. package/lib/feature-libraries/initializeForest.d.ts +0 -18
  722. package/lib/feature-libraries/initializeForest.d.ts.map +0 -1
  723. package/lib/feature-libraries/initializeForest.js +0 -31
  724. package/lib/feature-libraries/initializeForest.js.map +0 -1
  725. package/lib/simple-tree/discrepancies.d.ts +0 -167
  726. package/lib/simple-tree/discrepancies.d.ts.map +0 -1
  727. package/lib/simple-tree/discrepancies.js +0 -376
  728. package/lib/simple-tree/discrepancies.js.map +0 -1
  729. package/src/feature-libraries/initializeForest.ts +0 -55
  730. package/src/simple-tree/discrepancies.ts +0 -648
@@ -2,22 +2,56 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert, unreachableCase, fail } from "@fluidframework/core-utils/internal";
5
+ import { unreachableCase, fail } from "@fluidframework/core-utils/internal";
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
7
  import { EmptyKey, LeafNodeStoredSchema, MapNodeStoredSchema, ObjectNodeStoredSchema, } from "../core/index.js";
8
8
  import { FieldKinds } from "../feature-libraries/index.js";
9
9
  import { brand, getOrCreate } from "../util/index.js";
10
- import { NodeKind } from "./core/index.js";
11
- import { FieldKind, normalizeFieldSchema } from "./fieldSchema.js";
10
+ import { allowedTypeFilter, convertAllowedTypes, getTreeNodeSchemaPrivateData, isClassBasedSchema, NodeKind, } from "./core/index.js";
11
+ import { FieldKind, FieldSchemaAlpha, normalizeFieldSchema, } from "./fieldSchema.js";
12
12
  import { walkFieldSchema } from "./walkFieldSchema.js";
13
13
  const viewToStoredCache = new WeakMap();
14
+ export const restrictiveStoredSchemaGenerationOptions = {
15
+ includeStaged: () => false,
16
+ };
17
+ export const permissiveStoredSchemaGenerationOptions = {
18
+ includeStaged: () => true,
19
+ };
14
20
  /**
15
- * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.
21
+ * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.
22
+ *
23
+ * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.
24
+ */
25
+ export function toUpgradeSchema(root) {
26
+ return toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);
27
+ }
28
+ /**
29
+ * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.
30
+ */
31
+ export function toInitialSchema(root) {
32
+ return toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);
33
+ }
34
+ /**
35
+ * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.
36
+ * @remarks
37
+ * This allows as much as possible, relying on further validation when inserting the content.
38
+ *
39
+ * TODO: this should get additional options to enable support for unknown optional fields.
40
+ */
41
+ export const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;
42
+ /**
43
+ * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema}.
44
+ *
45
+ * @privateRemarks
46
+ * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if
47
+ * a staged allowed type has been upgraded and if so, include it in the conversion.
48
+ *
16
49
  * @throws
17
50
  * Throws a `UsageError` if multiple schemas are encountered with the same identifier.
18
51
  */
19
- export function toStoredSchema(root) {
20
- return getOrCreate(viewToStoredCache, root, () => {
52
+ export function toStoredSchema(root, options) {
53
+ const cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());
54
+ return getOrCreate(cache, root, () => {
21
55
  const normalized = normalizeFieldSchema(root);
22
56
  const nodeSchema = new Map();
23
57
  walkFieldSchema(normalized, {
@@ -26,36 +60,30 @@ export function toStoredSchema(root) {
26
60
  // Use JSON.stringify to quote and escape identifier string.
27
61
  throw new UsageError(`Multiple schema encountered with the identifier ${JSON.stringify(schema.identifier)}. Remove or rename them to avoid the collision.`);
28
62
  }
29
- nodeSchema.set(brand(schema.identifier), getStoredSchema(schema));
63
+ nodeSchema.set(brand(schema.identifier), getStoredSchema(schema, options));
30
64
  },
65
+ allowedTypeFilter: (allowedType) => allowedTypeFilter(allowedType, options),
31
66
  });
32
67
  const result = {
33
68
  nodeSchema,
34
- rootFieldSchema: convertField(normalized),
69
+ rootFieldSchema: convertField(normalized, options),
35
70
  };
36
71
  return result;
37
72
  });
38
73
  }
39
- /**
40
- * Converts a {@link SimpleTreeSchema} into a {@link TreeStoredSchema}.
41
- */
42
- export function simpleToStoredSchema(root) {
43
- const nodeSchema = new Map();
44
- for (const [identifier, schema] of root.definitions) {
45
- nodeSchema.set(brand(identifier), getStoredSchema(schema));
46
- }
47
- const result = {
48
- nodeSchema,
49
- rootFieldSchema: convertField(root.root),
50
- };
51
- return result;
52
- }
53
74
  /**
54
75
  * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.
55
76
  */
56
- export function convertField(schema) {
77
+ export function convertField(schema, options) {
57
78
  const kind = convertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);
58
- const types = schema.allowedTypesIdentifiers;
79
+ let types;
80
+ // eslint-disable-next-line unicorn/prefer-ternary
81
+ if (schema instanceof FieldSchemaAlpha) {
82
+ types = convertAllowedTypes(schema.annotatedAllowedTypesNormalized, options);
83
+ }
84
+ else {
85
+ types = schema.allowedTypesIdentifiers;
86
+ }
59
87
  return { kind, types, persistedMetadata: schema.persistedMetadata };
60
88
  }
61
89
  /**
@@ -70,12 +98,17 @@ export const convertFieldKind = new Map([
70
98
  * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.
71
99
  * @privateRemarks
72
100
  * TODO: Persist node metadata once schema FormatV2 is supported.
101
+ *
102
+ * TODO: AB#43548: Using a stored schema for unhydrated flex trees does not handle schema evolution features like "allowUnknownOptionalFields".
103
+ * Usage of this and the conversion which wrap it should be audited and reduced.
73
104
  */
74
- export function getStoredSchema(schema) {
105
+ export function getStoredSchema(schema, options) {
106
+ if (isClassBasedSchema(schema)) {
107
+ return getTreeNodeSchemaPrivateData(schema).toStored(options);
108
+ }
75
109
  const kind = schema.kind;
76
110
  switch (kind) {
77
111
  case NodeKind.Leaf: {
78
- assert(schema.kind === NodeKind.Leaf, 0xa4a /* invalid kind */);
79
112
  return new LeafNodeStoredSchema(schema.leafKind);
80
113
  }
81
114
  case NodeKind.Map:
@@ -91,18 +124,12 @@ export function getStoredSchema(schema) {
91
124
  }
92
125
  case NodeKind.Array: {
93
126
  const types = schema.allowedTypesIdentifiers;
94
- const field = {
95
- kind: FieldKinds.sequence.identifier,
96
- types,
97
- persistedMetadata: schema.persistedMetadata,
98
- };
99
- const fields = new Map([[EmptyKey, field]]);
100
- return new ObjectNodeStoredSchema(fields, schema.persistedMetadata);
127
+ return arrayNodeStoredSchema(types, schema.persistedMetadata);
101
128
  }
102
129
  case NodeKind.Object: {
103
130
  const fields = new Map();
104
131
  for (const fieldSchema of schema.fields.values()) {
105
- fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));
132
+ fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema, options));
106
133
  }
107
134
  return new ObjectNodeStoredSchema(fields, schema.persistedMetadata);
108
135
  }
@@ -111,4 +138,13 @@ export function getStoredSchema(schema) {
111
138
  }
112
139
  }
113
140
  }
141
+ export function arrayNodeStoredSchema(types, persistedMetadata) {
142
+ const field = {
143
+ kind: FieldKinds.sequence.identifier,
144
+ types,
145
+ persistedMetadata,
146
+ };
147
+ const fields = new Map([[EmptyKey, field]]);
148
+ return new ObjectNodeStoredSchema(fields, persistedMetadata);
149
+ }
114
150
  //# sourceMappingURL=toStoredSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GAQtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAsB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA4B,MAAM,kBAAkB,CAAC;AAO7F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAyC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAyB;IACvD,OAAO,WAAW,CAAC,iBAAiB,EAAE,IAAI,EAAE,GAAG,EAAE;QAChD,MAAM,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,UAAU,GAAwD,IAAI,GAAG,EAAE,CAAC;QAClF,eAAe,CAAC,UAAU,EAAE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K;gBACL,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;aAC3C,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC;QACD,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,MAAM,GAAyC,IAAI,GAAG,EAAE,CAAC;YAC/D,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;gBAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, getOrCreate } from \"../util/index.js\";\n\nimport { NodeKind } from \"./core/index.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport type {\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleNodeSchemaBase,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn getOrCreate(viewToStoredCache, root, () => {\n\t\tconst normalized = normalizeFieldSchema(root);\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(normalized, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(\n\t\t\t\t\tbrand(schema.identifier),\n\t\t\t\t\tgetStoredSchema(schema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema),\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Converts a {@link SimpleTreeSchema} into a {@link TreeStoredSchema}.\n */\nexport function simpleToStoredSchema(root: SimpleTreeSchema): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\tfor (const [identifier, schema] of root.definitions) {\n\t\tnodeSchema.set(brand(identifier), getStoredSchema(schema));\n\t}\n\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema,\n\t\trootFieldSchema: convertField(root.root),\n\t};\n\treturn result;\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(schema: SimpleFieldSchema): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types: TreeTypeSet = schema.allowedTypesIdentifiers as TreeTypeSet;\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(schema: SimpleNodeSchema): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(schema.kind === NodeKind.Leaf, 0xa4a /* invalid kind */);\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\tconst field = {\n\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\ttypes,\n\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t};\n\t\t\tconst fields = new Map([[EmptyKey, field]]);\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GAQtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAsB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqC,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,QAAQ,GAGR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GAGpB,MAAM,kBAAkB,CAAC;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CAAC;YACD,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,KAAkB,EAClB,iBAA2D;IAE3D,MAAM,KAAK,GAAG;QACb,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU;QACpC,KAAK;QACL,iBAAiB;KACjB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, getOrCreate, type JsonCompatibleReadOnlyObject } from \"../util/index.js\";\n\nimport {\n\tallowedTypeFilter,\n\tconvertAllowedTypes,\n\tgetTreeNodeSchemaPrivateData,\n\tisClassBasedSchema,\n\tNodeKind,\n\ttype SimpleNodeSchemaBase,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\ttype ImplicitFieldSchema,\n} from \"./fieldSchema.js\";\nimport type { SimpleFieldSchema, SimpleNodeSchema } from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<\n\tStoredSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\nexport const restrictiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => false,\n};\n\nexport const permissiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitAnnotatedFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitAnnotatedFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitAnnotatedFieldSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst normalized = normalizeFieldSchema(root);\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(normalized, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(\n\t\t\t\t\tbrand(schema.identifier),\n\t\t\t\t\tgetStoredSchema(\n\t\t\t\t\t\tschema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t\tallowedTypeFilter: (allowedType) => allowedTypeFilter(allowedType, options),\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized, options),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema | FieldSchemaAlpha,\n\toptions: StoredSchemaGenerationOptions,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tlet types: TreeTypeSet;\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (schema instanceof FieldSchemaAlpha) {\n\t\ttypes = convertAllowedTypes(schema.annotatedAllowedTypesNormalized, options);\n\t} else {\n\t\ttypes = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t}\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n *\n * TODO: AB#43548: Using a stored schema for unhydrated flex trees does not handle schema evolution features like \"allowUnknownOptionalFields\".\n * Usage of this and the conversion which wrap it should be audited and reduced.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeNodeStoredSchema {\n\tif (isClassBasedSchema(schema)) {\n\t\treturn getTreeNodeSchemaPrivateData(schema).toStored(options);\n\t}\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\treturn arrayNodeStoredSchema(types, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema, options));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nexport function arrayNodeStoredSchema(\n\ttypes: TreeTypeSet,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes,\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IFluidHandle } from "@fluidframework/core-interfaces";
6
- import { type ImplicitFieldSchema } from "./fieldSchema.js";
6
+ import { type ImplicitAnnotatedFieldSchema } from "./fieldSchema.js";
7
7
  import { type TreeNode, type TreeNodeSchema, type Unhydrated, UnhydratedFlexTreeNode } from "./core/index.js";
8
8
  /**
9
9
  * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.
@@ -31,7 +31,7 @@ import { type TreeNode, type TreeNodeSchema, type Unhydrated, UnhydratedFlexTree
31
31
  * Output should comply with the provided view schema, but this is not explicitly validated:
32
32
  * validation against stored schema (to guard against document corruption) is done elsewhere.
33
33
  */
34
- export declare function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(data: TIn, allowedTypes: ImplicitFieldSchema): TIn extends undefined ? undefined : UnhydratedFlexTreeNode;
34
+ export declare function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(data: TIn, allowedTypes: ImplicitAnnotatedFieldSchema): TIn extends undefined ? undefined : UnhydratedFlexTreeNode;
35
35
  /**
36
36
  * Copy content from `data` into a UnhydratedFlexTreeNode.
37
37
  */
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTreeFromInsertable.d.ts","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAMpE,OAAO,EAAE,KAAK,mBAAmB,EAAmC,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAKN,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,sBAAsB,EACtB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,SAAS,iBAAiB,GAAG,SAAS,EACzF,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,mBAAmB,GAC/B,GAAG,SAAS,SAAS,GAAG,SAAS,GAAG,sBAAsB,CAiB5D;AAED;;GAEG;AACH,wBAAgB,oCAAoC,CACnD,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,GACvC,sBAAsB,CAoBxB;AA2BD;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,EACzC,IAAI,EAAE,cAAc,GAClB,cAAc,EAAE,CAiBlB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GAEP,IAAI,GACJ,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC9C,SAAS,iBAAiB,EAAE,GAC5B,oBAAoB,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,iBAAiB;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC"}
1
+ {"version":3,"file":"unhydratedFlexTreeFromInsertable.d.ts","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAMpE,OAAO,EAGN,KAAK,4BAA4B,EACjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKN,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,sBAAsB,EACtB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,SAAS,iBAAiB,GAAG,SAAS,EACzF,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,4BAA4B,GACxC,GAAG,SAAS,SAAS,GAAG,SAAS,GAAG,sBAAsB,CAiB5D;AAED;;GAEG;AACH,wBAAgB,oCAAoC,CACnD,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,GACvC,sBAAsB,CAoBxB;AA2BD;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,EACzC,IAAI,EAAE,cAAc,GAClB,cAAc,EAAE,CAiBlB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GAEP,IAAI,GACJ,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC9C,SAAS,iBAAiB,EAAE,GAC5B,oBAAoB,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,iBAAiB;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC"}
@@ -5,7 +5,7 @@
5
5
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { hasSingle } from "../util/index.js";
8
- import { normalizeFieldSchema, FieldKind } from "./fieldSchema.js";
8
+ import { normalizeFieldSchema, FieldKind, } from "./fieldSchema.js";
9
9
  import { CompatibilityLevel, getKernel, getTreeNodeSchemaPrivateData, isTreeNode, UnhydratedFlexTreeNode, } from "./core/index.js";
10
10
  import { getUnhydratedContext } from "./createContext.js";
11
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTreeFromInsertable.js","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAA4B,oBAAoB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,4BAA4B,EAC5B,UAAU,EAIV,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,gCAAgC,CAC/C,IAAS,EACT,YAAiC;IAEjC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,+CAA+C;QAC/C,IAAI,qBAAqB,CAAC,IAAI,KAAK,SAAS,CAAC,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AK,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { hasSingle } from \"../util/index.js\";\n\nimport { type ImplicitFieldSchema, normalizeFieldSchema, FieldKind } from \"./fieldSchema.js\";\nimport {\n\tCompatibilityLevel,\n\tgetKernel,\n\tgetTreeNodeSchemaPrivateData,\n\tisTreeNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @remarks\n * The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * Often throws UsageErrors for invalid data, but may miss some cases.\n *\n * Output should comply with the provided view schema, but this is not explicitly validated:\n * validation against stored schema (to guard against document corruption) is done elsewhere.\n */\nexport function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitFieldSchema,\n): TIn extends undefined ? undefined : UnhydratedFlexTreeNode {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n\t}\n\n\tconst flexTree: UnhydratedFlexTreeNode = unhydratedFlexTreeFromInsertableNode(\n\t\tdata,\n\t\tnormalizedFieldSchema.allowedTypeSet,\n\t);\n\n\treturn flexTree as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n}\n\n/**\n * Copy content from `data` into a UnhydratedFlexTreeNode.\n */\nexport function unhydratedFlexTreeFromInsertableNode(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): UnhydratedFlexTreeNode {\n\tif (isTreeNode(data)) {\n\t\tconst kernel = getKernel(data);\n\t\tconst inner = kernel.getInnerNodeIfUnhydrated();\n\t\tif (inner === undefined) {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t} else {\n\t\t\tif (!allowedTypes.has(kernel.schema)) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\treturn inner;\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\tconst result = handler.toFlexContent(data, allowedTypes);\n\n\treturn new UnhydratedFlexTreeNode(...result, getUnhydratedContext(schema));\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tif (!hasSingle(possibleTypes)) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0];\n}\n\n/**\n * Returns all types for which the data is schema-compatible.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\n\tlet best = CompatibilityLevel.None;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of allowedTypes) {\n\t\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\t\tconst level = handler.shallowCompatibilityTest(data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn best === CompatibilityLevel.None ? [] : possibleTypes;\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n * @system @alpha\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
1
+ {"version":3,"file":"unhydratedFlexTreeFromInsertable.js","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EACN,oBAAoB,EACpB,SAAS,GAET,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,4BAA4B,EAC5B,UAAU,EAIV,sBAAsB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,gCAAgC,CAC/C,IAAS,EACT,YAA0C;IAE1C,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEjE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,+CAA+C;QAC/C,IAAI,qBAAqB,CAAC,IAAI,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;YACvD,MAAM,IAAI,UAAU,CAAC,uCAAuC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,SAAuE,CAAC;IAChF,CAAC;IAED,MAAM,QAAQ,GAA2B,oCAAoC,CAC5E,IAAI,EACJ,qBAAqB,CAAC,cAAc,CACpC,CAAC;IAEF,OAAO,QAAsE,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oCAAoC,CACnD,IAAuB,EACvB,YAAyC;IAEzC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM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AAC,MAAM,CAAC,UAAU,CAAC;SACnD,CAAC;;mHAE8G,CAChH,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC/B,YAAyC,EACzC,IAAoB;IAEpB,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAEpF,IAAI,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC;IACnC,MAAM,aAAa,GAAqB,EAAE,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,CAAC;QAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;YAClB,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;YACzB,IAAI,GAAG,KAAK,CAAC;QACd,CAAC;QACD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;IACD,OAAO,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport { hasSingle } from \"../util/index.js\";\n\nimport {\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype ImplicitAnnotatedFieldSchema,\n} from \"./fieldSchema.js\";\nimport {\n\tCompatibilityLevel,\n\tgetKernel,\n\tgetTreeNodeSchemaPrivateData,\n\tisTreeNode,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype Unhydrated,\n\tUnhydratedFlexTreeNode,\n} from \"./core/index.js\";\nimport { getUnhydratedContext } from \"./createContext.js\";\n\n/**\n * Transforms an input {@link TypedNode} tree to an {@link UnhydratedFlexTreeNode}.\n * @param data - The input tree to be converted.\n * If the data is an unsupported value (e.g. NaN), a fallback value will be used when supported,\n * otherwise an error will be thrown.\n *\n * Fallbacks:\n *\n * * `NaN` =\\> `null`\n *\n * * `+/-∞` =\\> `null`\n *\n * * `-0` =\\> `+0`\n *\n * For fields with a default value, the field may be omitted.\n * If `context` is not provided, defaults which require a context will be left empty which can be out of schema.\n *\n * @param allowedTypes - The set of types allowed by the parent context. Used to validate the input tree.\n * @remarks\n * The resulting tree will be populated with any defaults from {@link FieldProvider}s in the schema.\n *\n * Often throws UsageErrors for invalid data, but may miss some cases.\n *\n * Output should comply with the provided view schema, but this is not explicitly validated:\n * validation against stored schema (to guard against document corruption) is done elsewhere.\n */\nexport function unhydratedFlexTreeFromInsertable<TIn extends InsertableContent | undefined>(\n\tdata: TIn,\n\tallowedTypes: ImplicitAnnotatedFieldSchema,\n): TIn extends undefined ? undefined : UnhydratedFlexTreeNode {\n\tconst normalizedFieldSchema = normalizeFieldSchema(allowedTypes);\n\n\tif (data === undefined) {\n\t\t// TODO: this code-path should support defaults\n\t\tif (normalizedFieldSchema.kind !== FieldKind.Optional) {\n\t\t\tthrow new UsageError(\"Got undefined for non-optional field.\");\n\t\t}\n\t\treturn undefined as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n\t}\n\n\tconst flexTree: UnhydratedFlexTreeNode = unhydratedFlexTreeFromInsertableNode(\n\t\tdata,\n\t\tnormalizedFieldSchema.allowedTypeSet,\n\t);\n\n\treturn flexTree as TIn extends undefined ? undefined : UnhydratedFlexTreeNode;\n}\n\n/**\n * Copy content from `data` into a UnhydratedFlexTreeNode.\n */\nexport function unhydratedFlexTreeFromInsertableNode(\n\tdata: InsertableContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): UnhydratedFlexTreeNode {\n\tif (isTreeNode(data)) {\n\t\tconst kernel = getKernel(data);\n\t\tconst inner = kernel.getInnerNodeIfUnhydrated();\n\t\tif (inner === undefined) {\n\t\t\t// The node is already hydrated, meaning that it already got inserted into the tree previously\n\t\t\tthrow new UsageError(\"A node may not be inserted into the tree more than once\");\n\t\t} else {\n\t\t\tif (!allowedTypes.has(kernel.schema)) {\n\t\t\t\tthrow new UsageError(\"Invalid schema for this context.\");\n\t\t\t}\n\t\t\treturn inner;\n\t\t}\n\t}\n\n\tconst schema = getType(data, allowedTypes);\n\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\tconst result = handler.toFlexContent(data, allowedTypes);\n\n\treturn new UnhydratedFlexTreeNode(...result, getUnhydratedContext(schema));\n}\n\nfunction getType(\n\tdata: FactoryContent,\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n): TreeNodeSchema {\n\tconst possibleTypes = getPossibleTypes(allowedTypes, data);\n\tif (possibleTypes.length === 0) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is incompatible with all of the types allowed by the schema. The set of allowed types is: ${JSON.stringify(\n\t\t\t\t[...allowedTypes].map((schema) => schema.identifier),\n\t\t\t)}.`,\n\t\t);\n\t}\n\tif (!hasSingle(possibleTypes)) {\n\t\tthrow new UsageError(\n\t\t\t`The provided data is compatible with more than one type allowed by the schema.\nThe set of possible types is ${JSON.stringify([\n\t\t\t\t...possibleTypes.map((schema) => schema.identifier),\n\t\t\t])}.\nExplicitly construct an unhydrated node of the desired type to disambiguate.\nFor class-based schema, this can be done by replacing an expression like \"{foo: 1}\" with \"new MySchema({foo: 1})\".`,\n\t\t);\n\t}\n\treturn possibleTypes[0];\n}\n\n/**\n * Returns all types for which the data is schema-compatible.\n */\nexport function getPossibleTypes(\n\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\tdata: FactoryContent,\n): TreeNodeSchema[] {\n\tassert(data !== undefined, 0x889 /* undefined cannot be used as FactoryContent. */);\n\n\tlet best = CompatibilityLevel.None;\n\tconst possibleTypes: TreeNodeSchema[] = [];\n\tfor (const schema of allowedTypes) {\n\t\tconst handler = getTreeNodeSchemaPrivateData(schema).idempotentInitialize();\n\t\tconst level = handler.shallowCompatibilityTest(data);\n\t\tif (level > best) {\n\t\t\tpossibleTypes.length = 0;\n\t\t\tbest = level;\n\t\t}\n\t\tif (best === level) {\n\t\t\tpossibleTypes.push(schema);\n\t\t}\n\t}\n\treturn best === CompatibilityLevel.None ? [] : possibleTypes;\n}\n\n/**\n * Content which can be used to build a node.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n * @system @alpha\n */\nexport type FactoryContent =\n\t| IFluidHandle\n\t| string\n\t| number\n\t| boolean\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| Iterable<readonly [string, InsertableContent]>\n\t| readonly InsertableContent[]\n\t| FactoryContentObject;\n\n/**\n * Record-like object which can be used to build some kinds of nodes.\n * @remarks\n * Can contain unhydrated nodes, but can not be an unhydrated node at the root.\n *\n * Supports object and map nodes.\n * @system @alpha\n */\nexport type FactoryContentObject = {\n\treadonly [P in string]?: InsertableContent;\n};\n\n/**\n * Content which can be inserted into a tree.\n * @system @alpha\n */\nexport type InsertableContent = Unhydrated<TreeNode> | FactoryContent;\n"]}
@@ -6,6 +6,7 @@ import { type TreeNodeSchema, type SchemaVisitor } from "./core/index.js";
6
6
  import { type ImplicitFieldSchema } from "./fieldSchema.js";
7
7
  /**
8
8
  * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.
9
+ * @internal
9
10
  */
10
11
  export declare function walkFieldSchema(schema: ImplicitFieldSchema, visitor: SchemaVisitor, visitedSet?: Set<TreeNodeSchema>): void;
11
12
  //# sourceMappingURL=walkFieldSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"walkFieldSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/walkFieldSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAoB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,KAAK,mBAAmB,EAAwB,MAAM,kBAAkB,CAAC;AAElF;;GAEG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,aAAa,EACtB,UAAU,GAAE,GAAG,CAAC,cAAc,CAAa,GACzC,IAAI,CAMN"}
1
+ {"version":3,"file":"walkFieldSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/walkFieldSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAoB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,KAAK,mBAAmB,EAAwB,MAAM,kBAAkB,CAAC;AAElF;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,aAAa,EACtB,UAAU,GAAE,GAAG,CAAC,cAAc,CAAa,GACzC,IAAI,CAMN"}
@@ -6,6 +6,7 @@ import { walkAllowedTypes } from "./core/index.js";
6
6
  import { normalizeFieldSchema } from "./fieldSchema.js";
7
7
  /**
8
8
  * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.
9
+ * @internal
9
10
  */
10
11
  export function walkFieldSchema(schema, visitor, visitedSet = new Set()) {
11
12
  walkAllowedTypes(normalizeFieldSchema(schema).annotatedAllowedTypesNormalized, visitor, visitedSet);
@@ -1 +1 @@
1
- {"version":3,"file":"walkFieldSchema.js","sourceRoot":"","sources":["../../src/simple-tree/walkFieldSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAA4B,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAElF;;GAEG;AACH,MAAM,UAAU,eAAe,CAC9B,MAA2B,EAC3B,OAAsB,EACtB,aAAkC,IAAI,GAAG,EAAE;IAE3C,gBAAgB,CACf,oBAAoB,CAAC,MAAM,CAAC,CAAC,+BAA+B,EAC5D,OAAO,EACP,UAAU,CACV,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type TreeNodeSchema, walkAllowedTypes, type SchemaVisitor } from \"./core/index.js\";\nimport { type ImplicitFieldSchema, normalizeFieldSchema } from \"./fieldSchema.js\";\n\n/**\n * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.\n */\nexport function walkFieldSchema(\n\tschema: ImplicitFieldSchema,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema> = new Set(),\n): void {\n\twalkAllowedTypes(\n\t\tnormalizeFieldSchema(schema).annotatedAllowedTypesNormalized,\n\t\tvisitor,\n\t\tvisitedSet,\n\t);\n}\n"]}
1
+ {"version":3,"file":"walkFieldSchema.js","sourceRoot":"","sources":["../../src/simple-tree/walkFieldSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAA4B,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAElF;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC9B,MAA2B,EAC3B,OAAsB,EACtB,aAAkC,IAAI,GAAG,EAAE;IAE3C,gBAAgB,CACf,oBAAoB,CAAC,MAAM,CAAC,CAAC,+BAA+B,EAC5D,OAAO,EACP,UAAU,CACV,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type TreeNodeSchema, walkAllowedTypes, type SchemaVisitor } from \"./core/index.js\";\nimport { type ImplicitFieldSchema, normalizeFieldSchema } from \"./fieldSchema.js\";\n\n/**\n * Traverses all {@link TreeNodeSchema} schema reachable from `schema`, applying the visitor pattern.\n * @internal\n */\nexport function walkFieldSchema(\n\tschema: ImplicitFieldSchema,\n\tvisitor: SchemaVisitor,\n\tvisitedSet: Set<TreeNodeSchema> = new Set(),\n): void {\n\twalkAllowedTypes(\n\t\tnormalizeFieldSchema(schema).annotatedAllowedTypesNormalized,\n\t\tvisitor,\n\t\tvisitedSet,\n\t);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree",
3
- "version": "2.51.0",
3
+ "version": "2.53.0-350190",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -101,17 +101,17 @@
101
101
  "temp-directory": "nyc/.nyc_output"
102
102
  },
103
103
  "dependencies": {
104
- "@fluid-internal/client-utils": "~2.51.0",
105
- "@fluidframework/container-runtime": "~2.51.0",
106
- "@fluidframework/core-interfaces": "~2.51.0",
107
- "@fluidframework/core-utils": "~2.51.0",
108
- "@fluidframework/datastore-definitions": "~2.51.0",
109
- "@fluidframework/driver-definitions": "~2.51.0",
110
- "@fluidframework/id-compressor": "~2.51.0",
111
- "@fluidframework/runtime-definitions": "~2.51.0",
112
- "@fluidframework/runtime-utils": "~2.51.0",
113
- "@fluidframework/shared-object-base": "~2.51.0",
114
- "@fluidframework/telemetry-utils": "~2.51.0",
104
+ "@fluid-internal/client-utils": "2.53.0-350190",
105
+ "@fluidframework/container-runtime": "2.53.0-350190",
106
+ "@fluidframework/core-interfaces": "2.53.0-350190",
107
+ "@fluidframework/core-utils": "2.53.0-350190",
108
+ "@fluidframework/datastore-definitions": "2.53.0-350190",
109
+ "@fluidframework/driver-definitions": "2.53.0-350190",
110
+ "@fluidframework/id-compressor": "2.53.0-350190",
111
+ "@fluidframework/runtime-definitions": "2.53.0-350190",
112
+ "@fluidframework/runtime-utils": "2.53.0-350190",
113
+ "@fluidframework/shared-object-base": "2.53.0-350190",
114
+ "@fluidframework/telemetry-utils": "2.53.0-350190",
115
115
  "@sinclair/typebox": "^0.34.13",
116
116
  "@tylerbu/sorted-btree-es6": "^1.8.0",
117
117
  "@types/ungap__structured-clone": "^1.2.0",
@@ -121,20 +121,20 @@
121
121
  "devDependencies": {
122
122
  "@arethetypeswrong/cli": "^0.17.1",
123
123
  "@biomejs/biome": "~1.9.3",
124
- "@fluid-internal/mocha-test-setup": "~2.51.0",
125
- "@fluid-private/stochastic-test-utils": "~2.51.0",
126
- "@fluid-private/test-dds-utils": "~2.51.0",
127
- "@fluid-private/test-drivers": "~2.51.0",
124
+ "@fluid-internal/mocha-test-setup": "2.53.0-350190",
125
+ "@fluid-private/stochastic-test-utils": "2.53.0-350190",
126
+ "@fluid-private/test-dds-utils": "2.53.0-350190",
127
+ "@fluid-private/test-drivers": "2.53.0-350190",
128
128
  "@fluid-tools/benchmark": "^0.51.0",
129
- "@fluid-tools/build-cli": "^0.56.0",
129
+ "@fluid-tools/build-cli": "^0.57.0",
130
130
  "@fluidframework/build-common": "^2.0.3",
131
- "@fluidframework/build-tools": "^0.56.0",
132
- "@fluidframework/container-definitions": "~2.51.0",
133
- "@fluidframework/container-loader": "~2.51.0",
131
+ "@fluidframework/build-tools": "^0.57.0",
132
+ "@fluidframework/container-definitions": "2.53.0-350190",
133
+ "@fluidframework/container-loader": "2.53.0-350190",
134
134
  "@fluidframework/eslint-config-fluid": "^5.7.4",
135
- "@fluidframework/test-runtime-utils": "~2.51.0",
136
- "@fluidframework/test-utils": "~2.51.0",
137
- "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.50.0",
135
+ "@fluidframework/test-runtime-utils": "2.53.0-350190",
136
+ "@fluidframework/test-utils": "2.53.0-350190",
137
+ "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.52.0",
138
138
  "@microsoft/api-extractor": "7.52.8",
139
139
  "@types/diff": "^3.5.1",
140
140
  "@types/easy-table": "^0.0.32",
@@ -409,9 +409,10 @@ export enum FluidClientVersion {
409
409
  // then update it to "2.001" once we actually have the opt in working.
410
410
  // v2_1 = v2_0,
411
411
 
412
- /** Fluid Framework Client 2.41 and newer. */
413
- // If we land some new formats in 2.41, we can enable selecting
414
- // v2_41 = 2.041,
412
+ /** Fluid Framework Client 2.52 and newer. */
413
+ // New formats introduced in 2.52:
414
+ // - DetachedFieldIndex FormatV2
415
+ v2_52 = 2.052,
415
416
 
416
417
  /**
417
418
  * Enable unreleased and unfinished features.
package/src/core/index.ts CHANGED
@@ -192,10 +192,12 @@ export {
192
192
  revisionMetadataSourceFromInfo,
193
193
  type RevisionInfo,
194
194
  type EncodedRevisionTag,
195
+ type EncodedStableId,
195
196
  type EncodedChangeAtomId,
196
197
  taggedAtomId,
197
198
  taggedOptAtomId,
198
199
  offsetChangeAtomId,
200
+ StableIdSchema,
199
201
  subtractChangeAtomIds,
200
202
  replaceAtomRevisions,
201
203
  replaceChange,
@@ -16,6 +16,7 @@ export {
16
16
  RevisionTagSchema,
17
17
  type EncodedRevisionTag,
18
18
  type EncodedChangeAtomId,
19
+ type EncodedStableId,
19
20
  type ChangesetLocalId,
20
21
  type ChangeAtomId,
21
22
  type ChangeAtomIdMap,
@@ -23,6 +24,7 @@ export {
23
24
  taggedAtomId,
24
25
  taggedOptAtomId,
25
26
  offsetChangeAtomId,
27
+ StableIdSchema,
26
28
  subtractChangeAtomIds,
27
29
  replaceAtomRevisions,
28
30
  type ChangeAtomIdRangeMap,
@@ -7,6 +7,7 @@ import type {
7
7
  OpSpaceCompressedId,
8
8
  SessionId,
9
9
  SessionSpaceCompressedId,
10
+ StableId,
10
11
  } from "@fluidframework/id-compressor";
11
12
  import { Type } from "@sinclair/typebox";
12
13
 
@@ -38,6 +39,9 @@ export const RevisionTagSchema = Type.Union([
38
39
  brandedNumberType<Exclude<EncodedRevisionTag, string>>(),
39
40
  ]);
40
41
 
42
+ export type EncodedStableId = Brand<StableId, "EncodedStableId">;
43
+ export const StableIdSchema = Type.String();
44
+
41
45
  /**
42
46
  * An ID which is unique within a revision of a `ModularChangeset`.
43
47
  * A `ModularChangeset` which is a composition of multiple revisions may contain duplicate `ChangesetLocalId`s,
@@ -110,9 +110,6 @@ export interface SchemaAndPolicy {
110
110
  * This contains information that describes the semantics of things which can be referenced in stored schema.
111
111
  * For example, field kind identifiers refer to specific field kinds, which imply specific rules around what is valid in a given field (the multiplicity).
112
112
  * This structure provides such information, allowing it to be possible to determine if a given tree complies with a particular stored schema.
113
- *
114
- * TODO: AB#43546
115
- * Some additional data which is not needed to define compatibility with a given stored schema is currently included here, and should be removed.
116
113
  */
117
114
  export interface SchemaPolicy {
118
115
  /**
@@ -123,27 +120,6 @@ export interface SchemaPolicy {
123
120
  * and will be unable to process any changes that use those FieldKinds.
124
121
  */
125
122
  readonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;
126
-
127
- /**
128
- * If true, new content inserted into the tree should be validated against the stored schema.
129
- * @remarks
130
- * TODO: AB#43546: This is not information used to interpret the stored schema: this configuration should be moved elsewhere.
131
- */
132
- readonly validateSchema: boolean;
133
-
134
- /**
135
- * Whether to allow a document to be opened when a particular stored schema (identified by `identifier`)
136
- * contains optional fields that are not known to the view schema.
137
- *
138
- * @privateRemarks
139
- * Plumbing this in via `SchemaPolicy` avoids needing to walk the view schema representation repeatedly in places
140
- * that need it (schema validation, view vs stored compatibility checks).
141
- *
142
- * TODO: AB#43546
143
- * This is not information used to interpret the stored schema: it is instead about view schema, and how compatible they are with a stored schema.
144
- * SchemaCompatibilityTester should be updated to not store this table in here, and then this field should be removed.
145
- */
146
- allowUnknownOptionalFields(identifier: TreeNodeSchemaIdentifier): boolean;
147
123
  }
148
124
 
149
125
  /**
@@ -179,7 +155,7 @@ export interface TreeFieldStoredSchema {
179
155
  *
180
156
  * 2. The schema used for out of schema fields (which thus must be empty/not exist) on object and leaf nodes.
181
157
  */
182
- export const forbiddenFieldKindIdentifier = "Forbidden";
158
+ export const forbiddenFieldKindIdentifier: FieldKindIdentifier = brand("Forbidden");
183
159
 
184
160
  /**
185
161
  * A schema for empty fields (fields which must always be empty).
@@ -187,7 +163,7 @@ export const forbiddenFieldKindIdentifier = "Forbidden";
187
163
  */
188
164
  export const storedEmptyFieldSchema: TreeFieldStoredSchema = {
189
165
  // This kind requires the field to be empty.
190
- kind: brand(forbiddenFieldKindIdentifier),
166
+ kind: forbiddenFieldKindIdentifier,
191
167
  // This type set also forces the field to be empty not not allowing any types as all.
192
168
  types: new Set(),
193
169
  persistedMetadata: undefined,
@@ -28,8 +28,6 @@ import type { RevisionTag, RevisionTagCodec } from "../rebase/index.js";
28
28
  import type { FieldKey } from "../schema-stored/index.js";
29
29
 
30
30
  import type * as Delta from "./delta.js";
31
- import { makeDetachedNodeToFieldCodec } from "./detachedFieldIndexCodec.js";
32
- import type { Format } from "./detachedFieldIndexFormat.js";
33
31
  import type {
34
32
  DetachedField,
35
33
  DetachedFieldSummaryData,
@@ -37,6 +35,7 @@ import type {
37
35
  Major,
38
36
  Minor,
39
37
  } from "./detachedFieldIndexTypes.js";
38
+ import { makeDetachedFieldIndexCodec } from "./detachedFieldIndexCodecs.js";
40
39
 
41
40
  /**
42
41
  * The tree index records detached field IDs and associates them with a change atom ID.
@@ -59,7 +58,7 @@ export class DetachedFieldIndex {
59
58
  Delta.DetachedNodeId
60
59
  > = new Map();
61
60
 
62
- private readonly codec: IJsonCodec<DetachedFieldSummaryData, Format>;
61
+ private readonly codec: IJsonCodec<DetachedFieldSummaryData>;
63
62
  private readonly options: CodecWriteOptions;
64
63
 
65
64
  /**
@@ -87,8 +86,7 @@ export class DetachedFieldIndex {
87
86
  jsonValidator: noopValidator,
88
87
  oldestCompatibleClient: FluidClientVersion.v2_0,
89
88
  };
90
- // TODO: this should take in CodecWriteOptions, and use it to pick the write version.
91
- this.codec = makeDetachedNodeToFieldCodec(revisionTagCodec, this.options, idCompressor);
89
+ this.codec = makeDetachedFieldIndexCodec(revisionTagCodec, this.options, idCompressor);
92
90
  }
93
91
 
94
92
  public clone(): DetachedFieldIndex {
@@ -337,7 +335,7 @@ export class DetachedFieldIndex {
337
335
  * Loads the tree index from the given string, this overrides any existing data.
338
336
  */
339
337
  public loadData(data: JsonCompatibleReadOnly): void {
340
- const detachedFieldIndex: DetachedFieldSummaryData = this.codec.decode(data as Format);
338
+ const detachedFieldIndex: DetachedFieldSummaryData = this.codec.decode(data);
341
339
 
342
340
  this.rootIdAllocator = idAllocatorFromMaxId(
343
341
  detachedFieldIndex.maxId,