@fluidframework/tree 2.72.0 → 2.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (609) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/api-report/tree.alpha.api.md +17 -30
  3. package/dist/alpha.d.ts +3 -1
  4. package/dist/api.d.ts +6 -2
  5. package/dist/api.d.ts.map +1 -1
  6. package/dist/api.js +2 -11
  7. package/dist/api.js.map +1 -1
  8. package/dist/codec/codec.d.ts +9 -2
  9. package/dist/codec/codec.d.ts.map +1 -1
  10. package/dist/codec/codec.js +9 -2
  11. package/dist/codec/codec.js.map +1 -1
  12. package/dist/codec/index.d.ts +1 -1
  13. package/dist/codec/index.d.ts.map +1 -1
  14. package/dist/codec/index.js +2 -1
  15. package/dist/codec/index.js.map +1 -1
  16. package/dist/codec/versioned/codec.d.ts +7 -2
  17. package/dist/codec/versioned/codec.d.ts.map +1 -1
  18. package/dist/codec/versioned/codec.js +24 -1
  19. package/dist/codec/versioned/codec.js.map +1 -1
  20. package/dist/codec/versioned/index.d.ts +1 -1
  21. package/dist/codec/versioned/index.d.ts.map +1 -1
  22. package/dist/codec/versioned/index.js +2 -1
  23. package/dist/codec/versioned/index.js.map +1 -1
  24. package/dist/core/schema-stored/schema.d.ts +12 -1
  25. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  26. package/dist/core/schema-stored/schema.js.map +1 -1
  27. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecs.js +5 -3
  29. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  30. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +4 -5
  31. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  32. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +1 -0
  35. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +2 -1
  37. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/codecs.js +31 -17
  42. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +6 -6
  44. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -2
  46. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +156 -4
  48. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/format.js +7 -3
  50. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  51. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +8 -3
  52. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  53. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js +4 -1
  54. package/dist/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  55. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  56. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
  58. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +13 -13
  60. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +23 -6
  62. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +9 -8
  64. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +20 -4
  66. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  68. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/index.js +2 -1
  70. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  71. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +35 -17
  72. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  73. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +53 -55
  74. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  75. package/dist/feature-libraries/default-schema/index.d.ts +1 -3
  76. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  77. package/dist/feature-libraries/default-schema/index.js +2 -8
  78. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  79. package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
  80. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  81. package/dist/feature-libraries/forest-summary/format.js +4 -2
  82. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  83. package/dist/feature-libraries/index.d.ts +4 -3
  84. package/dist/feature-libraries/index.d.ts.map +1 -1
  85. package/dist/feature-libraries/index.js +8 -7
  86. package/dist/feature-libraries/index.js.map +1 -1
  87. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  88. package/dist/feature-libraries/modular-schema/comparison.js +1 -2
  89. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  90. package/dist/feature-libraries/modular-schema/fieldKind.d.ts +38 -12
  91. package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  92. package/dist/feature-libraries/modular-schema/fieldKind.js +29 -11
  93. package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  94. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.d.ts +2 -2
  95. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
  96. package/dist/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
  97. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -2
  98. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  99. package/dist/feature-libraries/modular-schema/genericFieldKind.js +3 -2
  100. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  101. package/dist/feature-libraries/modular-schema/index.d.ts +0 -1
  102. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  103. package/dist/feature-libraries/modular-schema/index.js +1 -3
  104. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  105. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts +5 -6
  106. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  107. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  108. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -8
  109. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  110. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1 -2
  111. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  112. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +66 -9
  113. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  114. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  115. package/dist/feature-libraries/object-forest/objectForest.js +3 -2
  116. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  117. package/dist/feature-libraries/optional-field/index.d.ts +1 -1
  118. package/dist/feature-libraries/optional-field/index.d.ts.map +1 -1
  119. package/dist/feature-libraries/optional-field/index.js.map +1 -1
  120. package/dist/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  121. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
  122. package/dist/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  123. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  124. package/dist/feature-libraries/schema-index/codec.js +5 -3
  125. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  126. package/dist/feature-libraries/{default-schema/schemaChecker.d.ts → schemaChecker.d.ts} +2 -2
  127. package/dist/feature-libraries/schemaChecker.d.ts.map +1 -0
  128. package/dist/feature-libraries/{default-schema/schemaChecker.js → schemaChecker.js} +3 -3
  129. package/dist/feature-libraries/schemaChecker.js.map +1 -0
  130. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  131. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js +0 -2
  132. package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  133. package/dist/index.d.ts +2 -2
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +5 -3
  136. package/dist/index.js.map +1 -1
  137. package/dist/packageVersion.d.ts +1 -1
  138. package/dist/packageVersion.js +1 -1
  139. package/dist/packageVersion.js.map +1 -1
  140. package/dist/shared-tree/index.d.ts +1 -1
  141. package/dist/shared-tree/index.d.ts.map +1 -1
  142. package/dist/shared-tree/index.js +1 -2
  143. package/dist/shared-tree/index.js.map +1 -1
  144. package/dist/shared-tree/sharedTree.d.ts +0 -44
  145. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  146. package/dist/shared-tree/sharedTree.js +1 -52
  147. package/dist/shared-tree/sharedTree.js.map +1 -1
  148. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  149. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  150. package/dist/shared-tree/sharedTreeChangeCodecs.js +0 -2
  151. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  152. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  153. package/dist/shared-tree-core/editManagerCodecs.js +12 -6
  154. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  155. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +3 -4
  156. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  157. package/dist/shared-tree-core/editManagerFormatCommons.js +5 -8
  158. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  159. package/dist/shared-tree-core/index.d.ts +2 -2
  160. package/dist/shared-tree-core/index.d.ts.map +1 -1
  161. package/dist/shared-tree-core/index.js +3 -2
  162. package/dist/shared-tree-core/index.js.map +1 -1
  163. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  164. package/dist/shared-tree-core/messageCodecs.js +20 -9
  165. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  166. package/dist/shared-tree-core/messageFormat.d.ts +4 -6
  167. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
  168. package/dist/shared-tree-core/messageFormat.js +9 -7
  169. package/dist/shared-tree-core/messageFormat.js.map +1 -1
  170. package/dist/simple-tree/api/configuration.d.ts +2 -0
  171. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  172. package/dist/simple-tree/api/configuration.js +10 -0
  173. package/dist/simple-tree/api/configuration.js.map +1 -1
  174. package/dist/simple-tree/api/index.d.ts +1 -0
  175. package/dist/simple-tree/api/index.d.ts.map +1 -1
  176. package/dist/simple-tree/api/index.js +5 -1
  177. package/dist/simple-tree/api/index.js.map +1 -1
  178. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  179. package/dist/simple-tree/api/schemaFromSimple.js +7 -1
  180. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  181. package/dist/simple-tree/api/simpleSchemaCodec.js +4 -6
  182. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  183. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +103 -0
  184. package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -0
  185. package/dist/simple-tree/api/snapshotCompatibilityChecker.js +128 -0
  186. package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -0
  187. package/dist/simple-tree/api/tree.d.ts +1 -1
  188. package/dist/simple-tree/api/tree.js +1 -1
  189. package/dist/simple-tree/api/tree.js.map +1 -1
  190. package/dist/simple-tree/core/allowedTypes.js +1 -1
  191. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  192. package/dist/simple-tree/core/index.d.ts +3 -3
  193. package/dist/simple-tree/core/index.d.ts.map +1 -1
  194. package/dist/simple-tree/core/index.js +3 -1
  195. package/dist/simple-tree/core/index.js.map +1 -1
  196. package/dist/simple-tree/core/toStored.d.ts +12 -5
  197. package/dist/simple-tree/core/toStored.d.ts.map +1 -1
  198. package/dist/simple-tree/core/toStored.js +26 -10
  199. package/dist/simple-tree/core/toStored.js.map +1 -1
  200. package/dist/simple-tree/core/treeNodeSchema.d.ts +1 -6
  201. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  202. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  203. package/dist/simple-tree/core/treeNodeValid.d.ts +1 -1
  204. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  205. package/dist/simple-tree/core/treeNodeValid.js +1 -2
  206. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  207. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  208. package/dist/simple-tree/fieldSchema.js +1 -8
  209. package/dist/simple-tree/fieldSchema.js.map +1 -1
  210. package/dist/simple-tree/index.d.ts +2 -2
  211. package/dist/simple-tree/index.d.ts.map +1 -1
  212. package/dist/simple-tree/index.js +9 -3
  213. package/dist/simple-tree/index.js.map +1 -1
  214. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  215. package/dist/simple-tree/leafNodeSchema.js +0 -1
  216. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  217. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  218. package/dist/simple-tree/node-kinds/array/arrayNode.js +13 -49
  219. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  220. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  221. package/dist/simple-tree/node-kinds/map/mapNode.js +1 -5
  222. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  223. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  224. package/dist/simple-tree/node-kinds/object/objectNode.js +2 -10
  225. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  226. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  227. package/dist/simple-tree/node-kinds/record/recordNode.js +1 -5
  228. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  229. package/dist/simple-tree/simpleSchema.d.ts +15 -3
  230. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  231. package/dist/simple-tree/simpleSchema.js.map +1 -1
  232. package/dist/simple-tree/toStoredSchema.d.ts +20 -8
  233. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  234. package/dist/simple-tree/toStoredSchema.js +27 -22
  235. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  236. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  237. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +18 -15
  238. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  239. package/dist/tableSchema.d.ts +22 -52
  240. package/dist/tableSchema.d.ts.map +1 -1
  241. package/dist/tableSchema.js +141 -277
  242. package/dist/tableSchema.js.map +1 -1
  243. package/dist/util/arrayUtilities.d.ts +45 -0
  244. package/dist/util/arrayUtilities.d.ts.map +1 -0
  245. package/dist/util/arrayUtilities.js +76 -0
  246. package/dist/util/arrayUtilities.js.map +1 -0
  247. package/dist/util/index.d.ts +1 -0
  248. package/dist/util/index.d.ts.map +1 -1
  249. package/dist/util/index.js +7 -2
  250. package/dist/util/index.js.map +1 -1
  251. package/lib/alpha.d.ts +3 -1
  252. package/lib/api.d.ts +6 -2
  253. package/lib/api.d.ts.map +1 -1
  254. package/lib/api.js +2 -13
  255. package/lib/api.js.map +1 -1
  256. package/lib/codec/codec.d.ts +9 -2
  257. package/lib/codec/codec.d.ts.map +1 -1
  258. package/lib/codec/codec.js +9 -2
  259. package/lib/codec/codec.js.map +1 -1
  260. package/lib/codec/index.d.ts +1 -1
  261. package/lib/codec/index.d.ts.map +1 -1
  262. package/lib/codec/index.js +1 -1
  263. package/lib/codec/index.js.map +1 -1
  264. package/lib/codec/versioned/codec.d.ts +7 -2
  265. package/lib/codec/versioned/codec.d.ts.map +1 -1
  266. package/lib/codec/versioned/codec.js +22 -0
  267. package/lib/codec/versioned/codec.js.map +1 -1
  268. package/lib/codec/versioned/index.d.ts +1 -1
  269. package/lib/codec/versioned/index.d.ts.map +1 -1
  270. package/lib/codec/versioned/index.js +1 -1
  271. package/lib/codec/versioned/index.js.map +1 -1
  272. package/lib/core/schema-stored/schema.d.ts +12 -1
  273. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  274. package/lib/core/schema-stored/schema.js.map +1 -1
  275. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  276. package/lib/core/tree/detachedFieldIndexCodecs.js +5 -3
  277. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  278. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +4 -5
  279. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  280. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  281. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  282. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +2 -1
  283. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  284. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts +2 -1
  285. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.d.ts.map +1 -1
  286. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  287. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +1 -1
  288. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  289. package/lib/feature-libraries/chunked-forest/codec/codecs.js +34 -20
  290. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  291. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +6 -6
  292. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  293. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -2
  294. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  295. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +156 -4
  296. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  297. package/lib/feature-libraries/chunked-forest/codec/format.js +6 -2
  298. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts +8 -3
  300. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.d.ts.map +1 -1
  301. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js +4 -1
  302. package/lib/feature-libraries/chunked-forest/codec/formatGeneric.js.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  304. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  305. package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
  306. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  307. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +13 -13
  308. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  309. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -6
  310. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts +9 -8
  312. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +17 -2
  314. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  316. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  318. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  319. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +35 -17
  320. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  321. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +55 -57
  322. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  323. package/lib/feature-libraries/default-schema/index.d.ts +1 -3
  324. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  325. package/lib/feature-libraries/default-schema/index.js +1 -3
  326. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  327. package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
  328. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  329. package/lib/feature-libraries/forest-summary/format.js +4 -2
  330. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  331. package/lib/feature-libraries/index.d.ts +4 -3
  332. package/lib/feature-libraries/index.d.ts.map +1 -1
  333. package/lib/feature-libraries/index.js +4 -3
  334. package/lib/feature-libraries/index.js.map +1 -1
  335. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  336. package/lib/feature-libraries/modular-schema/comparison.js +1 -2
  337. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  338. package/lib/feature-libraries/modular-schema/fieldKind.d.ts +38 -12
  339. package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
  340. package/lib/feature-libraries/modular-schema/fieldKind.js +29 -11
  341. package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
  342. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.d.ts +2 -2
  343. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.d.ts.map +1 -1
  344. package/lib/feature-libraries/modular-schema/fieldKindConfiguration.js.map +1 -1
  345. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -2
  346. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  347. package/lib/feature-libraries/modular-schema/genericFieldKind.js +3 -2
  348. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  349. package/lib/feature-libraries/modular-schema/index.d.ts +0 -1
  350. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  351. package/lib/feature-libraries/modular-schema/index.js +0 -1
  352. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  353. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts +5 -6
  354. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  355. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  356. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +8 -8
  357. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  358. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1 -2
  359. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  360. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +66 -9
  361. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  362. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  363. package/lib/feature-libraries/object-forest/objectForest.js +2 -1
  364. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  365. package/lib/feature-libraries/optional-field/index.d.ts +1 -1
  366. package/lib/feature-libraries/optional-field/index.d.ts.map +1 -1
  367. package/lib/feature-libraries/optional-field/index.js.map +1 -1
  368. package/lib/feature-libraries/optional-field/optionalFieldCodecs.d.ts.map +1 -1
  369. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js +1 -5
  370. package/lib/feature-libraries/optional-field/optionalFieldCodecs.js.map +1 -1
  371. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  372. package/lib/feature-libraries/schema-index/codec.js +5 -3
  373. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  374. package/lib/feature-libraries/{default-schema/schemaChecker.d.ts → schemaChecker.d.ts} +2 -2
  375. package/lib/feature-libraries/schemaChecker.d.ts.map +1 -0
  376. package/lib/feature-libraries/{default-schema/schemaChecker.js → schemaChecker.js} +3 -3
  377. package/lib/feature-libraries/schemaChecker.js.map +1 -0
  378. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
  379. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js +0 -2
  380. package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
  381. package/lib/index.d.ts +2 -2
  382. package/lib/index.d.ts.map +1 -1
  383. package/lib/index.js +2 -2
  384. package/lib/index.js.map +1 -1
  385. package/lib/packageVersion.d.ts +1 -1
  386. package/lib/packageVersion.js +1 -1
  387. package/lib/packageVersion.js.map +1 -1
  388. package/lib/shared-tree/index.d.ts +1 -1
  389. package/lib/shared-tree/index.d.ts.map +1 -1
  390. package/lib/shared-tree/index.js +1 -1
  391. package/lib/shared-tree/index.js.map +1 -1
  392. package/lib/shared-tree/sharedTree.d.ts +0 -44
  393. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  394. package/lib/shared-tree/sharedTree.js +0 -51
  395. package/lib/shared-tree/sharedTree.js.map +1 -1
  396. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
  397. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  398. package/lib/shared-tree/sharedTreeChangeCodecs.js +0 -2
  399. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  400. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  401. package/lib/shared-tree-core/editManagerCodecs.js +13 -7
  402. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  403. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +3 -4
  404. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  405. package/lib/shared-tree-core/editManagerFormatCommons.js +4 -7
  406. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  407. package/lib/shared-tree-core/index.d.ts +2 -2
  408. package/lib/shared-tree-core/index.d.ts.map +1 -1
  409. package/lib/shared-tree-core/index.js +2 -2
  410. package/lib/shared-tree-core/index.js.map +1 -1
  411. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  412. package/lib/shared-tree-core/messageCodecs.js +21 -10
  413. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  414. package/lib/shared-tree-core/messageFormat.d.ts +4 -6
  415. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
  416. package/lib/shared-tree-core/messageFormat.js +8 -6
  417. package/lib/shared-tree-core/messageFormat.js.map +1 -1
  418. package/lib/simple-tree/api/configuration.d.ts +2 -0
  419. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  420. package/lib/simple-tree/api/configuration.js +10 -0
  421. package/lib/simple-tree/api/configuration.js.map +1 -1
  422. package/lib/simple-tree/api/index.d.ts +1 -0
  423. package/lib/simple-tree/api/index.d.ts.map +1 -1
  424. package/lib/simple-tree/api/index.js +1 -0
  425. package/lib/simple-tree/api/index.js.map +1 -1
  426. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  427. package/lib/simple-tree/api/schemaFromSimple.js +8 -2
  428. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  429. package/lib/simple-tree/api/simpleSchemaCodec.js +5 -7
  430. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
  431. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +103 -0
  432. package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -0
  433. package/lib/simple-tree/api/snapshotCompatibilityChecker.js +122 -0
  434. package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -0
  435. package/lib/simple-tree/api/tree.d.ts +1 -1
  436. package/lib/simple-tree/api/tree.js +1 -1
  437. package/lib/simple-tree/api/tree.js.map +1 -1
  438. package/lib/simple-tree/core/allowedTypes.js +1 -1
  439. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  440. package/lib/simple-tree/core/index.d.ts +3 -3
  441. package/lib/simple-tree/core/index.d.ts.map +1 -1
  442. package/lib/simple-tree/core/index.js +2 -2
  443. package/lib/simple-tree/core/index.js.map +1 -1
  444. package/lib/simple-tree/core/toStored.d.ts +12 -5
  445. package/lib/simple-tree/core/toStored.d.ts.map +1 -1
  446. package/lib/simple-tree/core/toStored.js +25 -9
  447. package/lib/simple-tree/core/toStored.js.map +1 -1
  448. package/lib/simple-tree/core/treeNodeSchema.d.ts +1 -6
  449. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  450. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  451. package/lib/simple-tree/core/treeNodeValid.d.ts +1 -1
  452. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  453. package/lib/simple-tree/core/treeNodeValid.js +1 -2
  454. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  455. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  456. package/lib/simple-tree/fieldSchema.js +2 -9
  457. package/lib/simple-tree/fieldSchema.js.map +1 -1
  458. package/lib/simple-tree/index.d.ts +2 -2
  459. package/lib/simple-tree/index.d.ts.map +1 -1
  460. package/lib/simple-tree/index.js +2 -2
  461. package/lib/simple-tree/index.js.map +1 -1
  462. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  463. package/lib/simple-tree/leafNodeSchema.js +1 -2
  464. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  465. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  466. package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -51
  467. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  468. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  469. package/lib/simple-tree/node-kinds/map/mapNode.js +3 -7
  470. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  471. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  472. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -11
  473. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  474. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  475. package/lib/simple-tree/node-kinds/record/recordNode.js +3 -7
  476. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  477. package/lib/simple-tree/simpleSchema.d.ts +15 -3
  478. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  479. package/lib/simple-tree/simpleSchema.js.map +1 -1
  480. package/lib/simple-tree/toStoredSchema.d.ts +20 -8
  481. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  482. package/lib/simple-tree/toStoredSchema.js +28 -24
  483. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  484. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  485. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +20 -17
  486. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  487. package/lib/tableSchema.d.ts +22 -52
  488. package/lib/tableSchema.d.ts.map +1 -1
  489. package/lib/tableSchema.js +143 -279
  490. package/lib/tableSchema.js.map +1 -1
  491. package/lib/util/arrayUtilities.d.ts +45 -0
  492. package/lib/util/arrayUtilities.d.ts.map +1 -0
  493. package/lib/util/arrayUtilities.js +69 -0
  494. package/lib/util/arrayUtilities.js.map +1 -0
  495. package/lib/util/index.d.ts +1 -0
  496. package/lib/util/index.d.ts.map +1 -1
  497. package/lib/util/index.js +1 -0
  498. package/lib/util/index.js.map +1 -1
  499. package/package.json +21 -21
  500. package/src/api.ts +22 -11
  501. package/src/codec/codec.ts +10 -2
  502. package/src/codec/index.ts +1 -0
  503. package/src/codec/versioned/codec.ts +40 -2
  504. package/src/codec/versioned/index.ts +1 -0
  505. package/src/core/schema-stored/schema.ts +12 -1
  506. package/src/core/tree/detachedFieldIndexCodecs.ts +10 -3
  507. package/src/feature-libraries/README.md +1 -1
  508. package/src/feature-libraries/chunked-forest/chunkTree.ts +3 -3
  509. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +5 -0
  510. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +2 -1
  511. package/src/feature-libraries/chunked-forest/codec/codecs.ts +52 -19
  512. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +8 -3
  513. package/src/feature-libraries/chunked-forest/codec/format.ts +14 -4
  514. package/src/feature-libraries/chunked-forest/codec/formatGeneric.ts +7 -2
  515. package/src/feature-libraries/chunked-forest/codec/index.ts +1 -4
  516. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +62 -9
  517. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +24 -2
  518. package/src/feature-libraries/chunked-forest/index.ts +1 -1
  519. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +86 -74
  520. package/src/feature-libraries/default-schema/index.ts +1 -9
  521. package/src/feature-libraries/forest-summary/format.ts +15 -9
  522. package/src/feature-libraries/index.ts +7 -5
  523. package/src/feature-libraries/modular-schema/comparison.ts +2 -3
  524. package/src/feature-libraries/modular-schema/fieldKind.ts +90 -13
  525. package/src/feature-libraries/modular-schema/fieldKindConfiguration.ts +2 -3
  526. package/src/feature-libraries/modular-schema/genericFieldKind.ts +6 -6
  527. package/src/feature-libraries/modular-schema/index.ts +0 -1
  528. package/src/feature-libraries/modular-schema/isNeverTree.ts +7 -8
  529. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +13 -13
  530. package/src/feature-libraries/object-forest/objectForest.ts +2 -6
  531. package/src/feature-libraries/optional-field/index.ts +1 -0
  532. package/src/feature-libraries/optional-field/optionalFieldCodecs.ts +1 -5
  533. package/src/feature-libraries/schema-index/codec.ts +10 -3
  534. package/src/feature-libraries/{default-schema/schemaChecker.ts → schemaChecker.ts} +4 -4
  535. package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +0 -2
  536. package/src/index.ts +3 -1
  537. package/src/packageVersion.ts +1 -1
  538. package/src/shared-tree/index.ts +0 -1
  539. package/src/shared-tree/sharedTree.ts +0 -70
  540. package/src/shared-tree/sharedTreeChangeCodecs.ts +1 -6
  541. package/src/shared-tree-core/editManagerCodecs.ts +19 -7
  542. package/src/shared-tree-core/editManagerFormatCommons.ts +11 -12
  543. package/src/shared-tree-core/index.ts +6 -2
  544. package/src/shared-tree-core/messageCodecs.ts +32 -17
  545. package/src/shared-tree-core/messageFormat.ts +8 -6
  546. package/src/simple-tree/api/configuration.ts +17 -4
  547. package/src/simple-tree/api/index.ts +5 -0
  548. package/src/simple-tree/api/schemaFromSimple.ts +14 -6
  549. package/src/simple-tree/api/simpleSchemaCodec.ts +10 -9
  550. package/src/simple-tree/api/snapshotCompatibilityChecker.ts +135 -0
  551. package/src/simple-tree/api/tree.ts +1 -1
  552. package/src/simple-tree/core/allowedTypes.ts +1 -1
  553. package/src/simple-tree/core/index.ts +3 -1
  554. package/src/simple-tree/core/toStored.ts +42 -18
  555. package/src/simple-tree/core/treeNodeSchema.ts +1 -7
  556. package/src/simple-tree/core/treeNodeValid.ts +0 -2
  557. package/src/simple-tree/fieldSchema.ts +2 -11
  558. package/src/simple-tree/index.ts +6 -1
  559. package/src/simple-tree/leafNodeSchema.ts +1 -2
  560. package/src/simple-tree/node-kinds/array/arrayNode.ts +26 -75
  561. package/src/simple-tree/node-kinds/map/mapNode.ts +1 -15
  562. package/src/simple-tree/node-kinds/object/objectNode.ts +2 -17
  563. package/src/simple-tree/node-kinds/record/recordNode.ts +1 -15
  564. package/src/simple-tree/simpleSchema.ts +16 -3
  565. package/src/simple-tree/toStoredSchema.ts +54 -38
  566. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +22 -17
  567. package/src/tableSchema.ts +110 -334
  568. package/src/util/arrayUtilities.ts +88 -0
  569. package/src/util/index.ts +6 -0
  570. package/dist/feature-libraries/default-schema/defaultSchema.d.ts +0 -10
  571. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +0 -1
  572. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -15
  573. package/dist/feature-libraries/default-schema/defaultSchema.js.map +0 -1
  574. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +0 -1
  575. package/dist/feature-libraries/default-schema/schemaChecker.js.map +0 -1
  576. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +0 -50
  577. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +0 -1
  578. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js +0 -76
  579. package/dist/feature-libraries/modular-schema/fieldKindWithEditor.js.map +0 -1
  580. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +0 -12
  581. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +0 -1
  582. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js +0 -158
  583. package/dist/feature-libraries/optional-field/optionalFieldCodecV1.js.map +0 -1
  584. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +0 -11
  585. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +0 -1
  586. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +0 -245
  587. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +0 -1
  588. package/lib/feature-libraries/default-schema/defaultSchema.d.ts +0 -10
  589. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +0 -1
  590. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -12
  591. package/lib/feature-libraries/default-schema/defaultSchema.js.map +0 -1
  592. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +0 -1
  593. package/lib/feature-libraries/default-schema/schemaChecker.js.map +0 -1
  594. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts +0 -50
  595. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.d.ts.map +0 -1
  596. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js +0 -71
  597. package/lib/feature-libraries/modular-schema/fieldKindWithEditor.js.map +0 -1
  598. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts +0 -12
  599. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.d.ts.map +0 -1
  600. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js +0 -154
  601. package/lib/feature-libraries/optional-field/optionalFieldCodecV1.js.map +0 -1
  602. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +0 -11
  603. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +0 -1
  604. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +0 -241
  605. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +0 -1
  606. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -15
  607. package/src/feature-libraries/modular-schema/fieldKindWithEditor.ts +0 -108
  608. package/src/feature-libraries/optional-field/optionalFieldCodecV1.ts +0 -208
  609. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +0 -344
@@ -2,13 +2,18 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { TSchema } from "@sinclair/typebox";
5
+ import type { SemanticVersion } from "@fluidframework/runtime-utils/internal";
6
+ import { type TSchema } from "@sinclair/typebox";
6
7
  import type { JsonCompatibleReadOnly } from "../../util/index.js";
7
8
  import { type ICodecFamily, type ICodecOptions, type IJsonCodec, type FormatVersion, type CodecWriteOptions } from "../codec.js";
8
9
  import { Versioned } from "./format.js";
9
10
  import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
10
11
  export declare function makeVersionedCodec<TDecoded, TEncoded extends Versioned = JsonCompatibleReadOnly & Versioned, TValidate = TEncoded, TContext = void>(supportedVersions: Set<FormatVersion>, { jsonValidator: validator }: ICodecOptions, inner: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>): IJsonCodec<TDecoded, TEncoded, TValidate, TContext>;
11
- export declare function makeVersionedValidatedCodec<EncodedSchema extends TSchema, TDecoded, TEncoded extends Versioned = JsonCompatibleReadOnly & Versioned, TValidate = TEncoded, TContext = void>(options: ICodecOptions, supportedVersions: Set<number>, schema: EncodedSchema, codec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>): IJsonCodec<TDecoded, TEncoded, TValidate, TContext>;
12
+ export declare function makeVersionedValidatedCodec<EncodedSchema extends TSchema, TDecoded, TEncoded extends Versioned = JsonCompatibleReadOnly & Versioned, TValidate = TEncoded, TContext = void>(options: ICodecOptions, supportedVersions: Set<FormatVersion>, schema: EncodedSchema, codec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>): IJsonCodec<TDecoded, TEncoded, TValidate, TContext>;
13
+ /**
14
+ * Creates a codec which always throws a UsageError when encoding or decoding, indicating that the format version is discontinued.
15
+ */
16
+ export declare function makeDiscontinuedCodecVersion<TDecoded, TEncoded extends Versioned = JsonCompatibleReadOnly & Versioned, TContext = unknown>(options: ICodecOptions, discontinuedVersion: FormatVersion, discontinuedSince: SemanticVersion): IJsonCodec<TDecoded, TEncoded, TEncoded, TContext>;
12
17
  /**
13
18
  * Creates a codec which dispatches to the appropriate member of a codec family based on the version of
14
19
  * data it encounters.
@@ -1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,aAAa,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAC/C,UAAU,CAAC,QAAQ,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,QAAQ,CAAC,CAYhF;AAED;;;;;GAKG;AACH,qBAAa,oCAAoC,CAAC,QAAQ,EAAE,QAAQ;IAElE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc;;IAT/B;;OAEG;IACc,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACzD;;;;OAIG;IACc,cAAc,EAAE,CAAC,mBAAmB,EAAE,uBAAuB,KAAK,MAAM;IAGnF,KAAK,CACX,OAAO,EAAE,iBAAiB,GACxB,UAAU,CAAC,QAAQ,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,QAAQ,CAAC;CAIjF"}
@@ -4,9 +4,10 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ClientVersionDispatchingCodecBuilder = exports.makeVersionDispatchingCodec = exports.makeVersionedValidatedCodec = exports.makeVersionedCodec = void 0;
7
+ exports.ClientVersionDispatchingCodecBuilder = exports.makeVersionDispatchingCodec = exports.makeDiscontinuedCodecVersion = exports.makeVersionedValidatedCodec = exports.makeVersionedCodec = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
+ const typebox_1 = require("@sinclair/typebox");
10
11
  const codec_js_1 = require("../codec.js");
11
12
  const format_js_1 = require("./format.js");
12
13
  const packageVersion_js_1 = require("../../packageVersion.js");
@@ -36,6 +37,28 @@ function makeVersionedValidatedCodec(options, supportedVersions, schema, codec)
36
37
  return makeVersionedCodec(supportedVersions, options, (0, codec_js_1.withSchemaValidation)(schema, codec, options.jsonValidator));
37
38
  }
38
39
  exports.makeVersionedValidatedCodec = makeVersionedValidatedCodec;
40
+ /**
41
+ * Creates a codec which always throws a UsageError when encoding or decoding, indicating that the format version is discontinued.
42
+ */
43
+ function makeDiscontinuedCodecVersion(options, discontinuedVersion, discontinuedSince) {
44
+ const schema = typebox_1.Type.Object({
45
+ version: discontinuedVersion === undefined
46
+ ? typebox_1.Type.Undefined()
47
+ : typebox_1.Type.Literal(discontinuedVersion),
48
+ },
49
+ // Using `additionalProperties: true` allows this schema to be used when loading data encoded by older versions even though they contain additional properties.
50
+ { additionalProperties: true });
51
+ const codec = {
52
+ encode: (_) => {
53
+ throw new internal_2.UsageError(`Cannot encode data to format ${discontinuedVersion}. The codec was discontinued in FF version ${discontinuedSince}.`);
54
+ },
55
+ decode: (data) => {
56
+ throw new internal_2.UsageError(`Cannot decode data to format ${data.version}. The codec was discontinued in FF version ${discontinuedSince}.`);
57
+ },
58
+ };
59
+ return makeVersionedValidatedCodec(options, new Set([discontinuedVersion]), schema, codec);
60
+ }
61
+ exports.makeDiscontinuedCodecVersion = makeDiscontinuedCodecVersion;
39
62
  /**
40
63
  * Creates a codec which dispatches to the appropriate member of a codec family based on the version of
41
64
  * data it encounters.
@@ -1 +1 @@
1
- {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/codec/versioned/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAItE,0CAOqB;AAErB,2CAAwC;AACxC,+DAAqD;AAGrD,SAAgB,kBAAkB,CAMjC,iBAAqC,EACrC,EAAE,aAAa,EAAE,SAAS,EAAiB,EAC3C,KAA0D;IAE1D,MAAM,KAAK,GAAG;QACb,MAAM,EAAE,CAAC,IAAc,EAAE,OAAiB,EAAY,EAAE;YACvD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC5C,IAAA,iBAAM,EACL,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EACtC,KAAK,CAAC,+CAA+C,CACrD,CA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E,OAAO,EAAE;QACrD,MAAM,CAAC,IAAI,EAAE,OAAO;YACnB,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAc,CAAC;QACtD,CAAC;QACD,MAAM,CAAC,IAAe,EAAE,OAAO;YAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAfD,kEAeC;AAED;;;;;GAKG;AACH,MAAa,oCAAoC;IAChD;IACC;;OAEG;IACc,MAAwC;IACzD;;;;OAIG;IACc,cAAwE;QANxE,WAAM,GAAN,MAAM,CAAkC;QAMxC,mBAAc,GAAd,cAAc,CAA0D;IACvF,CAAC;IAEG,KAAK,CACX,OAA0B;QAE1B,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACtE,OAAO,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAC/E,CAAC;CACD;AApBD,oFAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\twithSchemaValidation,\n\ttype FormatVersion,\n\ttype CodecWriteOptions,\n} from \"../codec.js\";\n\nimport { Versioned } from \"./format.js\";\nimport { pkgVersion } from \"../../packageVersion.js\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\nexport function makeVersionedCodec<\n\tTDecoded,\n\tTEncoded extends Versioned = JsonCompatibleReadOnly & Versioned,\n\tTValidate = TEncoded,\n\tTContext = void,\n>(\n\tsupportedVersions: Set<FormatVersion>,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tinner: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>,\n): IJsonCodec<TDecoded, TEncoded, TValidate, TContext> {\n\tconst codec = {\n\t\tencode: (data: TDecoded, context: TContext): TEncoded => {\n\t\t\tconst encoded = inner.encode(data, context);\n\t\t\tassert(\n\t\t\t\tsupportedVersions.has(encoded.version),\n\t\t\t\t0x88b /* version being encoded should be supported */,\n\t\t\t);\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: TValidate, context: TContext): TDecoded => {\n\t\t\tconst versioned = data as Versioned; // Validated by withSchemaValidation\n\t\t\tif (!supportedVersions.has(versioned.version)) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Unsupported version ${versioned.version} encountered while decoding data. Supported versions for this data are: ${Array.from(supportedVersions).join(\", \")}.\nThe client which encoded this data likely specified an \"minVersionForCollab\" value which corresponds to a version newer than the version of this client (\"${pkgVersion}\").`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst decoded = inner.decode(data, context);\n\t\t\treturn decoded;\n\t\t},\n\t};\n\n\treturn supportedVersions.has(undefined)\n\t\t? codec\n\t\t: withSchemaValidation(Versioned, codec, validator);\n}\n\nexport function makeVersionedValidatedCodec<\n\tEncodedSchema extends TSchema,\n\tTDecoded,\n\tTEncoded extends Versioned = JsonCompatibleReadOnly & Versioned,\n\tTValidate = TEncoded,\n\tTContext = void,\n>(\n\toptions: ICodecOptions,\n\tsupportedVersions: Set<number>,\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>,\n): IJsonCodec<TDecoded, TEncoded, TValidate, TContext> {\n\treturn makeVersionedCodec(\n\t\tsupportedVersions,\n\t\toptions,\n\t\twithSchemaValidation(schema, codec, options.jsonValidator),\n\t);\n}\n\n/**\n * Creates a codec which dispatches to the appropriate member of a codec family based on the version of\n * data it encounters.\n * @remarks\n * Each member of the codec family must write an explicit version number into the data it encodes (implementing {@link Versioned}).\n *\n * TODO: Users of this should migrate to {@link ClientVersionDispatchingCodecBuilder} so that the actual format version used can be encapsulated.\n */\nexport function makeVersionDispatchingCodec<TDecoded, TContext>(\n\tfamily: ICodecFamily<TDecoded, TContext>,\n\toptions: ICodecOptions & { writeVersion: number },\n): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\tconst writeCodec = family.resolve(options.writeVersion).json;\n\tconst supportedVersions = new Set(family.getSupportedFormats());\n\treturn makeVersionedCodec(supportedVersions, options, {\n\t\tencode(data, context): Versioned {\n\t\t\treturn writeCodec.encode(data, context) as Versioned;\n\t\t},\n\t\tdecode(data: Versioned, context) {\n\t\t\tconst codec = family.resolve(data.version);\n\t\t\treturn codec.json.decode(data, context);\n\t\t},\n\t});\n}\n\n/**\n * Creates a codec which dispatches to the appropriate member of a codec family based on the `minVersionForCollab` for encode and the\n * version number in data it encounters for decode.\n * @privateRemarks\n * This is a two stage builder so the first stage can encapsulate all codec specific details and the second can bring in configuration.\n */\nexport class ClientVersionDispatchingCodecBuilder<TDecoded, TContext> {\n\tpublic constructor(\n\t\t/**\n\t\t * The codec family to dispatch to.\n\t\t */\n\t\tprivate readonly family: ICodecFamily<TDecoded, TContext>,\n\t\t/**\n\t\t * A function which maps a {@link MinimumVersionForCollab} to a version number for the codec family which is supported by that version.\n\t\t * This can (and typically does) pick the newest version of the codec which is known to be compatible with the client version so that\n\t\t * any improvements in newer versions of the codec can be used when allowed.\n\t\t */\n\t\tprivate readonly versionMapping: (minVersionForCollab: MinimumVersionForCollab) => number,\n\t) {}\n\n\tpublic build(\n\t\toptions: CodecWriteOptions,\n\t): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\tconst writeVersion = this.versionMapping(options.minVersionForCollab);\n\t\treturn makeVersionDispatchingCodec(this.family, { ...options, writeVersion });\n\t}\n}\n"]}
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../../src/codec/versioned/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,+CAAuD;AAGvD,0CAOqB;AAErB,2CAAwC;AACxC,+DAAqD;AAGrD,SAAgB,kBAAkB,CAMjC,iBAAqC,EACrC,EAAE,aAAa,EAAE,SAAS,EAAiB,EAC3C,KAA0D;IAE1D,MAAM,KAAK,GAAG;QACb,MAAM,EAAE,CAAC,IAAc,EAAE,OAAiB,EAAY,EAAE;YACvD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC5C,IAAA,iBAAM,EACL,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EACtC,KAAK,CAAC,+CAA+C,CACrD,CAAC;YACF,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,CAAC,IAAe,EAAE,OAAiB,EAAY,EAAE;YACxD,MAAM,SAAS,GAAG,IAAiB,CAAC,CAAC,oCAAoC;YACzE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC/C,MAAM,IAAI,qBAAU,CACnB,uBAAuB,SAAS,CAAC,OAAO,2EAA2E,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;4JACJ,8BAAU,KAAK,CACtK,CAAC;YACH,CAAC;YACD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC5C,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC;IAEF,OAAO,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC;QACtC,CAAC,CAAC,KAAK;QACP,CAA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C,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC;IAC7D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAChE,OAAO,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,EAAE;QACrD,MAAM,CAAC,IAAI,EAAE,OAAO;YACnB,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAc,CAAC;QACtD,CAAC;QACD,MAAM,CAAC,IAAe,EAAE,OAAO;YAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAfD,kEAeC;AAED;;;;;GAKG;AACH,MAAa,oCAAoC;IAChD;IACC;;OAEG;IACc,MAAwC;IACzD;;;;OAIG;IACc,cAAwE;QANxE,WAAM,GAAN,MAAM,CAAkC;QAMxC,mBAAc,GAAd,cAAc,CAA0D;IACvF,CAAC;IAEG,KAAK,CACX,OAA0B;QAE1B,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACtE,OAAO,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAC/E,CAAC;CACD;AApBD,oFAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { SemanticVersion } from \"@fluidframework/runtime-utils/internal\";\nimport { Type, type TSchema } from \"@sinclair/typebox\";\n\nimport type { JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport {\n\ttype ICodecFamily,\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\twithSchemaValidation,\n\ttype FormatVersion,\n\ttype CodecWriteOptions,\n} from \"../codec.js\";\n\nimport { Versioned } from \"./format.js\";\nimport { pkgVersion } from \"../../packageVersion.js\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\nexport function makeVersionedCodec<\n\tTDecoded,\n\tTEncoded extends Versioned = JsonCompatibleReadOnly & Versioned,\n\tTValidate = TEncoded,\n\tTContext = void,\n>(\n\tsupportedVersions: Set<FormatVersion>,\n\t{ jsonValidator: validator }: ICodecOptions,\n\tinner: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>,\n): IJsonCodec<TDecoded, TEncoded, TValidate, TContext> {\n\tconst codec = {\n\t\tencode: (data: TDecoded, context: TContext): TEncoded => {\n\t\t\tconst encoded = inner.encode(data, context);\n\t\t\tassert(\n\t\t\t\tsupportedVersions.has(encoded.version),\n\t\t\t\t0x88b /* version being encoded should be supported */,\n\t\t\t);\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (data: TValidate, context: TContext): TDecoded => {\n\t\t\tconst versioned = data as Versioned; // Validated by withSchemaValidation\n\t\t\tif (!supportedVersions.has(versioned.version)) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Unsupported version ${versioned.version} encountered while decoding data. Supported versions for this data are: ${Array.from(supportedVersions).join(\", \")}.\nThe client which encoded this data likely specified an \"minVersionForCollab\" value which corresponds to a version newer than the version of this client (\"${pkgVersion}\").`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst decoded = inner.decode(data, context);\n\t\t\treturn decoded;\n\t\t},\n\t};\n\n\treturn supportedVersions.has(undefined)\n\t\t? codec\n\t\t: withSchemaValidation(Versioned, codec, validator);\n}\n\nexport function makeVersionedValidatedCodec<\n\tEncodedSchema extends TSchema,\n\tTDecoded,\n\tTEncoded extends Versioned = JsonCompatibleReadOnly & Versioned,\n\tTValidate = TEncoded,\n\tTContext = void,\n>(\n\toptions: ICodecOptions,\n\tsupportedVersions: Set<FormatVersion>,\n\tschema: EncodedSchema,\n\tcodec: IJsonCodec<TDecoded, TEncoded, TValidate, TContext>,\n): IJsonCodec<TDecoded, TEncoded, TValidate, TContext> {\n\treturn makeVersionedCodec(\n\t\tsupportedVersions,\n\t\toptions,\n\t\twithSchemaValidation(schema, codec, options.jsonValidator),\n\t);\n}\n\n/**\n * Creates a codec which always throws a UsageError when encoding or decoding, indicating that the format version is discontinued.\n */\nexport function makeDiscontinuedCodecVersion<\n\tTDecoded,\n\tTEncoded extends Versioned = JsonCompatibleReadOnly & Versioned,\n\tTContext = unknown,\n>(\n\toptions: ICodecOptions,\n\tdiscontinuedVersion: FormatVersion,\n\tdiscontinuedSince: SemanticVersion,\n): IJsonCodec<TDecoded, TEncoded, TEncoded, TContext> {\n\tconst schema = Type.Object(\n\t\t{\n\t\t\tversion:\n\t\t\t\tdiscontinuedVersion === undefined\n\t\t\t\t\t? Type.Undefined()\n\t\t\t\t\t: Type.Literal(discontinuedVersion),\n\t\t},\n\t\t// Using `additionalProperties: true` allows this schema to be used when loading data encoded by older versions even though they contain additional properties.\n\t\t{ additionalProperties: true },\n\t);\n\tconst codec: IJsonCodec<TDecoded, TEncoded, TEncoded, TContext> = {\n\t\tencode: (_: TDecoded): TEncoded => {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Cannot encode data to format ${discontinuedVersion}. The codec was discontinued in FF version ${discontinuedSince}.`,\n\t\t\t);\n\t\t},\n\t\tdecode: (data: TEncoded): TDecoded => {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Cannot decode data to format ${data.version}. The codec was discontinued in FF version ${discontinuedSince}.`,\n\t\t\t);\n\t\t},\n\t};\n\treturn makeVersionedValidatedCodec(options, new Set([discontinuedVersion]), schema, codec);\n}\n\n/**\n * Creates a codec which dispatches to the appropriate member of a codec family based on the version of\n * data it encounters.\n * @remarks\n * Each member of the codec family must write an explicit version number into the data it encodes (implementing {@link Versioned}).\n *\n * TODO: Users of this should migrate to {@link ClientVersionDispatchingCodecBuilder} so that the actual format version used can be encapsulated.\n */\nexport function makeVersionDispatchingCodec<TDecoded, TContext>(\n\tfamily: ICodecFamily<TDecoded, TContext>,\n\toptions: ICodecOptions & { writeVersion: number },\n): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\tconst writeCodec = family.resolve(options.writeVersion).json;\n\tconst supportedVersions = new Set(family.getSupportedFormats());\n\treturn makeVersionedCodec(supportedVersions, options, {\n\t\tencode(data, context): Versioned {\n\t\t\treturn writeCodec.encode(data, context) as Versioned;\n\t\t},\n\t\tdecode(data: Versioned, context) {\n\t\t\tconst codec = family.resolve(data.version);\n\t\t\treturn codec.json.decode(data, context);\n\t\t},\n\t});\n}\n\n/**\n * Creates a codec which dispatches to the appropriate member of a codec family based on the `minVersionForCollab` for encode and the\n * version number in data it encounters for decode.\n * @privateRemarks\n * This is a two stage builder so the first stage can encapsulate all codec specific details and the second can bring in configuration.\n */\nexport class ClientVersionDispatchingCodecBuilder<TDecoded, TContext> {\n\tpublic constructor(\n\t\t/**\n\t\t * The codec family to dispatch to.\n\t\t */\n\t\tprivate readonly family: ICodecFamily<TDecoded, TContext>,\n\t\t/**\n\t\t * A function which maps a {@link MinimumVersionForCollab} to a version number for the codec family which is supported by that version.\n\t\t * This can (and typically does) pick the newest version of the codec which is known to be compatible with the client version so that\n\t\t * any improvements in newer versions of the codec can be used when allowed.\n\t\t */\n\t\tprivate readonly versionMapping: (minVersionForCollab: MinimumVersionForCollab) => number,\n\t) {}\n\n\tpublic build(\n\t\toptions: CodecWriteOptions,\n\t): IJsonCodec<TDecoded, JsonCompatibleReadOnly, JsonCompatibleReadOnly, TContext> {\n\t\tconst writeVersion = this.versionMapping(options.minVersionForCollab);\n\t\treturn makeVersionDispatchingCodec(this.family, { ...options, writeVersion });\n\t}\n}\n"]}
@@ -3,5 +3,5 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { Versioned } from "./format.js";
6
- export { makeVersionedCodec, makeVersionedValidatedCodec, makeVersionDispatchingCodec, } from "./codec.js";
6
+ export { makeVersionedCodec, makeVersionedValidatedCodec, makeVersionDispatchingCodec, makeDiscontinuedCodecVersion, } from "./codec.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/codec/versioned/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,GAC3B,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/codec/versioned/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,GAC5B,MAAM,YAAY,CAAC"}
@@ -4,11 +4,12 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.makeVersionDispatchingCodec = exports.makeVersionedValidatedCodec = exports.makeVersionedCodec = exports.Versioned = void 0;
7
+ exports.makeDiscontinuedCodecVersion = exports.makeVersionDispatchingCodec = exports.makeVersionedValidatedCodec = exports.makeVersionedCodec = exports.Versioned = void 0;
8
8
  var format_js_1 = require("./format.js");
9
9
  Object.defineProperty(exports, "Versioned", { enumerable: true, get: function () { return format_js_1.Versioned; } });
10
10
  var codec_js_1 = require("./codec.js");
11
11
  Object.defineProperty(exports, "makeVersionedCodec", { enumerable: true, get: function () { return codec_js_1.makeVersionedCodec; } });
12
12
  Object.defineProperty(exports, "makeVersionedValidatedCodec", { enumerable: true, get: function () { return codec_js_1.makeVersionedValidatedCodec; } });
13
13
  Object.defineProperty(exports, "makeVersionDispatchingCodec", { enumerable: true, get: function () { return codec_js_1.makeVersionDispatchingCodec; } });
14
+ Object.defineProperty(exports, "makeDiscontinuedCodecVersion", { enumerable: true, get: function () { return codec_js_1.makeDiscontinuedCodecVersion; } });
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/codec/versioned/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uCAIoB;AAHnB,8GAAA,kBAAkB,OAAA;AAClB,uHAAA,2BAA2B,OAAA;AAC3B,uHAAA,2BAA2B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { Versioned } from \"./format.js\";\nexport {\n\tmakeVersionedCodec,\n\tmakeVersionedValidatedCodec,\n\tmakeVersionDispatchingCodec,\n} from \"./codec.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/codec/versioned/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uCAKoB;AAJnB,8GAAA,kBAAkB,OAAA;AAClB,uHAAA,2BAA2B,OAAA;AAC3B,uHAAA,2BAA2B,OAAA;AAC3B,wHAAA,4BAA4B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { Versioned } from \"./format.js\";\nexport {\n\tmakeVersionedCodec,\n\tmakeVersionedValidatedCodec,\n\tmakeVersionDispatchingCodec,\n\tmakeDiscontinuedCodecVersion,\n} from \"./codec.js\";\n"]}
@@ -60,13 +60,24 @@ export declare enum ValueSchema {
60
60
  */
61
61
  export type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier>;
62
62
  /**
63
- * Declarative portion of a Field Kind.
63
+ * Declarative portion of a {@link FlexFieldKind}.
64
64
  *
65
65
  * @remarks
66
66
  * Enough info about a field kind to know if a given tree is is schema.
67
+ *
68
+ * Note that compatibility between trees and schema is not sufficient to evaluate if a schema upgrade should be allowed.
69
+ * Currently schema upgrades are restricted to field kind changes which can not be cyclic (like version upgrades but not down grades).
70
+ * See {@link FlexFieldKind.allowsFieldSuperset} for more details.
67
71
  */
68
72
  export interface FieldKindData {
73
+ /**
74
+ * Globally scoped identifier.
75
+ */
69
76
  readonly identifier: FieldKindIdentifier;
77
+ /**
78
+ * Bound on the number of children that fields of this kind may have.
79
+ * TODO: consider replacing this with numeric upper and lower bounds.
80
+ */
70
81
  readonly multiplicity: Multiplicity;
71
82
  }
72
83
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/core/schema-stored/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACN,KAAK,KAAK,EACV,KAAK,4BAA4B,EACjC,KAAK,WAAW,EAGhB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,IAAI,mBAAmB,EAE7C,KAAK,wBAAwB,IAAI,0BAA0B,EAC3D,KAAK,wBAAwB,EAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACX,iBAAiB,IAAI,mBAAmB,EACxC,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,IAAI,0BAA0B,EACtD,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;IAE/B;;OAEG;;CAEM,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,KAAK,CACtC,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,EAC9D,qBAAqB,CACrB,CA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AAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,iBAAiB,CAAC,QAA8B;IACxD,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAA,eAAI,EAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACjF,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAA6B;IAChE,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iHAAiH;QACjH,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;KAC/B,CAAC;AACH,CAAC;AAND,kDAMC;AAED,SAAgB,mBAAmB,CAAC,MAA6B;IAChE,MAAM,WAAW,GAAwB,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAErE,mDAAmD;IACnD,OAAO,MAAM,CAAC,iBAAiB,KAAK,SAAS;QAC5C,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,iBAAiB,EAAE;QACxD,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC;AACvB,CAAC;AAPD,kDAOC;AAED,SAAgB,iBAAiB,CAAC,MAA2B;IAC5D,MAAM,GAAG,GAA0B;QAClC,kFAAkF;QAClF,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QAC5B,iBAAiB,EAAE,MAAM,CAAC,QAAQ;KAClC,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AARD,8CAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../codec/index.js\";\nimport {\n\ttype Brand,\n\ttype JsonCompatibleReadOnlyObject,\n\ttype MakeNominal,\n\tbrandConst,\n\tinvertMap,\n} from \"../../util/index.js\";\n\nimport {\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldSchemaFormat as FieldSchemaFormatV1,\n\tPersistedValueSchema,\n\ttype TreeNodeSchemaDataFormat as TreeNodeSchemaDataFormatV1,\n\ttype TreeNodeSchemaIdentifier,\n} from \"./formatV1.js\";\nimport type {\n\tFieldSchemaFormat as FieldSchemaFormatV2,\n\tPersistedMetadataFormat,\n\tTreeNodeSchemaUnionFormat,\n\tTreeNodeSchemaDataFormat as TreeNodeSchemaDataFormatV2,\n} from \"./formatV2.js\";\nimport type { Multiplicity } from \"./multiplicity.js\";\n\n/**\n * The format version for the schema.\n */\nexport const SchemaFormatVersion = {\n\tv1: 1,\n\t/**\n\t * Adds persisted metadata to the node schema and field schema.\n\t */\n\tv2: 2,\n} as const;\nexport type SchemaFormatVersion = Brand<\n\t(typeof SchemaFormatVersion)[keyof typeof SchemaFormatVersion],\n\t\"SchemaFormatVersion\"\n>;\n\ntype FieldSchemaFormat = FieldSchemaFormatV1 | FieldSchemaFormatV2;\n\n/**\n * Schema for what {@link TreeLeafValue} is allowed on a Leaf node.\n * @privateRemarks\n * See also {@link TreeValue}.\n * If further stabilizing this,\n * consider the implications of how this might prevent adding of new leaf types in the future.\n * Maybe add a disclaimer that it might be extended like on {@link NodeKind}?\n * @alpha\n */\nexport enum ValueSchema {\n\tNumber,\n\tString,\n\tBoolean,\n\tFluidHandle,\n\tNull,\n}\n\n/**\n * Set of allowed tree types.\n * Providing multiple values here allows polymorphism, tagged union style.\n *\n * In the future, this could be extended to allow inlining a TreeNodeStoredSchema here\n * (or some similar structural schema system).\n * For structural types which could go here, there are a few interesting options:\n *\n * - Allow replacing the whole set with a structural type for terminal / non-tree data,\n * and use this as a replacement for values on the tree nodes.\n *\n * - Allow expression structural constraints for child trees, for example requiring specific traits\n * (ex: via TreeNodeStoredSchema), instead of by type.\n *\n * There are two ways this could work:\n *\n * - Constrain the child nodes based on their shape:\n * this makes schema safe editing difficult because nodes would incur extra editing constraints to prevent them\n * from going out of schema based on their location in such a field.\n *\n * - Constrain the types allowed based on which types guarantee their data will always meet the constraints.\n *\n * Care would need to be taken to make sure this is sound for the schema updating mechanisms.\n */\nexport type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier>;\n\n/**\n * Declarative portion of a Field Kind.\n *\n * @remarks\n * Enough info about a field kind to know if a given tree is is schema.\n */\nexport interface FieldKindData {\n\treadonly identifier: FieldKindIdentifier;\n\treadonly multiplicity: Multiplicity;\n}\n\n/**\n * Everything needed to define what it means for a tree to be in schema.\n */\nexport interface SchemaAndPolicy {\n\treadonly schema: StoredSchemaCollection;\n\treadonly policy: SchemaPolicy;\n}\n\n/**\n * Extra data needed to interpret stored schema.\n * @remarks\n * This contains information that describes the semantics of things which can be referenced in stored schema.\n * For example, field kind identifiers refer to specific field kinds, which imply specific rules around what is valid in a given field (the multiplicity).\n * This structure provides such information, allowing it to be possible to determine if a given tree complies with a particular stored schema.\n */\nexport interface SchemaPolicy {\n\t/**\n\t * Policy information about FieldKinds:\n\t * This is typically stored as code, not in documents, and defines how to handle fields based on their kind.\n\t * It is assumed that all users of a document will have exactly the same FieldKind policies,\n\t * though older applications might be missing some,\n\t * and will be unable to process any changes that use those FieldKinds.\n\t */\n\treadonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;\n}\n\n/**\n * Schema for a field.\n * Object implementing this interface should never be modified.\n */\nexport interface TreeFieldStoredSchema {\n\treadonly kind: FieldKindIdentifier;\n\n\t/**\n\t * The set of allowed child types.\n\t * If not specified, types are unconstrained.\n\t */\n\treadonly types: TreeTypeSet;\n\n\t/**\n\t * Portion of the metadata which can be persisted.\n\t * @remarks\n\t * Discarded when encoding to {@link SchemaFormatVersion.V1}.\n\t * @privateRemarks\n\t * This field corresponds to the `metadata` field in the persisted schema format.\n\t */\n\treadonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * Identifier used for the FieldKind for fields which must be empty.\n *\n * @remarks\n * This mainly show up in:\n *\n * 1. The root default field for documents.\n *\n * 2. The schema used for out of schema fields (which thus must be empty/not exist) on object and leaf nodes.\n */\nexport const forbiddenFieldKindIdentifier = brandConst(\"Forbidden\")<FieldKindIdentifier>();\n\n/**\n * A schema for empty fields (fields which must always be empty).\n * There are multiple ways this could be encoded, but this is the most explicit.\n */\nexport const storedEmptyFieldSchema: TreeFieldStoredSchema = {\n\t// This kind requires the field to be empty.\n\tkind: forbiddenFieldKindIdentifier,\n\t// This type set also forces the field to be empty not not allowing any types as all.\n\ttypes: new Set(),\n\tpersistedMetadata: undefined,\n};\n\n/**\n * Identifier used for the FieldKind for fields of type identifier.\n */\nexport const identifierFieldKindIdentifier = \"Identifier\";\n\nexport abstract class TreeNodeStoredSchema {\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * Constructor for a TreeNodeStoredSchema.\n\t * @param metadata - Persisted metadata for this node schema.\n\t */\n\tpublic constructor(public readonly metadata: PersistedMetadataFormat | undefined) {}\n\n\t/**\n\t * Encode in the v1 schema format.\n\t */\n\tpublic abstract encodeV1(): TreeNodeSchemaDataFormatV1;\n\n\t/**\n\t * Encode in the v2 schema format.\n\t * @remarks Post-condition: if metadata was specified on the input schema, it will be present in the output.\n\t */\n\tpublic abstract encodeV2(): TreeNodeSchemaDataFormatV2;\n\n\t/**\n\t * Returns the schema for the provided field.\n\t */\n\tpublic abstract getFieldSchema(field: FieldKey): TreeFieldStoredSchema;\n}\n\nexport class ObjectNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param objectNodeFields - Schema for fields with keys scoped to this TreeNodeStoredSchema.\n\t * This refers to the TreeFieldStoredSchema directly\n\t * (as opposed to just supporting FieldSchemaIdentifier and having a central FieldKey -\\> TreeFieldStoredSchema map).\n\t * This allows us short friendly field keys which can be ergonomically used as field names in code.\n\t * It also interoperates well with mapFields being used as a map with arbitrary data as keys.\n\t */\n\tpublic constructor(\n\t\tpublic readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>,\n\t\tmetadata?: PersistedMetadataFormat | undefined,\n\t) {\n\t\tsuper(metadata);\n\t}\n\n\tpublic override encodeV1(): TreeNodeSchemaDataFormatV1 {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> =\n\t\t\tthis.encodeFieldsObject(encodeFieldSchemaV1);\n\n\t\treturn {\n\t\t\tobject: fieldsObject,\n\t\t};\n\t}\n\n\tpublic override encodeV2(): TreeNodeSchemaDataFormatV2 {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> =\n\t\t\tthis.encodeFieldsObject(encodeFieldSchemaV2);\n\t\tconst kind = { object: fieldsObject };\n\n\t\treturn { kind, metadata: this.metadata };\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.objectNodeFields.get(field) ?? storedEmptyFieldSchema;\n\t}\n\n\tprivate encodeFieldsObject(\n\t\tencodeFieldSchema: (storedFieldSchema: TreeFieldStoredSchema) => FieldSchemaFormat,\n\t): Record<string, FieldSchemaFormat> {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> = Object.create(null);\n\t\t// Sort fields to ensure output is identical for for equivalent schema (since field order is not considered significant).\n\t\t// This makes comparing schema easier, and ensures chunk reuse for schema summaries isn't needlessly broken.\n\t\tfor (const key of [...this.objectNodeFields.keys()].sort()) {\n\t\t\tObject.defineProperty(fieldsObject, key, {\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t\tvalue: encodeFieldSchema(\n\t\t\t\t\tthis.objectNodeFields.get(key) ?? fail(0xae7 /* missing field */),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\treturn fieldsObject;\n\t}\n}\n\nexport class MapNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param mapFields - Allows using the fields as a map, with the keys being\n\t * FieldKeys and the values being constrained by this TreeFieldStoredSchema.\n\t * Usually `FieldKind.Value` should NOT be used here\n\t * since no nodes can ever be in schema if you use `FieldKind.Value` here\n\t * (that would require infinite children).\n\t */\n\tpublic constructor(\n\t\tpublic readonly mapFields: TreeFieldStoredSchema,\n\t\tmetadata?: PersistedMetadataFormat | undefined,\n\t) {\n\t\tsuper(metadata);\n\t}\n\n\tpublic override encodeV1(): TreeNodeSchemaDataFormatV1 {\n\t\treturn {\n\t\t\tmap: encodeFieldSchemaV1(this.mapFields),\n\t\t};\n\t}\n\n\tpublic override encodeV2(): TreeNodeSchemaDataFormatV2 {\n\t\tconst kind = { map: encodeFieldSchemaV2(this.mapFields) };\n\t\treturn { kind, metadata: this.metadata };\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.mapFields;\n\t}\n}\n\nexport class LeafNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param leafValue - There are several approaches for how to store actual data in the tree\n\t * (special node types, special field contents, data on nodes etc.)\n\t * as well as several options about how the data should be modeled at this level\n\t * (byte sequence? javascript type? json?),\n\t * as well as options for how much of this would be exposed in the schema language\n\t * (ex: would all nodes with values be special built-ins, or could any schema add them?)\n\t * A simple easy to do in javascript approach is taken here:\n\t * this is not intended to be a suggestion of what approach to take, or what to expose in the schema language.\n\t * This is simply one approach that can work for modeling them in the internal schema representation.\n\t */\n\tpublic constructor(public readonly leafValue: ValueSchema) {\n\t\t// No metadata for leaf nodes.\n\t\tsuper(undefined);\n\t}\n\n\tpublic override encodeV1(): TreeNodeSchemaDataFormatV1 {\n\t\treturn {\n\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t};\n\t}\n\n\tpublic override encodeV2(): TreeNodeSchemaDataFormatV2 {\n\t\treturn {\n\t\t\t// No metadata for leaf nodes, so don't emit a metadata field.\n\t\t\tkind: {\n\t\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn storedEmptyFieldSchema;\n\t}\n}\n\n/**\n * Decoder wrapper function for {@link TreeNodeStoredSchema} implementations.\n * Curries the constructor so that the caller can inject metadata.\n */\ntype StoredSchemaDecoder = (\n\tmetadata: PersistedMetadataFormat | undefined,\n) => TreeNodeStoredSchema;\n\nexport const storedSchemaDecodeDispatcher: DiscriminatedUnionDispatcher<\n\tTreeNodeSchemaUnionFormat,\n\t[],\n\tStoredSchemaDecoder\n> = new DiscriminatedUnionDispatcher({\n\tleaf: (data: PersistedValueSchema) => (metadata) =>\n\t\tnew LeafNodeStoredSchema(decodeValueSchema(data)),\n\tobject: (data: Record<TreeNodeSchemaIdentifier, FieldSchemaFormat>) => (metadata) => {\n\t\tconst map = new Map();\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tmap.set(key, decodeFieldSchema(value));\n\t\t}\n\t\treturn new ObjectNodeStoredSchema(map, metadata);\n\t},\n\tmap: (data: FieldSchemaFormat) => (metadata) =>\n\t\tnew MapNodeStoredSchema(decodeFieldSchema(data), metadata),\n});\n\nconst valueSchemaEncode = new Map([\n\t[ValueSchema.Number, PersistedValueSchema.Number],\n\t[ValueSchema.String, PersistedValueSchema.String],\n\t[ValueSchema.Boolean, PersistedValueSchema.Boolean],\n\t[ValueSchema.FluidHandle, PersistedValueSchema.FluidHandle],\n\t[ValueSchema.Null, PersistedValueSchema.Null],\n]);\n\nconst valueSchemaDecode = invertMap(valueSchemaEncode);\n\nfunction encodeValueSchema(inMemory: ValueSchema): PersistedValueSchema {\n\treturn valueSchemaEncode.get(inMemory) ?? fail(0xae8 /* missing PersistedValueSchema */);\n}\n\nfunction decodeValueSchema(inMemory: PersistedValueSchema): ValueSchema {\n\treturn valueSchemaDecode.get(inMemory) ?? fail(0xae9 /* missing ValueSchema */);\n}\n\nexport function encodeFieldSchemaV1(schema: TreeFieldStoredSchema): FieldSchemaFormatV1 {\n\treturn {\n\t\tkind: schema.kind,\n\t\t// Types are sorted by identifier to improve stability of persisted data to increase chance of schema blob reuse.\n\t\ttypes: [...schema.types].sort(),\n\t};\n}\n\nexport function encodeFieldSchemaV2(schema: TreeFieldStoredSchema): FieldSchemaFormatV2 {\n\tconst fieldSchema: FieldSchemaFormatV1 = encodeFieldSchemaV1(schema);\n\n\t// Omit metadata from the output if it is undefined\n\treturn schema.persistedMetadata !== undefined\n\t\t? { ...fieldSchema, metadata: schema.persistedMetadata }\n\t\t: { ...fieldSchema };\n}\n\nexport function decodeFieldSchema(schema: FieldSchemaFormatV2): TreeFieldStoredSchema {\n\tconst out: TreeFieldStoredSchema = {\n\t\t// TODO: maybe provide actual FieldKind objects here, error on unrecognized kinds.\n\t\tkind: schema.kind,\n\t\ttypes: new Set(schema.types),\n\t\tpersistedMetadata: schema.metadata,\n\t};\n\treturn out;\n}\n\n/**\n * Document schema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hand onto a specific version, make a copy.\n */\nexport interface TreeStoredSchema extends StoredSchemaCollection {\n\t/**\n\t * Schema for the root field which contains the whole tree.\n\t */\n\treadonly rootFieldSchema: TreeFieldStoredSchema;\n}\n\n/**\n * Collection of TreeNodeSchema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hang onto a specific version, make a copy.\n */\nexport interface StoredSchemaCollection {\n\t/**\n\t * {@inheritdoc StoredSchemaCollection}\n\t */\n\treadonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;\n}\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/core/schema-stored/schema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAE3D,mDAAoE;AACpE,kDAM6B;AAE7B,+CAOuB;AASvB;;GAEG;AACU,QAAA,mBAAmB,GAAG;IAClC,EAAE,EAAE,CAAC;IACL;;OAEG;IACH,EAAE,EAAE,CAAC;CACI,CAAC;AAQX;;;;;;;;GAQG;AAC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AC;AACvB,CAAC;AAPD,kDAOC;AAED,SAAgB,iBAAiB,CAAC,MAA2B;IAC5D,MAAM,GAAG,GAA0B;QAClC,kFAAkF;QAClF,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QAC5B,iBAAiB,EAAE,MAAM,CAAC,QAAQ;KAClC,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC;AARD,8CAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\n\nimport { DiscriminatedUnionDispatcher } from \"../../codec/index.js\";\nimport {\n\ttype Brand,\n\ttype JsonCompatibleReadOnlyObject,\n\ttype MakeNominal,\n\tbrandConst,\n\tinvertMap,\n} from \"../../util/index.js\";\n\nimport {\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype FieldSchemaFormat as FieldSchemaFormatV1,\n\tPersistedValueSchema,\n\ttype TreeNodeSchemaDataFormat as TreeNodeSchemaDataFormatV1,\n\ttype TreeNodeSchemaIdentifier,\n} from \"./formatV1.js\";\nimport type {\n\tFieldSchemaFormat as FieldSchemaFormatV2,\n\tPersistedMetadataFormat,\n\tTreeNodeSchemaUnionFormat,\n\tTreeNodeSchemaDataFormat as TreeNodeSchemaDataFormatV2,\n} from \"./formatV2.js\";\nimport type { Multiplicity } from \"./multiplicity.js\";\n\n/**\n * The format version for the schema.\n */\nexport const SchemaFormatVersion = {\n\tv1: 1,\n\t/**\n\t * Adds persisted metadata to the node schema and field schema.\n\t */\n\tv2: 2,\n} as const;\nexport type SchemaFormatVersion = Brand<\n\t(typeof SchemaFormatVersion)[keyof typeof SchemaFormatVersion],\n\t\"SchemaFormatVersion\"\n>;\n\ntype FieldSchemaFormat = FieldSchemaFormatV1 | FieldSchemaFormatV2;\n\n/**\n * Schema for what {@link TreeLeafValue} is allowed on a Leaf node.\n * @privateRemarks\n * See also {@link TreeValue}.\n * If further stabilizing this,\n * consider the implications of how this might prevent adding of new leaf types in the future.\n * Maybe add a disclaimer that it might be extended like on {@link NodeKind}?\n * @alpha\n */\nexport enum ValueSchema {\n\tNumber,\n\tString,\n\tBoolean,\n\tFluidHandle,\n\tNull,\n}\n\n/**\n * Set of allowed tree types.\n * Providing multiple values here allows polymorphism, tagged union style.\n *\n * In the future, this could be extended to allow inlining a TreeNodeStoredSchema here\n * (or some similar structural schema system).\n * For structural types which could go here, there are a few interesting options:\n *\n * - Allow replacing the whole set with a structural type for terminal / non-tree data,\n * and use this as a replacement for values on the tree nodes.\n *\n * - Allow expression structural constraints for child trees, for example requiring specific traits\n * (ex: via TreeNodeStoredSchema), instead of by type.\n *\n * There are two ways this could work:\n *\n * - Constrain the child nodes based on their shape:\n * this makes schema safe editing difficult because nodes would incur extra editing constraints to prevent them\n * from going out of schema based on their location in such a field.\n *\n * - Constrain the types allowed based on which types guarantee their data will always meet the constraints.\n *\n * Care would need to be taken to make sure this is sound for the schema updating mechanisms.\n */\nexport type TreeTypeSet = ReadonlySet<TreeNodeSchemaIdentifier>;\n\n/**\n * Declarative portion of a {@link FlexFieldKind}.\n *\n * @remarks\n * Enough info about a field kind to know if a given tree is is schema.\n *\n * Note that compatibility between trees and schema is not sufficient to evaluate if a schema upgrade should be allowed.\n * Currently schema upgrades are restricted to field kind changes which can not be cyclic (like version upgrades but not down grades).\n * See {@link FlexFieldKind.allowsFieldSuperset} for more details.\n */\nexport interface FieldKindData {\n\t/**\n\t * Globally scoped identifier.\n\t */\n\treadonly identifier: FieldKindIdentifier;\n\t/**\n\t * Bound on the number of children that fields of this kind may have.\n\t * TODO: consider replacing this with numeric upper and lower bounds.\n\t */\n\treadonly multiplicity: Multiplicity;\n}\n\n/**\n * Everything needed to define what it means for a tree to be in schema.\n */\nexport interface SchemaAndPolicy {\n\treadonly schema: StoredSchemaCollection;\n\treadonly policy: SchemaPolicy;\n}\n\n/**\n * Extra data needed to interpret stored schema.\n * @remarks\n * This contains information that describes the semantics of things which can be referenced in stored schema.\n * For example, field kind identifiers refer to specific field kinds, which imply specific rules around what is valid in a given field (the multiplicity).\n * This structure provides such information, allowing it to be possible to determine if a given tree complies with a particular stored schema.\n */\nexport interface SchemaPolicy {\n\t/**\n\t * Policy information about FieldKinds:\n\t * This is typically stored as code, not in documents, and defines how to handle fields based on their kind.\n\t * It is assumed that all users of a document will have exactly the same FieldKind policies,\n\t * though older applications might be missing some,\n\t * and will be unable to process any changes that use those FieldKinds.\n\t */\n\treadonly fieldKinds: ReadonlyMap<FieldKindIdentifier, FieldKindData>;\n}\n\n/**\n * Schema for a field.\n * Object implementing this interface should never be modified.\n */\nexport interface TreeFieldStoredSchema {\n\treadonly kind: FieldKindIdentifier;\n\n\t/**\n\t * The set of allowed child types.\n\t * If not specified, types are unconstrained.\n\t */\n\treadonly types: TreeTypeSet;\n\n\t/**\n\t * Portion of the metadata which can be persisted.\n\t * @remarks\n\t * Discarded when encoding to {@link SchemaFormatVersion.V1}.\n\t * @privateRemarks\n\t * This field corresponds to the `metadata` field in the persisted schema format.\n\t */\n\treadonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * Identifier used for the FieldKind for fields which must be empty.\n *\n * @remarks\n * This mainly show up in:\n *\n * 1. The root default field for documents.\n *\n * 2. The schema used for out of schema fields (which thus must be empty/not exist) on object and leaf nodes.\n */\nexport const forbiddenFieldKindIdentifier = brandConst(\"Forbidden\")<FieldKindIdentifier>();\n\n/**\n * A schema for empty fields (fields which must always be empty).\n * There are multiple ways this could be encoded, but this is the most explicit.\n */\nexport const storedEmptyFieldSchema: TreeFieldStoredSchema = {\n\t// This kind requires the field to be empty.\n\tkind: forbiddenFieldKindIdentifier,\n\t// This type set also forces the field to be empty not not allowing any types as all.\n\ttypes: new Set(),\n\tpersistedMetadata: undefined,\n};\n\n/**\n * Identifier used for the FieldKind for fields of type identifier.\n */\nexport const identifierFieldKindIdentifier = \"Identifier\";\n\nexport abstract class TreeNodeStoredSchema {\n\tprotected _typeCheck!: MakeNominal;\n\n\t/**\n\t * Constructor for a TreeNodeStoredSchema.\n\t * @param metadata - Persisted metadata for this node schema.\n\t */\n\tpublic constructor(public readonly metadata: PersistedMetadataFormat | undefined) {}\n\n\t/**\n\t * Encode in the v1 schema format.\n\t */\n\tpublic abstract encodeV1(): TreeNodeSchemaDataFormatV1;\n\n\t/**\n\t * Encode in the v2 schema format.\n\t * @remarks Post-condition: if metadata was specified on the input schema, it will be present in the output.\n\t */\n\tpublic abstract encodeV2(): TreeNodeSchemaDataFormatV2;\n\n\t/**\n\t * Returns the schema for the provided field.\n\t */\n\tpublic abstract getFieldSchema(field: FieldKey): TreeFieldStoredSchema;\n}\n\nexport class ObjectNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param objectNodeFields - Schema for fields with keys scoped to this TreeNodeStoredSchema.\n\t * This refers to the TreeFieldStoredSchema directly\n\t * (as opposed to just supporting FieldSchemaIdentifier and having a central FieldKey -\\> TreeFieldStoredSchema map).\n\t * This allows us short friendly field keys which can be ergonomically used as field names in code.\n\t * It also interoperates well with mapFields being used as a map with arbitrary data as keys.\n\t */\n\tpublic constructor(\n\t\tpublic readonly objectNodeFields: ReadonlyMap<FieldKey, TreeFieldStoredSchema>,\n\t\tmetadata?: PersistedMetadataFormat | undefined,\n\t) {\n\t\tsuper(metadata);\n\t}\n\n\tpublic override encodeV1(): TreeNodeSchemaDataFormatV1 {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> =\n\t\t\tthis.encodeFieldsObject(encodeFieldSchemaV1);\n\n\t\treturn {\n\t\t\tobject: fieldsObject,\n\t\t};\n\t}\n\n\tpublic override encodeV2(): TreeNodeSchemaDataFormatV2 {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> =\n\t\t\tthis.encodeFieldsObject(encodeFieldSchemaV2);\n\t\tconst kind = { object: fieldsObject };\n\n\t\treturn { kind, metadata: this.metadata };\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.objectNodeFields.get(field) ?? storedEmptyFieldSchema;\n\t}\n\n\tprivate encodeFieldsObject(\n\t\tencodeFieldSchema: (storedFieldSchema: TreeFieldStoredSchema) => FieldSchemaFormat,\n\t): Record<string, FieldSchemaFormat> {\n\t\tconst fieldsObject: Record<string, FieldSchemaFormat> = Object.create(null);\n\t\t// Sort fields to ensure output is identical for for equivalent schema (since field order is not considered significant).\n\t\t// This makes comparing schema easier, and ensures chunk reuse for schema summaries isn't needlessly broken.\n\t\tfor (const key of [...this.objectNodeFields.keys()].sort()) {\n\t\t\tObject.defineProperty(fieldsObject, key, {\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t\tvalue: encodeFieldSchema(\n\t\t\t\t\tthis.objectNodeFields.get(key) ?? fail(0xae7 /* missing field */),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\treturn fieldsObject;\n\t}\n}\n\nexport class MapNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param mapFields - Allows using the fields as a map, with the keys being\n\t * FieldKeys and the values being constrained by this TreeFieldStoredSchema.\n\t * Usually `FieldKind.Value` should NOT be used here\n\t * since no nodes can ever be in schema if you use `FieldKind.Value` here\n\t * (that would require infinite children).\n\t */\n\tpublic constructor(\n\t\tpublic readonly mapFields: TreeFieldStoredSchema,\n\t\tmetadata?: PersistedMetadataFormat | undefined,\n\t) {\n\t\tsuper(metadata);\n\t}\n\n\tpublic override encodeV1(): TreeNodeSchemaDataFormatV1 {\n\t\treturn {\n\t\t\tmap: encodeFieldSchemaV1(this.mapFields),\n\t\t};\n\t}\n\n\tpublic override encodeV2(): TreeNodeSchemaDataFormatV2 {\n\t\tconst kind = { map: encodeFieldSchemaV2(this.mapFields) };\n\t\treturn { kind, metadata: this.metadata };\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn this.mapFields;\n\t}\n}\n\nexport class LeafNodeStoredSchema extends TreeNodeStoredSchema {\n\t/**\n\t * @param leafValue - There are several approaches for how to store actual data in the tree\n\t * (special node types, special field contents, data on nodes etc.)\n\t * as well as several options about how the data should be modeled at this level\n\t * (byte sequence? javascript type? json?),\n\t * as well as options for how much of this would be exposed in the schema language\n\t * (ex: would all nodes with values be special built-ins, or could any schema add them?)\n\t * A simple easy to do in javascript approach is taken here:\n\t * this is not intended to be a suggestion of what approach to take, or what to expose in the schema language.\n\t * This is simply one approach that can work for modeling them in the internal schema representation.\n\t */\n\tpublic constructor(public readonly leafValue: ValueSchema) {\n\t\t// No metadata for leaf nodes.\n\t\tsuper(undefined);\n\t}\n\n\tpublic override encodeV1(): TreeNodeSchemaDataFormatV1 {\n\t\treturn {\n\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t};\n\t}\n\n\tpublic override encodeV2(): TreeNodeSchemaDataFormatV2 {\n\t\treturn {\n\t\t\t// No metadata for leaf nodes, so don't emit a metadata field.\n\t\t\tkind: {\n\t\t\t\tleaf: encodeValueSchema(this.leafValue),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic override getFieldSchema(field: FieldKey): TreeFieldStoredSchema {\n\t\treturn storedEmptyFieldSchema;\n\t}\n}\n\n/**\n * Decoder wrapper function for {@link TreeNodeStoredSchema} implementations.\n * Curries the constructor so that the caller can inject metadata.\n */\ntype StoredSchemaDecoder = (\n\tmetadata: PersistedMetadataFormat | undefined,\n) => TreeNodeStoredSchema;\n\nexport const storedSchemaDecodeDispatcher: DiscriminatedUnionDispatcher<\n\tTreeNodeSchemaUnionFormat,\n\t[],\n\tStoredSchemaDecoder\n> = new DiscriminatedUnionDispatcher({\n\tleaf: (data: PersistedValueSchema) => (metadata) =>\n\t\tnew LeafNodeStoredSchema(decodeValueSchema(data)),\n\tobject: (data: Record<TreeNodeSchemaIdentifier, FieldSchemaFormat>) => (metadata) => {\n\t\tconst map = new Map();\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tmap.set(key, decodeFieldSchema(value));\n\t\t}\n\t\treturn new ObjectNodeStoredSchema(map, metadata);\n\t},\n\tmap: (data: FieldSchemaFormat) => (metadata) =>\n\t\tnew MapNodeStoredSchema(decodeFieldSchema(data), metadata),\n});\n\nconst valueSchemaEncode = new Map([\n\t[ValueSchema.Number, PersistedValueSchema.Number],\n\t[ValueSchema.String, PersistedValueSchema.String],\n\t[ValueSchema.Boolean, PersistedValueSchema.Boolean],\n\t[ValueSchema.FluidHandle, PersistedValueSchema.FluidHandle],\n\t[ValueSchema.Null, PersistedValueSchema.Null],\n]);\n\nconst valueSchemaDecode = invertMap(valueSchemaEncode);\n\nfunction encodeValueSchema(inMemory: ValueSchema): PersistedValueSchema {\n\treturn valueSchemaEncode.get(inMemory) ?? fail(0xae8 /* missing PersistedValueSchema */);\n}\n\nfunction decodeValueSchema(inMemory: PersistedValueSchema): ValueSchema {\n\treturn valueSchemaDecode.get(inMemory) ?? fail(0xae9 /* missing ValueSchema */);\n}\n\nexport function encodeFieldSchemaV1(schema: TreeFieldStoredSchema): FieldSchemaFormatV1 {\n\treturn {\n\t\tkind: schema.kind,\n\t\t// Types are sorted by identifier to improve stability of persisted data to increase chance of schema blob reuse.\n\t\ttypes: [...schema.types].sort(),\n\t};\n}\n\nexport function encodeFieldSchemaV2(schema: TreeFieldStoredSchema): FieldSchemaFormatV2 {\n\tconst fieldSchema: FieldSchemaFormatV1 = encodeFieldSchemaV1(schema);\n\n\t// Omit metadata from the output if it is undefined\n\treturn schema.persistedMetadata !== undefined\n\t\t? { ...fieldSchema, metadata: schema.persistedMetadata }\n\t\t: { ...fieldSchema };\n}\n\nexport function decodeFieldSchema(schema: FieldSchemaFormatV2): TreeFieldStoredSchema {\n\tconst out: TreeFieldStoredSchema = {\n\t\t// TODO: maybe provide actual FieldKind objects here, error on unrecognized kinds.\n\t\tkind: schema.kind,\n\t\ttypes: new Set(schema.types),\n\t\tpersistedMetadata: schema.metadata,\n\t};\n\treturn out;\n}\n\n/**\n * Document schema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hand onto a specific version, make a copy.\n */\nexport interface TreeStoredSchema extends StoredSchemaCollection {\n\t/**\n\t * Schema for the root field which contains the whole tree.\n\t */\n\treadonly rootFieldSchema: TreeFieldStoredSchema;\n}\n\n/**\n * Collection of TreeNodeSchema data that can be stored in a document.\n *\n * @remarks\n * Note: the owner of this may modify it over time:\n * thus if needing to hang onto a specific version, make a copy.\n */\nexport interface StoredSchemaCollection {\n\t/**\n\t * {@inheritdoc StoredSchemaCollection}\n\t */\n\treadonly nodeSchema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"detachedFieldIndexCodecs.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,YAAY,EACjB,KAAK,UAAU,EAGf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAiB7E,wBAAgB,2BAA2B,CAC1C,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,UAAU,CAAC,wBAAwB,CAAC,CAMtC;AAED,wBAAgB,iCAAiC,CAChD,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,YAAY,CAAC,wBAAwB,CAAC,CAWxC;AAED,wBAAgB,uCAAuC,CACtD,aAAa,EAAE,uBAAuB,GACpC,SAAS,CAKX"}
1
+ {"version":3,"file":"detachedFieldIndexCodecs.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAM5F,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,YAAY,EACjB,KAAK,UAAU,EAGf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAoB7E,wBAAgB,2BAA2B,CAC1C,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,UAAU,CAAC,wBAAwB,CAAC,CAMtC;AAED,wBAAgB,iCAAiC,CAChD,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,YAAY,CAAC,wBAAwB,CAAC,CAWxC;AAED,wBAAgB,uCAAuC,CACtD,aAAa,EAAE,uBAAuB,GACpC,SAAS,CAKX"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getCodecTreeForDetachedFieldIndexFormat = exports.makeDetachedFieldIndexCodecFamily = exports.makeDetachedFieldIndexCodec = void 0;
8
+ const internal_1 = require("@fluidframework/runtime-utils/internal");
8
9
  const index_js_1 = require("../../codec/index.js");
9
10
  const detachedFieldIndexCodecV1_js_1 = require("./detachedFieldIndexCodecV1.js");
10
11
  const detachedFieldIndexCodecV2_js_1 = require("./detachedFieldIndexCodecV2.js");
@@ -16,9 +17,10 @@ const index_js_2 = require("../../util/index.js");
16
17
  * @returns The detached field codec version that corresponds to the provided MinimumVersionForCollab.
17
18
  */
18
19
  function clientVersionToDetachedFieldVersion(clientVersion) {
19
- return clientVersion < index_js_1.FluidClientVersion.v2_52
20
- ? (0, index_js_2.brand)(detachedFieldIndexFormatCommon_js_1.DetachedFieldIndexFormatVersion.v1)
21
- : (0, index_js_2.brand)(detachedFieldIndexFormatCommon_js_1.DetachedFieldIndexFormatVersion.v2);
20
+ return (0, index_js_2.brand)((0, internal_1.getConfigForMinVersionForCollab)(clientVersion, {
21
+ [internal_1.lowestMinVersionForCollab]: detachedFieldIndexFormatCommon_js_1.DetachedFieldIndexFormatVersion.v1,
22
+ [index_js_1.FluidClientVersion.v2_52]: detachedFieldIndexFormatCommon_js_1.DetachedFieldIndexFormatVersion.v2,
23
+ }));
22
24
  }
23
25
  function makeDetachedFieldIndexCodec(revisionTagCodec, options, idCompressor) {
24
26
  const family = makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor);
@@ -1 +1 @@
1
- {"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,mDAQ8B;AAG9B,iFAAgF;AAChF,iFAAgF;AAEhF,2FAAsF;AACtF,kDAA4C;AAE5C;;;;GAIG;AACH,SAAS,mCAAmC,CAC3C,aAAsC;IAEtC,OAAO,aAAa,GAAG,6BAAkB,CAAC,KAAK;QAC9C,CAAC,CAAC,IAAA,gBAAK,EAAC,mEAA+B,CAAC,EAAE,CAAC;QAC3C,CAAC,CAAC,IAAA,gBAAK,EAAC,mEAA+B,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,SAAgB,2BAA2B,CAC1C,gBAAkC,EAClC,OAA0B,EAC1B,YAA2B;IAE3B,MAAM,MAAM,GAAG,iCAAiC,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1F,OAAO,IAAA,sCAA2B,EAAC,MAAM,EAAE;QAC1C,GAAG,OAAO;QACV,YAAY,EAAE,mCAAmC,CAAC,OAAO,CAAC,mBAAmB,CAAC;KAC9E,CAAC,CAAC;AACJ,CAAC;AAVD,kEAUC;AAED,SAAgB,iCAAiC,CAChD,gBAAkC,EAClC,OAA0B,EAC1B,YAA2B;IAE3B,OAAO,IAAA,0BAAe,EAAC;QACtB;YACC,mEAA+B,CAAC,EAAE;YAClC,IAAA,6DAA8B,EAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC;SACvE;QACD;YACC,mEAA+B,CAAC,EAAE;YAClC,IAAA,6DAA8B,EAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC;SACvE;KACD,CAAC,CAAC;AACJ,CAAC;AAfD,8EAeC;AAED,SAAgB,uCAAuC,CACtD,aAAsC;IAEtC,OAAO;QACN,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,mCAAmC,CAAC,aAAa,CAAC;KAC3D,CAAC;AACH,CAAC;AAPD,0FAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype ICodecFamily,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeVersionDispatchingCodec,\n} from \"../../codec/index.js\";\nimport type { RevisionTagCodec } from \"../rebase/index.js\";\n\nimport { makeDetachedNodeToFieldCodecV1 } from \"./detachedFieldIndexCodecV1.js\";\nimport { makeDetachedNodeToFieldCodecV2 } from \"./detachedFieldIndexCodecV2.js\";\nimport type { DetachedFieldSummaryData } from \"./detachedFieldIndexTypes.js\";\nimport { DetachedFieldIndexFormatVersion } from \"./detachedFieldIndexFormatCommon.js\";\nimport { brand } from \"../../util/index.js\";\n\n/**\n * Convert a MinimumVersionForCollab to a version for detached field codecs.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The detached field codec version that corresponds to the provided MinimumVersionForCollab.\n */\nfunction clientVersionToDetachedFieldVersion(\n\tclientVersion: MinimumVersionForCollab,\n): DetachedFieldIndexFormatVersion {\n\treturn clientVersion < FluidClientVersion.v2_52\n\t\t? brand(DetachedFieldIndexFormatVersion.v1)\n\t\t: brand(DetachedFieldIndexFormatVersion.v2);\n}\n\nexport function makeDetachedFieldIndexCodec(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData> {\n\tconst family = makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor);\n\treturn makeVersionDispatchingCodec(family, {\n\t\t...options,\n\t\twriteVersion: clientVersionToDetachedFieldVersion(options.minVersionForCollab),\n\t});\n}\n\nexport function makeDetachedFieldIndexCodecFamily(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): ICodecFamily<DetachedFieldSummaryData> {\n\treturn makeCodecFamily([\n\t\t[\n\t\t\tDetachedFieldIndexFormatVersion.v1,\n\t\t\tmakeDetachedNodeToFieldCodecV1(revisionTagCodec, options, idCompressor),\n\t\t],\n\t\t[\n\t\t\tDetachedFieldIndexFormatVersion.v2,\n\t\t\tmakeDetachedNodeToFieldCodecV2(revisionTagCodec, options, idCompressor),\n\t\t],\n\t]);\n}\n\nexport function getCodecTreeForDetachedFieldIndexFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn {\n\t\tname: \"DetachedFieldIndex\",\n\t\tversion: clientVersionToDetachedFieldVersion(clientVersion),\n\t};\n}\n"]}
1
+ {"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":";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rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tgetConfigForMinVersionForCollab,\n\tlowestMinVersionForCollab,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\ttype CodecTree,\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype ICodecFamily,\n\ttype IJsonCodec,\n\tmakeCodecFamily,\n\tmakeVersionDispatchingCodec,\n} from \"../../codec/index.js\";\nimport type { RevisionTagCodec } from \"../rebase/index.js\";\n\nimport { makeDetachedNodeToFieldCodecV1 } from \"./detachedFieldIndexCodecV1.js\";\nimport { makeDetachedNodeToFieldCodecV2 } from \"./detachedFieldIndexCodecV2.js\";\nimport type { DetachedFieldSummaryData } from \"./detachedFieldIndexTypes.js\";\nimport { DetachedFieldIndexFormatVersion } from \"./detachedFieldIndexFormatCommon.js\";\nimport { brand } from \"../../util/index.js\";\n\n/**\n * Convert a MinimumVersionForCollab to a version for detached field codecs.\n * @param clientVersion - The MinimumVersionForCollab to convert.\n * @returns The detached field codec version that corresponds to the provided MinimumVersionForCollab.\n */\nfunction clientVersionToDetachedFieldVersion(\n\tclientVersion: MinimumVersionForCollab,\n): DetachedFieldIndexFormatVersion {\n\treturn brand(\n\t\tgetConfigForMinVersionForCollab(clientVersion, {\n\t\t\t[lowestMinVersionForCollab]: DetachedFieldIndexFormatVersion.v1,\n\t\t\t[FluidClientVersion.v2_52]: DetachedFieldIndexFormatVersion.v2,\n\t\t}),\n\t);\n}\n\nexport function makeDetachedFieldIndexCodec(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData> {\n\tconst family = makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor);\n\treturn makeVersionDispatchingCodec(family, {\n\t\t...options,\n\t\twriteVersion: clientVersionToDetachedFieldVersion(options.minVersionForCollab),\n\t});\n}\n\nexport function makeDetachedFieldIndexCodecFamily(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): ICodecFamily<DetachedFieldSummaryData> {\n\treturn makeCodecFamily([\n\t\t[\n\t\t\tDetachedFieldIndexFormatVersion.v1,\n\t\t\tmakeDetachedNodeToFieldCodecV1(revisionTagCodec, options, idCompressor),\n\t\t],\n\t\t[\n\t\t\tDetachedFieldIndexFormatVersion.v2,\n\t\t\tmakeDetachedNodeToFieldCodecV2(revisionTagCodec, options, idCompressor),\n\t\t],\n\t]);\n}\n\nexport function getCodecTreeForDetachedFieldIndexFormat(\n\tclientVersion: MinimumVersionForCollab,\n): CodecTree {\n\treturn {\n\t\tname: \"DetachedFieldIndex\",\n\t\tversion: clientVersionToDetachedFieldVersion(clientVersion),\n\t};\n}\n"]}
@@ -3,8 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IIdCompressor } from "@fluidframework/id-compressor";
6
- import { type FieldKey, type ITreeCursorSynchronous, type TreeFieldStoredSchema, type TreeNodeSchemaIdentifier, type TreeStoredSchemaSubscription, type Value, type TreeChunk, type SchemaAndPolicy } from "../../core/index.js";
7
- import type { FullSchemaPolicy } from "../modular-schema/index.js";
6
+ import { type FieldKey, type ITreeCursorSynchronous, type TreeFieldStoredSchema, type TreeNodeSchemaIdentifier, type TreeStoredSchemaSubscription, type Value, type TreeChunk, type SchemaAndPolicy, type SchemaPolicy } from "../../core/index.js";
8
7
  import { BasicChunk } from "./basicChunk.js";
9
8
  import { type FieldShape, TreeShape, UniformChunk } from "./uniformChunk.js";
10
9
  import type { IncrementalEncodingPolicy } from "./codec/index.js";
@@ -17,7 +16,7 @@ export interface Disposable {
17
16
  /**
18
17
  * Creates a ChunkPolicy which responds to schema changes.
19
18
  */
20
- export declare function makeTreeChunker(schema: TreeStoredSchemaSubscription, policy: FullSchemaPolicy, shouldEncodeIncrementally: IncrementalEncodingPolicy): IChunker;
19
+ export declare function makeTreeChunker(schema: TreeStoredSchemaSubscription, policy: SchemaPolicy, shouldEncodeIncrementally: IncrementalEncodingPolicy): IChunker;
21
20
  /**
22
21
  * Extends ChunkPolicy to include stateful details required by ChunkedForest.
23
22
  *
@@ -51,7 +50,7 @@ export declare const polymorphic: Polymorphic;
51
50
  export type ShapeInfo = TreeShape | Polymorphic;
52
51
  export declare class Chunker implements IChunker {
53
52
  readonly schema: TreeStoredSchemaSubscription;
54
- readonly policy: FullSchemaPolicy;
53
+ readonly policy: SchemaPolicy;
55
54
  readonly sequenceChunkSplitThreshold: number;
56
55
  readonly sequenceChunkInlineThreshold: number;
57
56
  readonly uniformChunkNodeCount: number;
@@ -63,7 +62,7 @@ export declare class Chunker implements IChunker {
63
62
  */
64
63
  private readonly typeShapes;
65
64
  private unregisterSchemaCallback;
66
- constructor(schema: TreeStoredSchemaSubscription, policy: FullSchemaPolicy, sequenceChunkSplitThreshold: number, sequenceChunkInlineThreshold: number, uniformChunkNodeCount: number, tryShapeFromNodeSchema: (type: TreeNodeSchemaIdentifier, shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>) => ShapeInfo);
65
+ constructor(schema: TreeStoredSchemaSubscription, policy: SchemaPolicy, sequenceChunkSplitThreshold: number, sequenceChunkInlineThreshold: number, uniformChunkNodeCount: number, tryShapeFromNodeSchema: (type: TreeNodeSchemaIdentifier, shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>) => ShapeInfo);
67
66
  clone(schema: TreeStoredSchemaSubscription): IChunker;
68
67
  shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;
69
68
  dispose(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"chunkTree.d.ts","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EA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4BAA4B,EAAE,MAAM,CAAC;IAE9C;;OAEG;IACH,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,CAAC;CAC7D;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC;CACjD;AAaD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACzB,MAAM,EAAE,sBAAsB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,OAAO,GACzB,SAAS,EAAE,CAqGb;AACD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,KAAK,EAAE,EACf,YAAY,CAAC,EAAE,aAAa,GAC1B,IAAI,CA4BN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,OAAO,EAC3B,YAAY,CAAC,EAAE,aAAa,GAC1B,YAAY,CAqBd"}
@@ -1 +1 @@
1
- {"version":3,"file":"chunkTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAqF;AAGrF,kDAiB6B;AAC7B,kDAAkD;AAElD,0DAAqE;AAErE,mDAA6C;AAC7C,yDAAmD;AACnD,uDAA6E;AAS7E;;GAEG;AACH,SAAgB,eAAe,CAC9B,MAAoC,EACpC,MAAwB,EACxB,yBAAoD;IAEpD,OAAO,IAAI,OAAO,CACjB,MAAM,EACN,MAAM,EACN,0BAAkB,CAAC,4BAA4B,EA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BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, debugAssert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchemaSubscription,\n\ttype TreeValue,\n\ttype Value,\n\tmapCursorFields,\n\tMultiplicity,\n\tValueSchema,\n\ttype TreeChunk,\n\ttryGetChunk,\n\ttype SchemaAndPolicy,\n} from \"../../core/index.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { FullSchemaPolicy } from \"../modular-schema/index.js\";\nimport { isStableNodeIdentifier } from \"../node-identifier/index.js\";\n\nimport { BasicChunk } from \"./basicChunk.js\";\nimport { SequenceChunk } from \"./sequenceChunk.js\";\nimport { type FieldShape, TreeShape, UniformChunk } from \"./uniformChunk.js\";\nimport type { IncrementalEncodingPolicy } from \"./codec/index.js\";\n\nexport interface Disposable {\n\t/**\n\t * Cleans up resources used by this, such as inbound event registrations.\n\t */\n\tdispose(): void;\n}\n/**\n * Creates a ChunkPolicy which responds to schema changes.\n */\nexport function makeTreeChunker(\n\tschema: TreeStoredSchemaSubscription,\n\tpolicy: FullSchemaPolicy,\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy,\n): IChunker {\n\treturn new Chunker(\n\t\tschema,\n\t\tpolicy,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.uniformChunkNodeCount,\n\t\t(type: TreeNodeSchemaIdentifier, shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>) =>\n\t\t\ttryShapeFromNodeSchema(\n\t\t\t\t{\n\t\t\t\t\tschema,\n\t\t\t\t\tpolicy,\n\t\t\t\t\tshouldEncodeIncrementally,\n\t\t\t\t\tshapes,\n\t\t\t\t},\n\t\t\t\ttype,\n\t\t\t),\n\t);\n}\n\n/**\n * Extends ChunkPolicy to include stateful details required by ChunkedForest.\n *\n * This extra complexity is mostly due to the fact that schema can change over time,\n * and that chunk policy uses caching which thus needs invalidation.\n */\nexport interface IChunker extends ChunkPolicy, Disposable {\n\treadonly schema: TreeStoredSchemaSubscription;\n\tclone(schema: TreeStoredSchemaSubscription): IChunker;\n}\n\n/**\n * Indicates that there are multiple possible `TreeShape` trees with a given type can have.\n *\n * @remarks\n * For example, a schema transitively containing a sequence field, optional field, or allowing multiple child types will be Polymorphic.\n * See `tryShapeFromNodeSchema` for how to tell if a type is Polymorphic.\n *\n * TODO: cache some of the possible shapes here.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class Polymorphic {}\n\n/**\n * See `Polymorphic`.\n * For now Polymorphic is stateless, so just use a singleton.\n */\nexport const polymorphic = new Polymorphic();\n\n/**\n * Information about the possible shapes a tree could take based on its type.\n * Note that this information is for a specific version of the schema.\n */\nexport type ShapeInfo = TreeShape | Polymorphic;\n\nexport class Chunker implements IChunker {\n\t/**\n\t * Cache for information about possible shapes for types.\n\t * Corresponds to the version of the schema in `schema`.\n\t * Cleared when `schema` changes.\n\t */\n\tprivate readonly typeShapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\n\tprivate unregisterSchemaCallback: (() => void) | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly policy: FullSchemaPolicy,\n\t\tpublic readonly sequenceChunkSplitThreshold: number,\n\t\tpublic readonly sequenceChunkInlineThreshold: number,\n\t\tpublic readonly uniformChunkNodeCount: number,\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tprivate readonly tryShapeFromNodeSchema: (\n\t\t\ttype: TreeNodeSchemaIdentifier,\n\t\t\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n\t\t) => ShapeInfo,\n\t) {}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription): IChunker {\n\t\t// This does not preserve the cache.\n\t\t// This is probably fine, but is a potential way it could be optimized in the future (with care to ensure invalidation work properly).\n\t\treturn new Chunker(\n\t\t\tschema,\n\t\t\tthis.policy,\n\t\t\tthis.sequenceChunkSplitThreshold,\n\t\t\tthis.sequenceChunkInlineThreshold,\n\t\t\tthis.uniformChunkNodeCount,\n\t\t\tthis.tryShapeFromNodeSchema,\n\t\t);\n\t}\n\n\tpublic shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo {\n\t\tconst cached = this.typeShapes.get(schema);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t\tthis.unregisterSchemaCallback = this.schema.events.on(\"afterSchemaChange\", () =>\n\t\t\tthis.schemaChanged(),\n\t\t);\n\t\treturn this.tryShapeFromNodeSchema(schema, this.typeShapes);\n\t}\n\n\tpublic dispose(): void {\n\t\t// Remove subscription for changes via dependent.\n\t\tthis.schemaChanged();\n\t}\n\n\tprivate schemaChanged(): void {\n\t\tthis.typeShapes.clear();\n\t\tif (this.unregisterSchemaCallback) {\n\t\t\tthis.unregisterSchemaCallback();\n\t\t\tthis.unregisterSchemaCallback = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Get a TreeChunk for the current node (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n *\n * @param cursor - cursor in nodes mode\n */\nexport function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk {\n\treturn chunkRange(cursor, policy, 1, true)[0] ?? oob();\n}\n\n/**\n * Get a TreeChunk[] for the current field (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n */\nexport function chunkField(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk[] {\n\tconst length = cursor.getFieldLength();\n\tconst started = cursor.firstNode();\n\tdebugAssert(\n\t\t() => started === (length !== 0) || \"only 0 length fields should not have nodes\",\n\t);\n\treturn chunkRange(cursor, policy, length, false);\n}\n\n/**\n * Get a TreeChunk for the current field (and its children) of cursor.\n * Like {@link chunkField}, but forces the results into a single TreeChunk.\n */\nexport function chunkFieldSingle(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk {\n\tconst chunks = chunkField(cursor, policy);\n\treturn combineChunks(chunks);\n}\n\n/**\n * Create a single TreeChunk from an array of TreeChunks.\n * @remarks\n * This takes ownership of the provided TreeChunk references, and returns an owned referenced.\n */\nexport function combineChunks(chunks: TreeChunk[]): TreeChunk {\n\tif (chunks.length === 1) {\n\t\treturn chunks[0] ?? oob();\n\t}\n\treturn new SequenceChunk(chunks);\n}\n\n/**\n * Get a BasicChunk for the current node (and its children) of cursor.\n * This will copy if needed, and add refs to existing chunks which hold the data.\n */\nexport function basicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\t// symbol based fast path to check for BasicChunk:\n\t// return existing chunk with a increased ref count if possible.\n\tconst chunk = tryGetChunk(cursor);\n\tif (chunk instanceof BasicChunk) {\n\t\tchunk.referenceAdded();\n\t\treturn chunk;\n\t}\n\n\treturn newBasicChunkTree(cursor, policy);\n}\n\nexport function makePolicy(policy?: Partial<ChunkPolicy>): ChunkPolicy {\n\tconst withDefaults = { ...defaultChunkPolicy, ...policy };\n\t// TODO: move this to a top level policy validation\n\tassert(\n\t\twithDefaults.sequenceChunkSplitThreshold >= 2,\n\t\t0x57d /* sequenceChunkThreshold must be at least 2 */,\n\t);\n\n\treturn withDefaults;\n}\n\nexport interface ShapeFromSchemaParameters extends SchemaAndPolicy {\n\t/**\n\t * Policy function to determine if a field should be encoded incrementally.\n\t * Incrementally encoding requires the subtree to not start in the middle of a larger uniform chunk.\n\t * Thus returning true from this callback indicates that shapes should not be produced which could\n\t *contain the incremental portion as a part of a larger shape.\n\t */\n\treadonly shouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * A cache for shapes which may be read and/or updated.\n\t * As the shape is a function of the other members of `ShapeFromSchemaParameters`,\n\t * it must be replaced or cleared if any of the properties other than this cache are modified.\n\t */\n\treadonly shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>;\n}\n\n/**\n * A TreeFieldStoredSchema with some additional context about where it is in the tree.\n */\nexport interface FieldSchemaWithContext {\n\t/**\n\t * The identifier of the specific field schema to analyze for shape uniformity.\n\t */\n\treadonly fieldSchema: TreeFieldStoredSchema;\n\t/**\n\t * The identifier of the parent node schema containing this field.\n\t * If undefined, this is a root field.\n\t */\n\treadonly parentNodeSchema?: TreeNodeSchemaIdentifier;\n\t/**\n\t * The field key/name used to identify this field within the parent node.\n\t */\n\treadonly key: FieldKey;\n}\n\n/**\n * Analyzes a tree node schema to determine if it has a single, uniform shape that can be optimized for chunking.\n * If the schema defines a tree structure with a deterministic, fixed shape (no optional fields, no sequences,\n * single child types), returns a TreeShape that can be used for efficient uniform chunking. Otherwise,\n * returns Polymorphic to indicate the shape varies and should use basic chunking.\n *\n * @param context - {@link ShapeFromSchemaParameters}.\n * @param nodeSchema - The identifier of the specific node schema to analyze for shape uniformity.\n * @returns TreeShape if the schema has a uniform shape, or Polymorphic if shape varies.\n *\n * @remarks\n * The determination here is conservative. `shouldEncodeIncrementally` is used to split up shapes so incrementally\n * encoded schema are not part of larger shapes. It also does not tolerate optional or sequence fields, nor does it\n * optimize for patterns of specific values.\n */\nexport function tryShapeFromNodeSchema(\n\tcontext: ShapeFromSchemaParameters,\n\tnodeSchema: TreeNodeSchemaIdentifier,\n): ShapeInfo {\n\tconst { schema, shapes } = context;\n\treturn getOrCreate(shapes, nodeSchema, () => {\n\t\tconst treeSchema = schema.nodeSchema.get(nodeSchema) ?? fail(0xaf9 /* missing schema */);\n\t\tif (treeSchema instanceof LeafNodeStoredSchema) {\n\t\t\t// Allow all string values (but only string values) to be compressed by the id compressor.\n\t\t\t// This allows compressing all compressible identifiers without requiring additional context to know which values could be identifiers.\n\t\t\t// Attempting to compress other string shouldn't have significant overhead,\n\t\t\t// and if any of them do end up compressing, that's a benefit not a bug.\n\t\t\treturn treeSchema.leafValue === ValueSchema.String\n\t\t\t\t? new TreeShape(nodeSchema, true, [], true)\n\t\t\t\t: new TreeShape(nodeSchema, true, [], false);\n\t\t}\n\t\tif (treeSchema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst fieldsArray: FieldShape[] = [];\n\t\t\tfor (const [key, fieldSchema] of treeSchema.objectNodeFields) {\n\t\t\t\tconst fieldShape = tryShapeFromFieldSchema(context, {\n\t\t\t\t\tfieldSchema,\n\t\t\t\t\tparentNodeSchema: nodeSchema,\n\t\t\t\t\tkey,\n\t\t\t\t});\n\t\t\t\tif (fieldShape === undefined) {\n\t\t\t\t\treturn polymorphic;\n\t\t\t\t}\n\t\t\t\tfieldsArray.push(fieldShape);\n\t\t\t}\n\t\t\treturn new TreeShape(nodeSchema, false, fieldsArray);\n\t\t}\n\t\treturn polymorphic;\n\t});\n}\n\n/**\n * Same as {@link tryShapeFromNodeSchema} but for fields with {@link FieldSchemaWithContext} instead of a nodeSchema.\n *\n * @param context - {@link ShapeFromFieldSchemaParameters}.\n * @param fieldSchemaWithContext - {@link FieldSchemaWithContext}.\n * @returns FieldShape if the field has a uniform shape, or undefined if the field is polymorphic.\n */\nexport function tryShapeFromFieldSchema(\n\tcontext: ShapeFromSchemaParameters,\n\tfieldSchemaWithContext: FieldSchemaWithContext,\n): FieldShape | undefined {\n\tconst { schema, policy, shouldEncodeIncrementally, shapes } = context;\n\tconst { fieldSchema, parentNodeSchema, key } = fieldSchemaWithContext;\n\t// If this field should be encoded incrementally, use polymorphic shape so that they\n\t// are chunked separately and can be re-used across encodings if they do not change.\n\tif (shouldEncodeIncrementally(parentNodeSchema, key)) {\n\t\treturn undefined;\n\t}\n\tconst kind = policy.fieldKinds.get(fieldSchema.kind) ?? fail(0xafa /* missing FieldKind */);\n\tif (kind.multiplicity !== Multiplicity.Single) {\n\t\treturn undefined;\n\t}\n\tif (fieldSchema.types?.size !== 1) {\n\t\treturn undefined;\n\t}\n\tconst childType = [...fieldSchema.types][0] ?? oob();\n\tconst childShape = tryShapeFromNodeSchema(\n\t\t{\n\t\t\tschema,\n\t\t\tpolicy,\n\t\t\tshouldEncodeIncrementally,\n\t\t\tshapes,\n\t\t},\n\t\tchildType,\n\t);\n\tif (childShape instanceof Polymorphic) {\n\t\treturn undefined;\n\t}\n\treturn [key, childShape, 1];\n}\n\n/**\n * Default settings for use for {@link ChunkPolicy}.\n * Use `makeTreeChunker` to create a policy with the defaults, but leverages to schema.\n */\nexport const defaultChunkPolicy: ChunkPolicy = {\n\t// Currently ChunkedForest and BasicTreeCursor don't handle SequenceChunks very efficiently:\n\t// they likely add more overhead than they save for now, so don't create them.\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\t// Current UniformChunk handling doesn't scale well to large chunks, so set a modest size limit:\n\tuniformChunkNodeCount: 400,\n\t// Without knowing what the schema is, all shapes are possible.\n\t// Use `makeTreeChunker` to do better.\n\tshapeFromSchema: () => polymorphic,\n};\n\nexport const basicOnlyChunkPolicy: ChunkPolicy = {\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\tuniformChunkNodeCount: 0,\n\tshapeFromSchema: () => polymorphic,\n};\n\n/**\n * Policy for how to chunk a tree.\n */\nexport interface ChunkPolicy {\n\t/**\n\t * Group sequences longer than this into into sequence chunks of this length or less.\n\t *\n\t * Must be at least 2.\n\t * Can be set to `Number.POSITIVE_INFINITY` to never introduce extra sequence chunks.\n\t */\n\treadonly sequenceChunkSplitThreshold: number;\n\n\t/**\n\t * SequenceChunks this long or shorter may get inlined into their parent chunk.\n\t */\n\treadonly sequenceChunkInlineThreshold: number;\n\n\t/**\n\t * Maximum total nodes to put in a UniformChunk.\n\t */\n\treadonly uniformChunkNodeCount: number;\n\n\t/**\n\t * Returns information about the shapes trees of type `schema` can take.\n\t */\n\tshapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;\n}\n\nexport interface ChunkCompressor {\n\treadonly policy: ChunkPolicy;\n\t/**\n\t * If the idCompressor is provided, {@link UniformChunk}s with identifiers will be encoded for its in-memory representation.\n\t * @remarks\n\t * This compression applies to {@link UniformChunk}s when {@link TreeShape.maybeDecompressedStringAsNumber} is set.\n\t * If the `policy` does not use UniformChunks or does not set `maybeDecompressedStringAsNumber`, then no compression will be applied even when providing `idCompressor`.\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n}\n\nfunction newBasicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\treturn new BasicChunk(\n\t\tcursor.type,\n\t\tnew Map(mapCursorFields(cursor, () => [cursor.getFieldKey(), chunkField(cursor, policy)])),\n\t\tcursor.value,\n\t);\n}\n\n/**\n * Chunk a portion of a field.\n *\n * @param cursor - cursor at the starting node in the field.\n * @param policy - heuristics to impact chunking\n * @param length - how many nodes to process (at the top level). When 0, the cursor is not moved, and may be at the end of the field (and thus in Fields mode)\n * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it. Invalid if length is 0.\n */\nexport function chunkRange(\n\tcursor: ITreeCursorSynchronous,\n\tchunkCompressor: ChunkCompressor,\n\tlength: number,\n\tskipLastNavigation: boolean,\n): TreeChunk[] {\n\tassert(\n\t\t!(skipLastNavigation && length === 0),\n\t\t0xb58 /* Cannot skip last navigation if length is 0 and thus last navigation already occurred. */,\n\t);\n\tassert(\n\t\t(cursor.mode === CursorLocationType.Nodes) === length > 0,\n\t\t0xb59 /* Should be in nodes mode if not past end */,\n\t);\n\tlet output: TreeChunk[] = [];\n\tlet remaining = length;\n\twhile (remaining > 0) {\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x57f /* should be in nodes */);\n\t\tconst start = cursor.chunkStart;\n\t\tlet reusedChunk = false;\n\t\t// symbol based fast path to check for chunk:\n\t\t// return existing chunk with a increased ref count if possible.\n\t\tif (start === cursor.fieldIndex) {\n\t\t\tconst chunkLength = cursor.chunkLength;\n\t\t\tif (chunkLength <= remaining) {\n\t\t\t\tconst chunk = tryGetChunk(cursor);\n\t\t\t\tif (chunk !== undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tchunk instanceof SequenceChunk &&\n\t\t\t\t\t\tchunk.subChunks.length <= chunkCompressor.policy.sequenceChunkInlineThreshold\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If sequence chunk, and its very short, inline it.\n\t\t\t\t\t\t// Note that this is not recursive: there may be short sequences nested below this which are not inlined.\n\t\t\t\t\t\tfor (const subChunk of chunk.subChunks) {\n\t\t\t\t\t\t\tsubChunk.referenceAdded();\n\t\t\t\t\t\t\toutput.push(subChunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchunk.referenceAdded();\n\t\t\t\t\toutput.push(chunk);\n\t\t\t\t\tremaining -= chunkLength;\n\t\t\t\t\treusedChunk = true;\n\t\t\t\t\tlet seek = chunkLength;\n\t\t\t\t\tif (skipLastNavigation && remaining === 0) {\n\t\t\t\t\t\tseek -= 1;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.seekNodes(seek);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!reusedChunk) {\n\t\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x580 /* should be in nodes */);\n\t\t\t// TODO: if provided, use schema to consider using UniformChunks\n\t\t\tconst type = cursor.type;\n\t\t\tconst shape = chunkCompressor.policy.shapeFromSchema(type);\n\t\t\tif (shape instanceof TreeShape) {\n\t\t\t\tconst nodesPerTopLevelNode = shape.positions.length;\n\t\t\t\tconst maxTopLevelLength = Math.ceil(\n\t\t\t\t\tnodesPerTopLevelNode / chunkCompressor.policy.uniformChunkNodeCount,\n\t\t\t\t);\n\t\t\t\tconst maxLength = Math.min(maxTopLevelLength, remaining);\n\t\t\t\tconst newChunk = uniformChunkFromCursor(\n\t\t\t\t\tcursor,\n\t\t\t\t\tshape,\n\t\t\t\t\tmaxLength,\n\t\t\t\t\tmaxLength === remaining && skipLastNavigation,\n\t\t\t\t\tchunkCompressor.idCompressor,\n\t\t\t\t);\n\t\t\t\tremaining -= newChunk.topLevelLength;\n\t\t\t\toutput.push(newChunk);\n\t\t\t} else {\n\t\t\t\t// Slow path: copy tree into new basic chunk\n\t\t\t\toutput.push(newBasicChunkTree(cursor, chunkCompressor));\n\t\t\t\tremaining -= 1;\n\t\t\t\tif (!skipLastNavigation || remaining !== 0) {\n\t\t\t\t\tcursor.nextNode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: maybe make a pass over output to coalesce UniformChunks and/or convert other formats to UniformChunks where possible.\n\n\t// If output is large, group it into a tree of sequence chunks.\n\twhile (output.length > chunkCompressor.policy.sequenceChunkSplitThreshold) {\n\t\tconst chunkCount = Math.ceil(\n\t\t\toutput.length / chunkCompressor.policy.sequenceChunkSplitThreshold,\n\t\t);\n\t\tconst newOutput: TreeChunk[] = [];\n\t\t// Rounding down, and add an extra item to some of the chunks.\n\t\tconst chunkSize = Math.floor(output.length / chunkCount);\n\t\t// number of chunks to add an extra item to to make total line up.\n\t\tconst extra = output.length % chunkCount;\n\t\tlet previousEnd = 0;\n\t\tfor (let index = 0; index < chunkCount; index++) {\n\t\t\t// If we are in the first `extra` items, add an extra to this chunk.\n\t\t\tconst end = previousEnd + chunkSize + (index < extra ? 1 : 0);\n\t\t\tnewOutput.push(new SequenceChunk(output.slice(previousEnd, end)));\n\t\t\tpreviousEnd = end;\n\t\t}\n\t\tassert(previousEnd === output.length, 0x581 /* chunks should add up to total */);\n\t\toutput = newOutput;\n\t}\n\n\treturn output;\n}\n/**\n * Extracts values from the current cursor position according to the provided tree shape.\n *\n * Walks through the tree structure defined by the shape, extracting values from leaf nodes\n * and recursively processing child fields. If an ID compressor is provided, compressible\n * string values (stable node identifiers) will be recompressed for optimal storage.\n *\n * @param cursor - Tree cursor positioned at the node to extract values from\n * @param shape - The tree shape defining the structure to extract\n * @param values - Array to append the extracted values to\n * @param idCompressor - Optional compressor used to encode string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function insertValues(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tvalues: Value[],\n\tidCompressor?: IIdCompressor,\n): void {\n\tassert(shape.type === cursor.type, 0x582 /* shape and type must match */);\n\n\t// TODO:Perf:\n\t// Fast path for already part of a uniform chunk with matching shape\n\n\t// Slow path: walk shape and cursor together, inserting values.\n\tif (shape.hasValue) {\n\t\tif (\n\t\t\ttypeof cursor.value === \"string\" &&\n\t\t\tidCompressor !== undefined &&\n\t\t\tisStableNodeIdentifier(cursor.value)\n\t\t) {\n\t\t\tvalues.push(idCompressor.tryRecompress(cursor.value) ?? cursor.value);\n\t\t} else {\n\t\t\tvalues.push(cursor.value);\n\t\t}\n\t}\n\tfor (const [key, childShape, length] of shape.fieldsArray) {\n\t\tcursor.enterField(key);\n\t\tlet count = 0;\n\t\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\t\tinsertValues(cursor, childShape, values, idCompressor);\n\t\t\tcount++;\n\t\t}\n\t\tcursor.exitField();\n\t\tassert(length === count, 0x583 /* unexpected field length */);\n\t}\n}\n\n/**\n * Read up to `maxTopLevelLength` nodes from `cursor`, stopping when limit is hit or type of node changes.\n *\n * This requires that the all trees with matching type match the provided shape.\n * This cannot be used if other shapes are possible for this type.\n *\n * If this stops early due to the type changing, `skipLastNavigation` is not involved:\n * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)\n * if the full length is used.\n *\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function uniformChunkFromCursor(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tmaxTopLevelLength: number,\n\tskipLastNavigation: boolean,\n\tidCompressor?: IIdCompressor,\n): UniformChunk {\n\t// TODO:\n\t// This could have a fast path for consuming already uniformly chunked data with matching shape.\n\n\tconst values: TreeValue[] = [];\n\tlet topLevelLength = 1;\n\twhile (topLevelLength <= maxTopLevelLength) {\n\t\tinsertValues(cursor, shape, values, idCompressor);\n\t\tif (topLevelLength === maxTopLevelLength) {\n\t\t\tif (!skipLastNavigation) {\n\t\t\t\tcursor.nextNode();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcursor.nextNode();\n\t\tif (cursor.type !== shape.type) {\n\t\t\tbreak;\n\t\t}\n\t\ttopLevelLength += 1;\n\t}\n\treturn new UniformChunk(shape.withTopLevelLength(topLevelLength), values, idCompressor);\n}\n"]}
1
+ {"version":3,"file":"chunkTree.js","sourceRoot":"","sources":["../../../src/feature-libraries/chunked-forest/chunkTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAqF;AAGrF,kDAkB6B;AAC7B,kDAAkD;AAClD,0DAAqE;AAErE,mDAA6C;AAC7C,yDAAmD;AACnD,uDAA6E;AAS7E;;GAEG;AACH,SAAgB,eAAe,CAC9B,MAAoC,EACpC,MAAoB,EACpB,yBAAoD;IAEpD,OAAO,IAAI,OAAO,CACjB,MAAM,EACN,MAAM,EACN,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,4BAA4B,EAC/C,0BAAkB,CAAC,qBAAqB,EACxC,CAAC,IAA8B,EAAE,MAAgD,EAAE,EAAE,CACpF,sBAAsB,CACrB;QACC,MAAM;QACN,MAAM;QACN,yBAAyB;QACzB,MAAM;KACN,EACD,IAAI,CACJ,CACF,CAAC;AACH,CAAC;AAtBD,0CAsBC;AAaD;;;;;;;;GAQG;AACH,kEAAkE;AAClE,MAAa,WAAW;CAAG;AAA3B,kCAA2B;AAE3B;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EAAE,CAAC;QACnB,IAAA,iBAAM,EAAC,MAAM,KAAK,KAAK,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC/D,CAAC;AACF,CAAC;AAjCD,oCAiCC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,sBAAsB,CACrC,MAA8B,EAC9B,KAAgB,EAChB,iBAAyB,EACzB,kBAA2B,EAC3B,YAA4B;IAE5B,QAAQ;IACR,gGAAgG;IAEhG,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,OAAO,cAAc,IAAI,iBAAiB,EAAE,CAAC;QAC5C,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAClD,IAAI,cAAc,KAAK,iBAAiB,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACzB,MAAM,CAAC,QAAQ,EAAE,CAAC;YACnB,CAAC;YACD,MAAM;QACP,CAAC;QACD,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;YAChC,MAAM;QACP,CAAC;QACD,cAAc,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,8BAAY,CAAC,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACzF,CAAC;AA3BD,wDA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, debugAssert, oob, fail } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\tCursorLocationType,\n\ttype FieldKey,\n\ttype ITreeCursorSynchronous,\n\tLeafNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeStoredSchemaSubscription,\n\ttype TreeValue,\n\ttype Value,\n\tmapCursorFields,\n\tMultiplicity,\n\tValueSchema,\n\ttype TreeChunk,\n\ttryGetChunk,\n\ttype SchemaAndPolicy,\n\ttype SchemaPolicy,\n} from \"../../core/index.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport { isStableNodeIdentifier } from \"../node-identifier/index.js\";\n\nimport { BasicChunk } from \"./basicChunk.js\";\nimport { SequenceChunk } from \"./sequenceChunk.js\";\nimport { type FieldShape, TreeShape, UniformChunk } from \"./uniformChunk.js\";\nimport type { IncrementalEncodingPolicy } from \"./codec/index.js\";\n\nexport interface Disposable {\n\t/**\n\t * Cleans up resources used by this, such as inbound event registrations.\n\t */\n\tdispose(): void;\n}\n/**\n * Creates a ChunkPolicy which responds to schema changes.\n */\nexport function makeTreeChunker(\n\tschema: TreeStoredSchemaSubscription,\n\tpolicy: SchemaPolicy,\n\tshouldEncodeIncrementally: IncrementalEncodingPolicy,\n): IChunker {\n\treturn new Chunker(\n\t\tschema,\n\t\tpolicy,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.sequenceChunkInlineThreshold,\n\t\tdefaultChunkPolicy.uniformChunkNodeCount,\n\t\t(type: TreeNodeSchemaIdentifier, shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>) =>\n\t\t\ttryShapeFromNodeSchema(\n\t\t\t\t{\n\t\t\t\t\tschema,\n\t\t\t\t\tpolicy,\n\t\t\t\t\tshouldEncodeIncrementally,\n\t\t\t\t\tshapes,\n\t\t\t\t},\n\t\t\t\ttype,\n\t\t\t),\n\t);\n}\n\n/**\n * Extends ChunkPolicy to include stateful details required by ChunkedForest.\n *\n * This extra complexity is mostly due to the fact that schema can change over time,\n * and that chunk policy uses caching which thus needs invalidation.\n */\nexport interface IChunker extends ChunkPolicy, Disposable {\n\treadonly schema: TreeStoredSchemaSubscription;\n\tclone(schema: TreeStoredSchemaSubscription): IChunker;\n}\n\n/**\n * Indicates that there are multiple possible `TreeShape` trees with a given type can have.\n *\n * @remarks\n * For example, a schema transitively containing a sequence field, optional field, or allowing multiple child types will be Polymorphic.\n * See `tryShapeFromNodeSchema` for how to tell if a type is Polymorphic.\n *\n * TODO: cache some of the possible shapes here.\n */\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class Polymorphic {}\n\n/**\n * See `Polymorphic`.\n * For now Polymorphic is stateless, so just use a singleton.\n */\nexport const polymorphic = new Polymorphic();\n\n/**\n * Information about the possible shapes a tree could take based on its type.\n * Note that this information is for a specific version of the schema.\n */\nexport type ShapeInfo = TreeShape | Polymorphic;\n\nexport class Chunker implements IChunker {\n\t/**\n\t * Cache for information about possible shapes for types.\n\t * Corresponds to the version of the schema in `schema`.\n\t * Cleared when `schema` changes.\n\t */\n\tprivate readonly typeShapes: Map<TreeNodeSchemaIdentifier, ShapeInfo> = new Map();\n\n\tprivate unregisterSchemaCallback: (() => void) | undefined;\n\n\tpublic constructor(\n\t\tpublic readonly schema: TreeStoredSchemaSubscription,\n\t\tpublic readonly policy: SchemaPolicy,\n\t\tpublic readonly sequenceChunkSplitThreshold: number,\n\t\tpublic readonly sequenceChunkInlineThreshold: number,\n\t\tpublic readonly uniformChunkNodeCount: number,\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\tprivate readonly tryShapeFromNodeSchema: (\n\t\t\ttype: TreeNodeSchemaIdentifier,\n\t\t\tshapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>,\n\t\t) => ShapeInfo,\n\t) {}\n\n\tpublic clone(schema: TreeStoredSchemaSubscription): IChunker {\n\t\t// This does not preserve the cache.\n\t\t// This is probably fine, but is a potential way it could be optimized in the future (with care to ensure invalidation work properly).\n\t\treturn new Chunker(\n\t\t\tschema,\n\t\t\tthis.policy,\n\t\t\tthis.sequenceChunkSplitThreshold,\n\t\t\tthis.sequenceChunkInlineThreshold,\n\t\t\tthis.uniformChunkNodeCount,\n\t\t\tthis.tryShapeFromNodeSchema,\n\t\t);\n\t}\n\n\tpublic shapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo {\n\t\tconst cached = this.typeShapes.get(schema);\n\t\tif (cached !== undefined) {\n\t\t\treturn cached;\n\t\t}\n\t\tthis.unregisterSchemaCallback = this.schema.events.on(\"afterSchemaChange\", () =>\n\t\t\tthis.schemaChanged(),\n\t\t);\n\t\treturn this.tryShapeFromNodeSchema(schema, this.typeShapes);\n\t}\n\n\tpublic dispose(): void {\n\t\t// Remove subscription for changes via dependent.\n\t\tthis.schemaChanged();\n\t}\n\n\tprivate schemaChanged(): void {\n\t\tthis.typeShapes.clear();\n\t\tif (this.unregisterSchemaCallback) {\n\t\t\tthis.unregisterSchemaCallback();\n\t\t\tthis.unregisterSchemaCallback = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Get a TreeChunk for the current node (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n *\n * @param cursor - cursor in nodes mode\n */\nexport function chunkTree(cursor: ITreeCursorSynchronous, policy: ChunkCompressor): TreeChunk {\n\treturn chunkRange(cursor, policy, 1, true)[0] ?? oob();\n}\n\n/**\n * Get a TreeChunk[] for the current field (and its children) of cursor.\n * This will copy if needed, but add refs to existing chunks which hold the data.\n */\nexport function chunkField(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk[] {\n\tconst length = cursor.getFieldLength();\n\tconst started = cursor.firstNode();\n\tdebugAssert(\n\t\t() => started === (length !== 0) || \"only 0 length fields should not have nodes\",\n\t);\n\treturn chunkRange(cursor, policy, length, false);\n}\n\n/**\n * Get a TreeChunk for the current field (and its children) of cursor.\n * Like {@link chunkField}, but forces the results into a single TreeChunk.\n */\nexport function chunkFieldSingle(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): TreeChunk {\n\tconst chunks = chunkField(cursor, policy);\n\treturn combineChunks(chunks);\n}\n\n/**\n * Create a single TreeChunk from an array of TreeChunks.\n * @remarks\n * This takes ownership of the provided TreeChunk references, and returns an owned referenced.\n */\nexport function combineChunks(chunks: TreeChunk[]): TreeChunk {\n\tif (chunks.length === 1) {\n\t\treturn chunks[0] ?? oob();\n\t}\n\treturn new SequenceChunk(chunks);\n}\n\n/**\n * Get a BasicChunk for the current node (and its children) of cursor.\n * This will copy if needed, and add refs to existing chunks which hold the data.\n */\nexport function basicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\t// symbol based fast path to check for BasicChunk:\n\t// return existing chunk with a increased ref count if possible.\n\tconst chunk = tryGetChunk(cursor);\n\tif (chunk instanceof BasicChunk) {\n\t\tchunk.referenceAdded();\n\t\treturn chunk;\n\t}\n\n\treturn newBasicChunkTree(cursor, policy);\n}\n\nexport function makePolicy(policy?: Partial<ChunkPolicy>): ChunkPolicy {\n\tconst withDefaults = { ...defaultChunkPolicy, ...policy };\n\t// TODO: move this to a top level policy validation\n\tassert(\n\t\twithDefaults.sequenceChunkSplitThreshold >= 2,\n\t\t0x57d /* sequenceChunkThreshold must be at least 2 */,\n\t);\n\n\treturn withDefaults;\n}\n\nexport interface ShapeFromSchemaParameters extends SchemaAndPolicy {\n\t/**\n\t * Policy function to determine if a field should be encoded incrementally.\n\t * Incrementally encoding requires the subtree to not start in the middle of a larger uniform chunk.\n\t * Thus returning true from this callback indicates that shapes should not be produced which could\n\t *contain the incremental portion as a part of a larger shape.\n\t */\n\treadonly shouldEncodeIncrementally: IncrementalEncodingPolicy;\n\t/**\n\t * A cache for shapes which may be read and/or updated.\n\t * As the shape is a function of the other members of `ShapeFromSchemaParameters`,\n\t * it must be replaced or cleared if any of the properties other than this cache are modified.\n\t */\n\treadonly shapes: Map<TreeNodeSchemaIdentifier, ShapeInfo>;\n}\n\n/**\n * A TreeFieldStoredSchema with some additional context about where it is in the tree.\n */\nexport interface FieldSchemaWithContext {\n\t/**\n\t * The identifier of the specific field schema to analyze for shape uniformity.\n\t */\n\treadonly fieldSchema: TreeFieldStoredSchema;\n\t/**\n\t * The identifier of the parent node schema containing this field.\n\t * If undefined, this is a root field.\n\t */\n\treadonly parentNodeSchema?: TreeNodeSchemaIdentifier;\n\t/**\n\t * The field key/name used to identify this field within the parent node.\n\t */\n\treadonly key: FieldKey;\n}\n\n/**\n * Analyzes a tree node schema to determine if it has a single, uniform shape that can be optimized for chunking.\n * If the schema defines a tree structure with a deterministic, fixed shape (no optional fields, no sequences,\n * single child types), returns a TreeShape that can be used for efficient uniform chunking. Otherwise,\n * returns Polymorphic to indicate the shape varies and should use basic chunking.\n *\n * @param context - {@link ShapeFromSchemaParameters}.\n * @param nodeSchema - The identifier of the specific node schema to analyze for shape uniformity.\n * @returns TreeShape if the schema has a uniform shape, or Polymorphic if shape varies.\n *\n * @remarks\n * The determination here is conservative. `shouldEncodeIncrementally` is used to split up shapes so incrementally\n * encoded schema are not part of larger shapes. It also does not tolerate optional or sequence fields, nor does it\n * optimize for patterns of specific values.\n */\nexport function tryShapeFromNodeSchema(\n\tcontext: ShapeFromSchemaParameters,\n\tnodeSchema: TreeNodeSchemaIdentifier,\n): ShapeInfo {\n\tconst { schema, shapes } = context;\n\treturn getOrCreate(shapes, nodeSchema, () => {\n\t\tconst treeSchema = schema.nodeSchema.get(nodeSchema) ?? fail(0xaf9 /* missing schema */);\n\t\tif (treeSchema instanceof LeafNodeStoredSchema) {\n\t\t\t// Allow all string values (but only string values) to be compressed by the id compressor.\n\t\t\t// This allows compressing all compressible identifiers without requiring additional context to know which values could be identifiers.\n\t\t\t// Attempting to compress other string shouldn't have significant overhead,\n\t\t\t// and if any of them do end up compressing, that's a benefit not a bug.\n\t\t\treturn treeSchema.leafValue === ValueSchema.String\n\t\t\t\t? new TreeShape(nodeSchema, true, [], true)\n\t\t\t\t: new TreeShape(nodeSchema, true, [], false);\n\t\t}\n\t\tif (treeSchema instanceof ObjectNodeStoredSchema) {\n\t\t\tconst fieldsArray: FieldShape[] = [];\n\t\t\tfor (const [key, fieldSchema] of treeSchema.objectNodeFields) {\n\t\t\t\tconst fieldShape = tryShapeFromFieldSchema(context, {\n\t\t\t\t\tfieldSchema,\n\t\t\t\t\tparentNodeSchema: nodeSchema,\n\t\t\t\t\tkey,\n\t\t\t\t});\n\t\t\t\tif (fieldShape === undefined) {\n\t\t\t\t\treturn polymorphic;\n\t\t\t\t}\n\t\t\t\tfieldsArray.push(fieldShape);\n\t\t\t}\n\t\t\treturn new TreeShape(nodeSchema, false, fieldsArray);\n\t\t}\n\t\treturn polymorphic;\n\t});\n}\n\n/**\n * Same as {@link tryShapeFromNodeSchema} but for fields with {@link FieldSchemaWithContext} instead of a nodeSchema.\n *\n * @param context - {@link ShapeFromFieldSchemaParameters}.\n * @param fieldSchemaWithContext - {@link FieldSchemaWithContext}.\n * @returns FieldShape if the field has a uniform shape, or undefined if the field is polymorphic.\n */\nexport function tryShapeFromFieldSchema(\n\tcontext: ShapeFromSchemaParameters,\n\tfieldSchemaWithContext: FieldSchemaWithContext,\n): FieldShape | undefined {\n\tconst { schema, policy, shouldEncodeIncrementally, shapes } = context;\n\tconst { fieldSchema, parentNodeSchema, key } = fieldSchemaWithContext;\n\t// If this field should be encoded incrementally, use polymorphic shape so that they\n\t// are chunked separately and can be re-used across encodings if they do not change.\n\tif (shouldEncodeIncrementally(parentNodeSchema, key)) {\n\t\treturn undefined;\n\t}\n\tconst kind = policy.fieldKinds.get(fieldSchema.kind) ?? fail(0xafa /* missing FieldKind */);\n\tif (kind.multiplicity !== Multiplicity.Single) {\n\t\treturn undefined;\n\t}\n\tif (fieldSchema.types?.size !== 1) {\n\t\treturn undefined;\n\t}\n\tconst childType = [...fieldSchema.types][0] ?? oob();\n\tconst childShape = tryShapeFromNodeSchema(\n\t\t{\n\t\t\tschema,\n\t\t\tpolicy,\n\t\t\tshouldEncodeIncrementally,\n\t\t\tshapes,\n\t\t},\n\t\tchildType,\n\t);\n\tif (childShape instanceof Polymorphic) {\n\t\treturn undefined;\n\t}\n\treturn [key, childShape, 1];\n}\n\n/**\n * Default settings for use for {@link ChunkPolicy}.\n * Use `makeTreeChunker` to create a policy with the defaults, but leverages to schema.\n */\nexport const defaultChunkPolicy: ChunkPolicy = {\n\t// Currently ChunkedForest and BasicTreeCursor don't handle SequenceChunks very efficiently:\n\t// they likely add more overhead than they save for now, so don't create them.\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\t// Current UniformChunk handling doesn't scale well to large chunks, so set a modest size limit:\n\tuniformChunkNodeCount: 400,\n\t// Without knowing what the schema is, all shapes are possible.\n\t// Use `makeTreeChunker` to do better.\n\tshapeFromSchema: () => polymorphic,\n};\n\nexport const basicOnlyChunkPolicy: ChunkPolicy = {\n\tsequenceChunkSplitThreshold: Number.POSITIVE_INFINITY,\n\tsequenceChunkInlineThreshold: Number.POSITIVE_INFINITY,\n\tuniformChunkNodeCount: 0,\n\tshapeFromSchema: () => polymorphic,\n};\n\n/**\n * Policy for how to chunk a tree.\n */\nexport interface ChunkPolicy {\n\t/**\n\t * Group sequences longer than this into into sequence chunks of this length or less.\n\t *\n\t * Must be at least 2.\n\t * Can be set to `Number.POSITIVE_INFINITY` to never introduce extra sequence chunks.\n\t */\n\treadonly sequenceChunkSplitThreshold: number;\n\n\t/**\n\t * SequenceChunks this long or shorter may get inlined into their parent chunk.\n\t */\n\treadonly sequenceChunkInlineThreshold: number;\n\n\t/**\n\t * Maximum total nodes to put in a UniformChunk.\n\t */\n\treadonly uniformChunkNodeCount: number;\n\n\t/**\n\t * Returns information about the shapes trees of type `schema` can take.\n\t */\n\tshapeFromSchema(schema: TreeNodeSchemaIdentifier): ShapeInfo;\n}\n\nexport interface ChunkCompressor {\n\treadonly policy: ChunkPolicy;\n\t/**\n\t * If the idCompressor is provided, {@link UniformChunk}s with identifiers will be encoded for its in-memory representation.\n\t * @remarks\n\t * This compression applies to {@link UniformChunk}s when {@link TreeShape.maybeDecompressedStringAsNumber} is set.\n\t * If the `policy` does not use UniformChunks or does not set `maybeDecompressedStringAsNumber`, then no compression will be applied even when providing `idCompressor`.\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n}\n\nfunction newBasicChunkTree(\n\tcursor: ITreeCursorSynchronous,\n\tpolicy: ChunkCompressor,\n): BasicChunk {\n\treturn new BasicChunk(\n\t\tcursor.type,\n\t\tnew Map(mapCursorFields(cursor, () => [cursor.getFieldKey(), chunkField(cursor, policy)])),\n\t\tcursor.value,\n\t);\n}\n\n/**\n * Chunk a portion of a field.\n *\n * @param cursor - cursor at the starting node in the field.\n * @param policy - heuristics to impact chunking\n * @param length - how many nodes to process (at the top level). When 0, the cursor is not moved, and may be at the end of the field (and thus in Fields mode)\n * @param skipLastNavigation - if true, leaves the cursor at the last node instead of moving off of it. Invalid if length is 0.\n */\nexport function chunkRange(\n\tcursor: ITreeCursorSynchronous,\n\tchunkCompressor: ChunkCompressor,\n\tlength: number,\n\tskipLastNavigation: boolean,\n): TreeChunk[] {\n\tassert(\n\t\t!(skipLastNavigation && length === 0),\n\t\t0xb58 /* Cannot skip last navigation if length is 0 and thus last navigation already occurred. */,\n\t);\n\tassert(\n\t\t(cursor.mode === CursorLocationType.Nodes) === length > 0,\n\t\t0xb59 /* Should be in nodes mode if not past end */,\n\t);\n\tlet output: TreeChunk[] = [];\n\tlet remaining = length;\n\twhile (remaining > 0) {\n\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x57f /* should be in nodes */);\n\t\tconst start = cursor.chunkStart;\n\t\tlet reusedChunk = false;\n\t\t// symbol based fast path to check for chunk:\n\t\t// return existing chunk with a increased ref count if possible.\n\t\tif (start === cursor.fieldIndex) {\n\t\t\tconst chunkLength = cursor.chunkLength;\n\t\t\tif (chunkLength <= remaining) {\n\t\t\t\tconst chunk = tryGetChunk(cursor);\n\t\t\t\tif (chunk !== undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tchunk instanceof SequenceChunk &&\n\t\t\t\t\t\tchunk.subChunks.length <= chunkCompressor.policy.sequenceChunkInlineThreshold\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If sequence chunk, and its very short, inline it.\n\t\t\t\t\t\t// Note that this is not recursive: there may be short sequences nested below this which are not inlined.\n\t\t\t\t\t\tfor (const subChunk of chunk.subChunks) {\n\t\t\t\t\t\t\tsubChunk.referenceAdded();\n\t\t\t\t\t\t\toutput.push(subChunk);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchunk.referenceAdded();\n\t\t\t\t\toutput.push(chunk);\n\t\t\t\t\tremaining -= chunkLength;\n\t\t\t\t\treusedChunk = true;\n\t\t\t\t\tlet seek = chunkLength;\n\t\t\t\t\tif (skipLastNavigation && remaining === 0) {\n\t\t\t\t\t\tseek -= 1;\n\t\t\t\t\t}\n\t\t\t\t\tcursor.seekNodes(seek);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!reusedChunk) {\n\t\t\tassert(cursor.mode === CursorLocationType.Nodes, 0x580 /* should be in nodes */);\n\t\t\t// TODO: if provided, use schema to consider using UniformChunks\n\t\t\tconst type = cursor.type;\n\t\t\tconst shape = chunkCompressor.policy.shapeFromSchema(type);\n\t\t\tif (shape instanceof TreeShape) {\n\t\t\t\tconst nodesPerTopLevelNode = shape.positions.length;\n\t\t\t\tconst maxTopLevelLength = Math.ceil(\n\t\t\t\t\tnodesPerTopLevelNode / chunkCompressor.policy.uniformChunkNodeCount,\n\t\t\t\t);\n\t\t\t\tconst maxLength = Math.min(maxTopLevelLength, remaining);\n\t\t\t\tconst newChunk = uniformChunkFromCursor(\n\t\t\t\t\tcursor,\n\t\t\t\t\tshape,\n\t\t\t\t\tmaxLength,\n\t\t\t\t\tmaxLength === remaining && skipLastNavigation,\n\t\t\t\t\tchunkCompressor.idCompressor,\n\t\t\t\t);\n\t\t\t\tremaining -= newChunk.topLevelLength;\n\t\t\t\toutput.push(newChunk);\n\t\t\t} else {\n\t\t\t\t// Slow path: copy tree into new basic chunk\n\t\t\t\toutput.push(newBasicChunkTree(cursor, chunkCompressor));\n\t\t\t\tremaining -= 1;\n\t\t\t\tif (!skipLastNavigation || remaining !== 0) {\n\t\t\t\t\tcursor.nextNode();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: maybe make a pass over output to coalesce UniformChunks and/or convert other formats to UniformChunks where possible.\n\n\t// If output is large, group it into a tree of sequence chunks.\n\twhile (output.length > chunkCompressor.policy.sequenceChunkSplitThreshold) {\n\t\tconst chunkCount = Math.ceil(\n\t\t\toutput.length / chunkCompressor.policy.sequenceChunkSplitThreshold,\n\t\t);\n\t\tconst newOutput: TreeChunk[] = [];\n\t\t// Rounding down, and add an extra item to some of the chunks.\n\t\tconst chunkSize = Math.floor(output.length / chunkCount);\n\t\t// number of chunks to add an extra item to to make total line up.\n\t\tconst extra = output.length % chunkCount;\n\t\tlet previousEnd = 0;\n\t\tfor (let index = 0; index < chunkCount; index++) {\n\t\t\t// If we are in the first `extra` items, add an extra to this chunk.\n\t\t\tconst end = previousEnd + chunkSize + (index < extra ? 1 : 0);\n\t\t\tnewOutput.push(new SequenceChunk(output.slice(previousEnd, end)));\n\t\t\tpreviousEnd = end;\n\t\t}\n\t\tassert(previousEnd === output.length, 0x581 /* chunks should add up to total */);\n\t\toutput = newOutput;\n\t}\n\n\treturn output;\n}\n/**\n * Extracts values from the current cursor position according to the provided tree shape.\n *\n * Walks through the tree structure defined by the shape, extracting values from leaf nodes\n * and recursively processing child fields. If an ID compressor is provided, compressible\n * string values (stable node identifiers) will be recompressed for optimal storage.\n *\n * @param cursor - Tree cursor positioned at the node to extract values from\n * @param shape - The tree shape defining the structure to extract\n * @param values - Array to append the extracted values to\n * @param idCompressor - Optional compressor used to encode string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function insertValues(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tvalues: Value[],\n\tidCompressor?: IIdCompressor,\n): void {\n\tassert(shape.type === cursor.type, 0x582 /* shape and type must match */);\n\n\t// TODO:Perf:\n\t// Fast path for already part of a uniform chunk with matching shape\n\n\t// Slow path: walk shape and cursor together, inserting values.\n\tif (shape.hasValue) {\n\t\tif (\n\t\t\ttypeof cursor.value === \"string\" &&\n\t\t\tidCompressor !== undefined &&\n\t\t\tisStableNodeIdentifier(cursor.value)\n\t\t) {\n\t\t\tvalues.push(idCompressor.tryRecompress(cursor.value) ?? cursor.value);\n\t\t} else {\n\t\t\tvalues.push(cursor.value);\n\t\t}\n\t}\n\tfor (const [key, childShape, length] of shape.fieldsArray) {\n\t\tcursor.enterField(key);\n\t\tlet count = 0;\n\t\tfor (let inNodes = cursor.firstNode(); inNodes; inNodes = cursor.nextNode()) {\n\t\t\tinsertValues(cursor, childShape, values, idCompressor);\n\t\t\tcount++;\n\t\t}\n\t\tcursor.exitField();\n\t\tassert(length === count, 0x583 /* unexpected field length */);\n\t}\n}\n\n/**\n * Read up to `maxTopLevelLength` nodes from `cursor`, stopping when limit is hit or type of node changes.\n *\n * This requires that the all trees with matching type match the provided shape.\n * This cannot be used if other shapes are possible for this type.\n *\n * If this stops early due to the type changing, `skipLastNavigation` is not involved:\n * `skipLastNavigation` only determines if the cursor will be left on the node after the last one (possibly exiting the field)\n * if the full length is used.\n *\n * @param idCompressor - compressor used to encoded string values that are compressible by the idCompressor for in-memory representation.\n * If the idCompressor is not provided, the values will be the original uncompressed values.\n */\nexport function uniformChunkFromCursor(\n\tcursor: ITreeCursorSynchronous,\n\tshape: TreeShape,\n\tmaxTopLevelLength: number,\n\tskipLastNavigation: boolean,\n\tidCompressor?: IIdCompressor,\n): UniformChunk {\n\t// TODO:\n\t// This could have a fast path for consuming already uniformly chunked data with matching shape.\n\n\tconst values: TreeValue[] = [];\n\tlet topLevelLength = 1;\n\twhile (topLevelLength <= maxTopLevelLength) {\n\t\tinsertValues(cursor, shape, values, idCompressor);\n\t\tif (topLevelLength === maxTopLevelLength) {\n\t\t\tif (!skipLastNavigation) {\n\t\t\t\tcursor.nextNode();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcursor.nextNode();\n\t\tif (cursor.type !== shape.type) {\n\t\t\tbreak;\n\t\t}\n\t\ttopLevelLength += 1;\n\t}\n\treturn new UniformChunk(shape.withTopLevelLength(topLevelLength), values, idCompressor);\n}\n"]}