@fluidframework/tree 2.51.0 → 2.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (579) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/CHANGELOG.md +43 -0
  3. package/api-report/tree.alpha.api.md +3 -2
  4. package/dist/codec/codec.d.ts +2 -1
  5. package/dist/codec/codec.d.ts.map +1 -1
  6. package/dist/codec/codec.js +4 -3
  7. package/dist/codec/codec.js.map +1 -1
  8. package/dist/core/index.d.ts +1 -1
  9. package/dist/core/index.d.ts.map +1 -1
  10. package/dist/core/index.js +3 -2
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/core/rebase/index.d.ts +1 -1
  13. package/dist/core/rebase/index.d.ts.map +1 -1
  14. package/dist/core/rebase/index.js +2 -1
  15. package/dist/core/rebase/index.js.map +1 -1
  16. package/dist/core/rebase/types.d.ts +3 -1
  17. package/dist/core/rebase/types.d.ts.map +1 -1
  18. package/dist/core/rebase/types.js +2 -1
  19. package/dist/core/rebase/types.js.map +1 -1
  20. package/dist/core/schema-stored/schema.d.ts +1 -23
  21. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  22. package/dist/core/schema-stored/schema.js +2 -2
  23. package/dist/core/schema-stored/schema.js.map +1 -1
  24. package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
  25. package/dist/core/tree/detachedFieldIndex.js +2 -3
  26. package/dist/core/tree/detachedFieldIndex.js.map +1 -1
  27. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  28. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  29. package/dist/core/tree/detachedFieldIndexCodecCommon.js +68 -0
  30. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  31. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  32. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  33. package/dist/core/tree/detachedFieldIndexCodecV1.js +55 -0
  34. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  35. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  36. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  37. package/dist/core/tree/detachedFieldIndexCodecV2.js +49 -0
  38. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  39. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  40. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  41. package/dist/core/tree/detachedFieldIndexCodecs.js +26 -0
  42. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  43. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  44. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  45. package/dist/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +18 -13
  46. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  47. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  48. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  49. package/dist/core/tree/detachedFieldIndexFormatV1.js +12 -0
  50. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  51. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  52. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  53. package/dist/core/tree/detachedFieldIndexFormatV2.js +14 -0
  54. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  55. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  56. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  57. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +21 -21
  58. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  60. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  62. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  64. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +74 -61
  66. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  68. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/format.js +18 -12
  70. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  71. package/{lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts → dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  72. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  73. package/dist/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +23 -17
  74. package/dist/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  75. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  76. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  77. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +22 -22
  78. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  79. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  80. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  81. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  82. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  83. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
  84. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  85. package/dist/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  86. package/dist/feature-libraries/default-schema/defaultSchema.js +0 -2
  87. package/dist/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  88. package/dist/feature-libraries/default-schema/index.d.ts +1 -1
  89. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  90. package/dist/feature-libraries/default-schema/index.js +2 -2
  91. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  92. package/dist/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  93. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  94. package/dist/feature-libraries/default-schema/schemaChecker.js +31 -26
  95. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  96. package/dist/feature-libraries/index.d.ts +1 -2
  97. package/dist/feature-libraries/index.d.ts.map +1 -1
  98. package/dist/feature-libraries/index.js +2 -4
  99. package/dist/feature-libraries/index.js.map +1 -1
  100. package/dist/feature-libraries/modular-schema/comparison.d.ts +5 -6
  101. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  102. package/dist/feature-libraries/modular-schema/comparison.js +15 -16
  103. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  104. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  105. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  106. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  107. package/dist/feature-libraries/object-forest/objectForest.js +2 -3
  108. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  109. package/dist/index.d.ts +1 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +6 -2
  112. package/dist/index.js.map +1 -1
  113. package/dist/packageVersion.d.ts +1 -1
  114. package/dist/packageVersion.js +1 -1
  115. package/dist/packageVersion.js.map +1 -1
  116. package/dist/shared-tree/independentView.d.ts +8 -0
  117. package/dist/shared-tree/independentView.d.ts.map +1 -1
  118. package/dist/shared-tree/independentView.js +23 -11
  119. package/dist/shared-tree/independentView.js.map +1 -1
  120. package/dist/shared-tree/schematizeTree.js +1 -1
  121. package/dist/shared-tree/schematizeTree.js.map +1 -1
  122. package/dist/shared-tree/schematizingTreeView.d.ts +0 -1
  123. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  124. package/dist/shared-tree/schematizingTreeView.js +7 -10
  125. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  126. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  127. package/dist/shared-tree/sharedTree.js +1 -29
  128. package/dist/shared-tree/sharedTree.js.map +1 -1
  129. package/dist/shared-tree/treeAlpha.d.ts +20 -6
  130. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  131. package/dist/shared-tree/treeAlpha.js +9 -4
  132. package/dist/shared-tree/treeAlpha.js.map +1 -1
  133. package/dist/shared-tree/treeCheckout.d.ts +2 -1
  134. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  135. package/dist/shared-tree/treeCheckout.js +32 -0
  136. package/dist/shared-tree/treeCheckout.js.map +1 -1
  137. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  138. package/dist/shared-tree-core/branch.js +1 -1
  139. package/dist/shared-tree-core/branch.js.map +1 -1
  140. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  141. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  142. package/dist/simple-tree/api/conciseTree.js +6 -6
  143. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  144. package/dist/simple-tree/api/configuration.d.ts +8 -2
  145. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  146. package/dist/simple-tree/api/configuration.js.map +1 -1
  147. package/dist/simple-tree/api/create.d.ts +8 -7
  148. package/dist/simple-tree/api/create.d.ts.map +1 -1
  149. package/dist/simple-tree/api/create.js +35 -22
  150. package/dist/simple-tree/api/create.js.map +1 -1
  151. package/dist/simple-tree/api/customTree.d.ts +25 -4
  152. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  153. package/dist/simple-tree/api/customTree.js +42 -16
  154. package/dist/simple-tree/api/customTree.js.map +1 -1
  155. package/dist/simple-tree/api/discrepancies.d.ts +98 -0
  156. package/dist/simple-tree/api/discrepancies.d.ts.map +1 -0
  157. package/dist/simple-tree/api/discrepancies.js +255 -0
  158. package/dist/simple-tree/api/discrepancies.js.map +1 -0
  159. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  160. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  161. package/dist/simple-tree/api/schemaCompatibilityTester.js +18 -117
  162. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  163. package/dist/simple-tree/api/schemaFactory.d.ts +7 -4
  164. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  165. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  166. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  167. package/dist/simple-tree/api/storedSchema.js +5 -1
  168. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  169. package/dist/simple-tree/api/treeBeta.d.ts +2 -2
  170. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  171. package/dist/simple-tree/api/treeBeta.js +10 -4
  172. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  173. package/dist/simple-tree/api/verboseTree.d.ts +2 -2
  174. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  175. package/dist/simple-tree/api/verboseTree.js +15 -15
  176. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  177. package/dist/simple-tree/core/allowedTypes.d.ts +20 -4
  178. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  179. package/dist/simple-tree/core/allowedTypes.js +45 -13
  180. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  181. package/dist/simple-tree/core/context.d.ts +13 -2
  182. package/dist/simple-tree/core/context.d.ts.map +1 -1
  183. package/dist/simple-tree/core/context.js +22 -9
  184. package/dist/simple-tree/core/context.js.map +1 -1
  185. package/dist/simple-tree/core/index.d.ts +2 -2
  186. package/dist/simple-tree/core/index.d.ts.map +1 -1
  187. package/dist/simple-tree/core/index.js +3 -1
  188. package/dist/simple-tree/core/index.js.map +1 -1
  189. package/dist/simple-tree/core/treeNodeKernel.d.ts +1 -1
  190. package/dist/simple-tree/core/treeNodeKernel.js +1 -1
  191. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  192. package/dist/simple-tree/core/treeNodeValid.d.ts +1 -1
  193. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  194. package/dist/simple-tree/core/treeNodeValid.js +8 -1
  195. package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
  196. package/dist/simple-tree/core/walkSchema.d.ts +3 -0
  197. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  198. package/dist/simple-tree/core/walkSchema.js +2 -0
  199. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  200. package/dist/simple-tree/createContext.d.ts +2 -0
  201. package/dist/simple-tree/createContext.d.ts.map +1 -1
  202. package/dist/simple-tree/createContext.js +3 -1
  203. package/dist/simple-tree/createContext.js.map +1 -1
  204. package/dist/simple-tree/fieldSchema.d.ts +1 -0
  205. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  206. package/dist/simple-tree/fieldSchema.js +1 -0
  207. package/dist/simple-tree/fieldSchema.js.map +1 -1
  208. package/dist/simple-tree/index.d.ts +4 -4
  209. package/dist/simple-tree/index.d.ts.map +1 -1
  210. package/dist/simple-tree/index.js +7 -8
  211. package/dist/simple-tree/index.js.map +1 -1
  212. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  213. package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
  214. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  215. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  216. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  217. package/dist/simple-tree/node-kinds/index.js +1 -2
  218. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  219. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  220. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  221. package/dist/simple-tree/node-kinds/object/index.js +1 -2
  222. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  223. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
  224. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  225. package/dist/simple-tree/node-kinds/object/objectNode.js +4 -18
  226. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  227. package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
  228. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  229. package/dist/simple-tree/prepareForInsertion.js +9 -3
  230. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  231. package/dist/simple-tree/toStoredSchema.d.ts +3 -0
  232. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  233. package/dist/simple-tree/toStoredSchema.js +3 -0
  234. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  235. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  236. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  237. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  238. package/dist/simple-tree/walkFieldSchema.d.ts +1 -0
  239. package/dist/simple-tree/walkFieldSchema.d.ts.map +1 -1
  240. package/dist/simple-tree/walkFieldSchema.js +1 -0
  241. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  242. package/lib/codec/codec.d.ts +2 -1
  243. package/lib/codec/codec.d.ts.map +1 -1
  244. package/lib/codec/codec.js +4 -3
  245. package/lib/codec/codec.js.map +1 -1
  246. package/lib/core/index.d.ts +1 -1
  247. package/lib/core/index.d.ts.map +1 -1
  248. package/lib/core/index.js +1 -1
  249. package/lib/core/index.js.map +1 -1
  250. package/lib/core/rebase/index.d.ts +1 -1
  251. package/lib/core/rebase/index.d.ts.map +1 -1
  252. package/lib/core/rebase/index.js +1 -1
  253. package/lib/core/rebase/index.js.map +1 -1
  254. package/lib/core/rebase/types.d.ts +3 -1
  255. package/lib/core/rebase/types.d.ts.map +1 -1
  256. package/lib/core/rebase/types.js +1 -0
  257. package/lib/core/rebase/types.js.map +1 -1
  258. package/lib/core/schema-stored/schema.d.ts +1 -23
  259. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  260. package/lib/core/schema-stored/schema.js +2 -2
  261. package/lib/core/schema-stored/schema.js.map +1 -1
  262. package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
  263. package/lib/core/tree/detachedFieldIndex.js +2 -3
  264. package/lib/core/tree/detachedFieldIndex.js.map +1 -1
  265. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +17 -0
  266. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -0
  267. package/lib/core/tree/detachedFieldIndexCodecCommon.js +64 -0
  268. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -0
  269. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +11 -0
  270. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -0
  271. package/lib/core/tree/detachedFieldIndexCodecV1.js +51 -0
  272. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -0
  273. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +11 -0
  274. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -0
  275. package/lib/core/tree/detachedFieldIndexCodecV2.js +45 -0
  276. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -0
  277. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +11 -0
  278. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -0
  279. package/lib/core/tree/detachedFieldIndexCodecs.js +21 -0
  280. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -0
  281. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +37 -0
  282. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -0
  283. package/lib/core/tree/{detachedFieldIndexFormat.js → detachedFieldIndexFormatCommon.js} +13 -10
  284. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -0
  285. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +13 -0
  286. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -0
  287. package/lib/core/tree/detachedFieldIndexFormatV1.js +9 -0
  288. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -0
  289. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +14 -0
  290. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -0
  291. package/lib/core/tree/detachedFieldIndexFormatV2.js +11 -0
  292. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -0
  293. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +9 -9
  294. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  295. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +19 -19
  296. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  297. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +4 -2
  298. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  299. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +4 -4
  300. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  301. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +50 -31
  302. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +70 -57
  304. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  305. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +20 -14
  306. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  307. package/lib/feature-libraries/chunked-forest/codec/format.js +17 -11
  308. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  309. package/{dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts → lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts} +20 -14
  310. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.d.ts.map +1 -0
  311. package/lib/feature-libraries/chunked-forest/codec/{nodeShape.js → nodeEncoder.js} +21 -15
  312. package/lib/feature-libraries/chunked-forest/codec/nodeEncoder.js.map +1 -0
  313. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +7 -7
  314. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +19 -19
  316. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  318. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  319. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
  320. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  321. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +14 -2
  322. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  323. package/lib/feature-libraries/default-schema/defaultSchema.d.ts.map +1 -1
  324. package/lib/feature-libraries/default-schema/defaultSchema.js +0 -2
  325. package/lib/feature-libraries/default-schema/defaultSchema.js.map +1 -1
  326. package/lib/feature-libraries/default-schema/index.d.ts +1 -1
  327. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  328. package/lib/feature-libraries/default-schema/index.js +1 -1
  329. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  330. package/lib/feature-libraries/default-schema/schemaChecker.d.ts +14 -4
  331. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  332. package/lib/feature-libraries/default-schema/schemaChecker.js +29 -24
  333. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  334. package/lib/feature-libraries/index.d.ts +1 -2
  335. package/lib/feature-libraries/index.d.ts.map +1 -1
  336. package/lib/feature-libraries/index.js +1 -2
  337. package/lib/feature-libraries/index.js.map +1 -1
  338. package/lib/feature-libraries/modular-schema/comparison.d.ts +5 -6
  339. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  340. package/lib/feature-libraries/modular-schema/comparison.js +14 -14
  341. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  342. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -3
  343. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  344. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  345. package/lib/feature-libraries/object-forest/objectForest.js +3 -4
  346. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  347. package/lib/index.d.ts +1 -1
  348. package/lib/index.d.ts.map +1 -1
  349. package/lib/index.js +2 -2
  350. package/lib/index.js.map +1 -1
  351. package/lib/packageVersion.d.ts +1 -1
  352. package/lib/packageVersion.js +1 -1
  353. package/lib/packageVersion.js.map +1 -1
  354. package/lib/shared-tree/independentView.d.ts +8 -0
  355. package/lib/shared-tree/independentView.d.ts.map +1 -1
  356. package/lib/shared-tree/independentView.js +21 -10
  357. package/lib/shared-tree/independentView.js.map +1 -1
  358. package/lib/shared-tree/schematizeTree.js +1 -1
  359. package/lib/shared-tree/schematizeTree.js.map +1 -1
  360. package/lib/shared-tree/schematizingTreeView.d.ts +0 -1
  361. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  362. package/lib/shared-tree/schematizingTreeView.js +8 -11
  363. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  364. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  365. package/lib/shared-tree/sharedTree.js +2 -30
  366. package/lib/shared-tree/sharedTree.js.map +1 -1
  367. package/lib/shared-tree/treeAlpha.d.ts +20 -6
  368. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  369. package/lib/shared-tree/treeAlpha.js +10 -5
  370. package/lib/shared-tree/treeAlpha.js.map +1 -1
  371. package/lib/shared-tree/treeCheckout.d.ts +2 -1
  372. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  373. package/lib/shared-tree/treeCheckout.js +33 -1
  374. package/lib/shared-tree/treeCheckout.js.map +1 -1
  375. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  376. package/lib/shared-tree-core/branch.js +1 -1
  377. package/lib/shared-tree-core/branch.js.map +1 -1
  378. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  379. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  380. package/lib/simple-tree/api/conciseTree.js +6 -6
  381. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  382. package/lib/simple-tree/api/configuration.d.ts +8 -2
  383. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  384. package/lib/simple-tree/api/configuration.js.map +1 -1
  385. package/lib/simple-tree/api/create.d.ts +8 -7
  386. package/lib/simple-tree/api/create.d.ts.map +1 -1
  387. package/lib/simple-tree/api/create.js +38 -25
  388. package/lib/simple-tree/api/create.js.map +1 -1
  389. package/lib/simple-tree/api/customTree.d.ts +25 -4
  390. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  391. package/lib/simple-tree/api/customTree.js +43 -17
  392. package/lib/simple-tree/api/customTree.js.map +1 -1
  393. package/lib/simple-tree/api/discrepancies.d.ts +98 -0
  394. package/lib/simple-tree/api/discrepancies.d.ts.map +1 -0
  395. package/lib/simple-tree/{discrepancies.js → api/discrepancies.js} +80 -206
  396. package/lib/simple-tree/api/discrepancies.js.map +1 -0
  397. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +9 -7
  398. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  399. package/lib/simple-tree/api/schemaCompatibilityTester.js +19 -118
  400. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  401. package/lib/simple-tree/api/schemaFactory.d.ts +7 -4
  402. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  403. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  404. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  405. package/lib/simple-tree/api/storedSchema.js +6 -2
  406. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  407. package/lib/simple-tree/api/treeBeta.d.ts +2 -2
  408. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  409. package/lib/simple-tree/api/treeBeta.js +8 -2
  410. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  411. package/lib/simple-tree/api/verboseTree.d.ts +2 -2
  412. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  413. package/lib/simple-tree/api/verboseTree.js +9 -9
  414. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  415. package/lib/simple-tree/core/allowedTypes.d.ts +20 -4
  416. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  417. package/lib/simple-tree/core/allowedTypes.js +42 -12
  418. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  419. package/lib/simple-tree/core/context.d.ts +13 -2
  420. package/lib/simple-tree/core/context.d.ts.map +1 -1
  421. package/lib/simple-tree/core/context.js +22 -9
  422. package/lib/simple-tree/core/context.js.map +1 -1
  423. package/lib/simple-tree/core/index.d.ts +2 -2
  424. package/lib/simple-tree/core/index.d.ts.map +1 -1
  425. package/lib/simple-tree/core/index.js +2 -2
  426. package/lib/simple-tree/core/index.js.map +1 -1
  427. package/lib/simple-tree/core/treeNodeKernel.d.ts +1 -1
  428. package/lib/simple-tree/core/treeNodeKernel.js +1 -1
  429. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  430. package/lib/simple-tree/core/treeNodeValid.d.ts +1 -1
  431. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
  432. package/lib/simple-tree/core/treeNodeValid.js +8 -1
  433. package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
  434. package/lib/simple-tree/core/walkSchema.d.ts +3 -0
  435. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  436. package/lib/simple-tree/core/walkSchema.js +2 -0
  437. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  438. package/lib/simple-tree/createContext.d.ts +2 -0
  439. package/lib/simple-tree/createContext.d.ts.map +1 -1
  440. package/lib/simple-tree/createContext.js +3 -1
  441. package/lib/simple-tree/createContext.js.map +1 -1
  442. package/lib/simple-tree/fieldSchema.d.ts +1 -0
  443. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  444. package/lib/simple-tree/fieldSchema.js +1 -0
  445. package/lib/simple-tree/fieldSchema.js.map +1 -1
  446. package/lib/simple-tree/index.d.ts +4 -4
  447. package/lib/simple-tree/index.d.ts.map +1 -1
  448. package/lib/simple-tree/index.js +4 -4
  449. package/lib/simple-tree/index.js.map +1 -1
  450. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  451. package/lib/simple-tree/node-kinds/array/arrayNode.js +1 -1
  452. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  453. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  454. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  455. package/lib/simple-tree/node-kinds/index.js +1 -1
  456. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  457. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  458. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  459. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  460. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  461. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -7
  462. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  463. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -16
  464. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  465. package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
  466. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  467. package/lib/simple-tree/prepareForInsertion.js +11 -5
  468. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  469. package/lib/simple-tree/toStoredSchema.d.ts +3 -0
  470. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  471. package/lib/simple-tree/toStoredSchema.js +3 -0
  472. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  473. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +2 -2
  474. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  475. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +1 -1
  476. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  477. package/lib/simple-tree/walkFieldSchema.d.ts +1 -0
  478. package/lib/simple-tree/walkFieldSchema.d.ts.map +1 -1
  479. package/lib/simple-tree/walkFieldSchema.js +1 -0
  480. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  481. package/package.json +23 -23
  482. package/src/codec/codec.ts +4 -3
  483. package/src/core/index.ts +2 -0
  484. package/src/core/rebase/index.ts +2 -0
  485. package/src/core/rebase/types.ts +4 -0
  486. package/src/core/schema-stored/schema.ts +2 -26
  487. package/src/core/tree/detachedFieldIndex.ts +4 -6
  488. package/src/core/tree/detachedFieldIndexCodecCommon.ts +87 -0
  489. package/src/core/tree/{detachedFieldIndexCodec.ts → detachedFieldIndexCodecV1.ts} +22 -68
  490. package/src/core/tree/detachedFieldIndexCodecV2.ts +72 -0
  491. package/src/core/tree/detachedFieldIndexCodecs.ts +44 -0
  492. package/src/core/tree/{detachedFieldIndexFormat.ts → detachedFieldIndexFormatCommon.ts} +32 -23
  493. package/src/core/tree/detachedFieldIndexFormatV1.ts +15 -0
  494. package/src/core/tree/detachedFieldIndexFormatV2.ts +17 -0
  495. package/src/feature-libraries/chunked-forest/codec/README.md +1 -1
  496. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +25 -25
  497. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -6
  498. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +96 -73
  499. package/src/feature-libraries/chunked-forest/codec/format.ts +20 -14
  500. package/src/feature-libraries/chunked-forest/codec/{nodeShape.ts → nodeEncoder.ts} +23 -17
  501. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +34 -34
  502. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +5 -5
  503. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +10 -0
  504. package/src/feature-libraries/default-schema/defaultSchema.ts +0 -2
  505. package/src/feature-libraries/default-schema/index.ts +1 -1
  506. package/src/feature-libraries/default-schema/schemaChecker.ts +47 -30
  507. package/src/feature-libraries/index.ts +1 -3
  508. package/src/feature-libraries/modular-schema/comparison.ts +14 -29
  509. package/src/feature-libraries/object-forest/objectForest.ts +10 -6
  510. package/src/index.ts +5 -0
  511. package/src/packageVersion.ts +1 -1
  512. package/src/shared-tree/independentView.ts +45 -19
  513. package/src/shared-tree/schematizeTree.ts +1 -1
  514. package/src/shared-tree/schematizingTreeView.ts +16 -13
  515. package/src/shared-tree/sharedTree.ts +2 -42
  516. package/src/shared-tree/treeAlpha.ts +30 -18
  517. package/src/shared-tree/treeCheckout.ts +54 -10
  518. package/src/shared-tree-core/branch.ts +1 -6
  519. package/src/simple-tree/api/conciseTree.ts +9 -7
  520. package/src/simple-tree/api/configuration.ts +8 -2
  521. package/src/simple-tree/api/create.ts +49 -36
  522. package/src/simple-tree/api/customTree.ts +59 -20
  523. package/src/simple-tree/{discrepancies.ts → api/discrepancies.ts} +128 -303
  524. package/src/simple-tree/api/schemaCompatibilityTester.ts +27 -151
  525. package/src/simple-tree/api/schemaFactory.ts +7 -4
  526. package/src/simple-tree/api/storedSchema.ts +6 -9
  527. package/src/simple-tree/api/treeBeta.ts +17 -4
  528. package/src/simple-tree/api/verboseTree.ts +17 -8
  529. package/src/simple-tree/core/allowedTypes.ts +54 -21
  530. package/src/simple-tree/core/context.ts +24 -22
  531. package/src/simple-tree/core/index.ts +2 -1
  532. package/src/simple-tree/core/treeNodeKernel.ts +1 -1
  533. package/src/simple-tree/core/treeNodeValid.ts +9 -2
  534. package/src/simple-tree/core/walkSchema.ts +3 -0
  535. package/src/simple-tree/createContext.ts +6 -1
  536. package/src/simple-tree/fieldSchema.ts +1 -0
  537. package/src/simple-tree/index.ts +5 -10
  538. package/src/simple-tree/node-kinds/array/arrayNode.ts +32 -19
  539. package/src/simple-tree/node-kinds/index.ts +0 -1
  540. package/src/simple-tree/node-kinds/object/index.ts +0 -1
  541. package/src/simple-tree/node-kinds/object/objectNode.ts +9 -27
  542. package/src/simple-tree/prepareForInsertion.ts +17 -9
  543. package/src/simple-tree/toStoredSchema.ts +3 -0
  544. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +6 -2
  545. package/src/simple-tree/walkFieldSchema.ts +1 -0
  546. package/dist/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  547. package/dist/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  548. package/dist/core/tree/detachedFieldIndexCodec.js +0 -100
  549. package/dist/core/tree/detachedFieldIndexCodec.js.map +0 -1
  550. package/dist/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  551. package/dist/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  552. package/dist/core/tree/detachedFieldIndexFormat.js.map +0 -1
  553. package/dist/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  554. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  555. package/dist/feature-libraries/initializeForest.d.ts +0 -18
  556. package/dist/feature-libraries/initializeForest.d.ts.map +0 -1
  557. package/dist/feature-libraries/initializeForest.js +0 -35
  558. package/dist/feature-libraries/initializeForest.js.map +0 -1
  559. package/dist/simple-tree/discrepancies.d.ts +0 -167
  560. package/dist/simple-tree/discrepancies.d.ts.map +0 -1
  561. package/dist/simple-tree/discrepancies.js +0 -382
  562. package/dist/simple-tree/discrepancies.js.map +0 -1
  563. package/lib/core/tree/detachedFieldIndexCodec.d.ts +0 -11
  564. package/lib/core/tree/detachedFieldIndexCodec.d.ts.map +0 -1
  565. package/lib/core/tree/detachedFieldIndexCodec.js +0 -96
  566. package/lib/core/tree/detachedFieldIndexCodec.js.map +0 -1
  567. package/lib/core/tree/detachedFieldIndexFormat.d.ts +0 -33
  568. package/lib/core/tree/detachedFieldIndexFormat.d.ts.map +0 -1
  569. package/lib/core/tree/detachedFieldIndexFormat.js.map +0 -1
  570. package/lib/feature-libraries/chunked-forest/codec/nodeShape.d.ts.map +0 -1
  571. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +0 -1
  572. package/lib/feature-libraries/initializeForest.d.ts +0 -18
  573. package/lib/feature-libraries/initializeForest.d.ts.map +0 -1
  574. package/lib/feature-libraries/initializeForest.js +0 -31
  575. package/lib/feature-libraries/initializeForest.js.map +0 -1
  576. package/lib/simple-tree/discrepancies.d.ts +0 -167
  577. package/lib/simple-tree/discrepancies.d.ts.map +0 -1
  578. package/lib/simple-tree/discrepancies.js.map +0 -1
  579. package/src/feature-libraries/initializeForest.ts +0 -55
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/core/schema-stored/schema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA2D;AAE3D,mDAAoE;AACpE,kDAK6B;AAE7B,+CAOuB;AASvB;;GAEG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB,6CAAM,CAAA;IACN;;OAEG;IACH,6CAAM,CAAA;AACP,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB;AAID;;;;;;;;GAQG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,iDAAM,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AAC,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 JsonCompatibleReadOnlyObject,\n\ttype MakeNominal,\n\tbrand,\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 enum SchemaVersion {\n\tv1 = 1,\n\t/**\n\t * Adds persisted metadata to the node schema and field schema.\n\t */\n\tv2 = 2,\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 *\n * TODO: AB#43546\n * Some additional data which is not needed to define compatibility with a given stored schema is currently included here, and should be removed.\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\t/**\n\t * If true, new content inserted into the tree should be validated against the stored schema.\n\t * @remarks\n\t * TODO: AB#43546: This is not information used to interpret the stored schema: this configuration should be moved elsewhere.\n\t */\n\treadonly validateSchema: boolean;\n\n\t/**\n\t * Whether to allow a document to be opened when a particular stored schema (identified by `identifier`)\n\t * contains optional fields that are not known to the view schema.\n\t *\n\t * @privateRemarks\n\t * Plumbing this in via `SchemaPolicy` avoids needing to walk the view schema representation repeatedly in places\n\t * that need it (schema validation, view vs stored compatibility checks).\n\t *\n\t * TODO: AB#43546\n\t * This is not information used to interpret the stored schema: it is instead about view schema, and how compatible they are with a stored schema.\n\t * SchemaCompatibilityTester should be updated to not store this table in here, and then this field should be removed.\n\t */\n\tallowUnknownOptionalFields(identifier: TreeNodeSchemaIdentifier): boolean;\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 = \"Forbidden\";\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: brand(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 -\n\t * 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 -\n\t * 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 -\n\t * 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,kDAK6B;AAE7B,+CAOuB;AASvB;;GAEG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACxB,6CAAM,CAAA;IACN;;OAEG;IACH,6CAAM,CAAA;AACP,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB;AAID;;;;;;;;GAQG;AACH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,iDAAM,CAAA;IACN,iDAAM,CAAA;IACN,mDAAO,CAAA;IACP,2DAAW,CAAA;IACX,6CAAI,CAAA;AACL,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AAwFD;;;;;;;;;GASG;AACU,QAAA,4BAA4B,GAAwB,IAAA,gBAAK,EAAC,WAAW,CAAC,CAAC;AAEpF;;;GAGG;AACU,QAAA,sBAAsB,GAA0B;IAC5D,4CAA4C;IAC5C,IAAI,E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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 JsonCompatibleReadOnlyObject,\n\ttype MakeNominal,\n\tbrand,\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 enum SchemaVersion {\n\tv1 = 1,\n\t/**\n\t * Adds persisted metadata to the node schema and field schema.\n\t */\n\tv2 = 2,\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: FieldKindIdentifier = brand(\"Forbidden\");\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 -\n\t * 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 -\n\t * 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 -\n\t * 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":"detachedFieldIndex.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACN,KAAK,iBAAiB,EAItB,MAAM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E,EAAE,KAAK,CAAC,cAAc,GAAG,YAAY;IAMvD;;OAEG;IACK,6BAA6B,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC;IAOpF;;OAEG;IACI,gCAAgC,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAiB7D,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI;IAWtD;;;;;;;OAOG;IACI,WAAW,CACjB,MAAM,CAAC,EAAE,KAAK,CAAC,cAAc,EAC7B,QAAQ,CAAC,EAAE,WAAW,EACtB,KAAK,GAAE,MAAU,GACf,YAAY;IAmBf;;OAEG;IACI,oBAAoB,CAC1B,EAAE,EAAE,KAAK,CAAC,cAAc,EACxB,QAAQ,EAAE,WAAW,GAAG,SAAS,GAC/B,IAAI;IAmBA,MAAM,IAAI,sBAAsB;IAOvC;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAmBnD;;;;OAIG;IACI,yBAAyB,CAAC,cAAc,EAAE,WAAW,GAAG,IAAI;CAqBnE"}
@@ -8,7 +8,7 @@ exports.DetachedFieldIndex = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const index_js_1 = require("../../codec/index.js");
10
10
  const index_js_2 = require("../../util/index.js");
11
- const detachedFieldIndexCodec_js_1 = require("./detachedFieldIndexCodec.js");
11
+ const detachedFieldIndexCodecs_js_1 = require("./detachedFieldIndexCodecs.js");
12
12
  /**
13
13
  * The tree index records detached field IDs and associates them with a change atom ID.
14
14
  */
@@ -47,8 +47,7 @@ class DetachedFieldIndex {
47
47
  jsonValidator: index_js_1.noopValidator,
48
48
  oldestCompatibleClient: index_js_1.FluidClientVersion.v2_0,
49
49
  };
50
- // TODO: this should take in CodecWriteOptions, and use it to pick the write version.
51
- this.codec = (0, detachedFieldIndexCodec_js_1.makeDetachedNodeToFieldCodec)(revisionTagCodec, this.options, idCompressor);
50
+ this.codec = (0, detachedFieldIndexCodecs_js_1.makeDetachedFieldIndexCodec)(revisionTagCodec, this.options, idCompressor);
52
51
  }
53
52
  clone() {
54
53
  const clone = new DetachedFieldIndex(this.name, (0, index_js_2.idAllocatorFromMaxId)(this.rootIdAllocator.getMaxId()), this.revisionTagCodec, this.idCompressor, this.options);
@@ -1 +1 @@
1
- {"version":3,"file":"detachedFieldIndex.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,mDAK8B;AAC9B,kDAW6B;AAK7B,6EAA4E;AAU5E;;GAEG;AACH,MAAa,kBAAkB;IA+B9B;;;OAGG;IACH,YACkB,IAAY,EACrB,eAA0C,EACjC,gBAAkC,EAClC,YAA2B,EAC5C,OAA2B;QAJV,SAAI,GAAJ,IAAI,CAAQ;QACrB,oBAAe,GAAf,eAAe,CAA2B;QACjC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,iBAAY,GAAZ,YAAY,CAAe;QAtC7C;;WAEG;QACK,wBAAmB,GAA2C,IAAI,GAAG,EAAE,CAAC;QAChF;;;;;;WAMG;QACK,mCAA8B,GAIlC,IAAI,GAAG,EAAE,CAAC;QAKd;;;;;;;WAOG;QACK,kBAAa,GAAG,IAAI,CAAC;QAa5B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI;YACzB,aAAa,EAAE,wBAAa;YAC5B,sBAAsB,EAAE,6BAAkB,CAAC,IAAI;SAC/C,CAAC;QACF,qFAAqF;QACrF,IAAI,CAAC,KAAK,GAAG,IAAA,yDAA4B,EAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACzF,CAAC;IAEM,KAAK;QACX,MAAM,KAAK,GAAG,IAAI,kBAAkB,CACnC,IAAI,CAAC,IAAI,EACT,IAAA,+BAAoB,EAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAA8B,EAClF,IAAI,CAAC,gBAAgB,EACrB,IAAI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QACjE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC3B,CAAC;CACD;AApVD,gDAoVC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tnoopValidator,\n} from \"../../codec/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype NestedMap,\n\tbrand,\n\tdeleteFromNestedMap,\n\tforEachInNestedMap,\n\tidAllocatorFromMaxId,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n} from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport { makeDetachedNodeToFieldCodec } from \"./detachedFieldIndexCodec.js\";\nimport type { Format } from \"./detachedFieldIndexFormat.js\";\nimport type {\n\tDetachedField,\n\tDetachedFieldSummaryData,\n\tForestRootId,\n\tMajor,\n\tMinor,\n} from \"./detachedFieldIndexTypes.js\";\n\n/**\n * The tree index records detached field IDs and associates them with a change atom ID.\n */\nexport class DetachedFieldIndex {\n\t/**\n\t * A mapping from detached node ids to detached fields.\n\t */\n\tprivate detachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t/**\n\t * A map from revisions to all detached fields for which the revision is the latest relevant revision.\n\t * See {@link DetachedField.latestRelevantRevision}.\n\t *\n\t * @remarks\n\t * undefined revisions are tolerated but any roots not associated with a revision must be disposed manually\n\t */\n\tprivate latestRelevantRevisionToFields: NestedMap<\n\t\tRevisionTag | undefined,\n\t\tForestRootId,\n\t\tDelta.DetachedNodeId\n\t> = new Map();\n\n\tprivate readonly codec: IJsonCodec<DetachedFieldSummaryData, Format>;\n\tprivate readonly options: CodecWriteOptions;\n\n\t/**\n\t * The process for loading `DetachedFieldIndex` data from a summary is split into two steps:\n\t * 1. Call {@link loadData}\n\t * 2. Call {@link setRevisionsForLoadedData}\n\t *\n\t * This flag is only set to `false` after calling `loadData` and is set back to `true` after calling `setRevisionsForLoadedData`.\n\t * This helps ensure that `setRevisionsForLoadedData` is only called after `loadData` and only called once.\n\t */\n\tprivate isFullyLoaded = true;\n\n\t/**\n\t * @param name - A name for the index, used as a prefix for the generated field keys.\n\t * @param rootIdAllocator - An ID allocator used to generate unique field keys.\n\t */\n\tpublic constructor(\n\t\tprivate readonly name: string,\n\t\tprivate rootIdAllocator: IdAllocator<ForestRootId>,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\toptions?: CodecWriteOptions,\n\t) {\n\t\tthis.options = options ?? {\n\t\t\tjsonValidator: noopValidator,\n\t\t\toldestCompatibleClient: FluidClientVersion.v2_0,\n\t\t};\n\t\t// TODO: this should take in CodecWriteOptions, and use it to pick the write version.\n\t\tthis.codec = makeDetachedNodeToFieldCodec(revisionTagCodec, this.options, idCompressor);\n\t}\n\n\tpublic clone(): DetachedFieldIndex {\n\t\tconst clone = new DetachedFieldIndex(\n\t\t\tthis.name,\n\t\t\tidAllocatorFromMaxId(this.rootIdAllocator.getMaxId()) as IdAllocator<ForestRootId>,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.options,\n\t\t);\n\t\tpopulateNestedMap(this.detachedNodeToField, clone.detachedNodeToField, true);\n\t\tpopulateNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tclone.latestRelevantRevisionToFields,\n\t\t\ttrue,\n\t\t);\n\t\treturn clone;\n\t}\n\n\tpublic *entries(): Generator<{\n\t\troot: ForestRootId;\n\t\tlatestRelevantRevision?: RevisionTag;\n\t\tid: Delta.DetachedNodeId;\n\t}> {\n\t\tfor (const [major, innerMap] of this.detachedNodeToField) {\n\t\t\tif (major !== undefined) {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision !== undefined\n\t\t\t\t\t\t? { id: { major, minor }, root, latestRelevantRevision }\n\t\t\t\t\t\t: { id: { major, minor }, root };\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision !== undefined\n\t\t\t\t\t\t? { id: { minor }, root, latestRelevantRevision }\n\t\t\t\t\t\t: { id: { minor }, root };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all entries from the index.\n\t */\n\tpublic purge(): void {\n\t\tthis.detachedNodeToField.clear();\n\t\tthis.latestRelevantRevisionToFields.clear();\n\t}\n\n\tpublic updateMajor(current: Major, updated: Major): void {\n\t\t// Update latestRelevantRevision information corresponding to `current`\n\t\t{\n\t\t\tconst inner = this.latestRelevantRevisionToFields.get(current);\n\t\t\tif (inner !== undefined) {\n\t\t\t\tfor (const nodeId of inner.values()) {\n\t\t\t\t\tconst entry = tryGetFromNestedMap(\n\t\t\t\t\t\tthis.detachedNodeToField,\n\t\t\t\t\t\tnodeId.major,\n\t\t\t\t\t\tnodeId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentry !== undefined,\n\t\t\t\t\t\t0x9b8 /* Inconsistent data: missing detached node entry */,\n\t\t\t\t\t);\n\t\t\t\t\tsetInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor, {\n\t\t\t\t\t\t...entry,\n\t\t\t\t\t\tlatestRelevantRevision: updated,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.latestRelevantRevisionToFields.delete(current);\n\n\t\t\t\tconst updatedInner = this.latestRelevantRevisionToFields.get(updated);\n\t\t\t\tif (updatedInner !== undefined) {\n\t\t\t\t\tfor (const [root, nodeId] of inner) {\n\t\t\t\t\t\tupdatedInner.set(root, nodeId);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.latestRelevantRevisionToFields.set(updated, inner);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update the major keys corresponding to `current`\n\t\t{\n\t\t\tconst innerCurrent = this.detachedNodeToField.get(current);\n\t\t\tif (innerCurrent !== undefined) {\n\t\t\t\tthis.detachedNodeToField.delete(current);\n\t\t\t\tconst innerUpdated = this.detachedNodeToField.get(updated);\n\t\t\t\tif (innerUpdated === undefined) {\n\t\t\t\t\tthis.detachedNodeToField.set(updated, innerCurrent);\n\t\t\t\t} else {\n\t\t\t\t\tfor (const [minor, entry] of innerCurrent) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tinnerUpdated.get(minor) === undefined,\n\t\t\t\t\t\t\t0x7a9 /* Collision during index update */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tinnerUpdated.set(minor, entry);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const [minor, entry] of innerCurrent) {\n\t\t\t\t\tconst entryInLatest = this.latestRelevantRevisionToFields.get(\n\t\t\t\t\t\tentry.latestRelevantRevision,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentryInLatest !== undefined,\n\t\t\t\t\t\t0x9b9 /* Inconsistent data: missing node entry in latestRelevantRevision */,\n\t\t\t\t\t);\n\t\t\t\t\tentryInLatest.set(entry.root, { major: updated, minor });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns a field key for the given ID.\n\t * This does not save the field key on the index. To do so, call {@link createEntry}.\n\t */\n\tpublic toFieldKey(id: ForestRootId): FieldKey {\n\t\treturn brand(`${this.name}-${id}`);\n\t}\n\n\t/**\n\t * Returns the FieldKey associated with the given id.\n\t * Returns undefined if no such id is known to the index.\n\t */\n\tpublic tryGetEntry(id: Delta.DetachedNodeId): ForestRootId | undefined {\n\t\treturn tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor)?.root;\n\t}\n\n\t/**\n\t * Returns the FieldKey associated with the given id.\n\t * Fails if no such id is known to the index.\n\t */\n\tpublic getEntry(id: Delta.DetachedNodeId): ForestRootId {\n\t\tconst key = this.tryGetEntry(id);\n\t\tassert(key !== undefined, 0x7aa /* Unknown removed node ID */);\n\t\treturn key;\n\t}\n\n\t/**\n\t * Returns the detached root IDs for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic *getRootsLastTouchedByRevision(revision: RevisionTag): Iterable<ForestRootId> {\n\t\tconst roots = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (roots !== undefined) {\n\t\t\tyield* roots.keys();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the detached roots for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic deleteRootsLastTouchedByRevision(revision: RevisionTag): void {\n\t\tconst entries = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (entries === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.latestRelevantRevisionToFields.delete(revision);\n\t\tfor (const detachedNodeId of entries.values()) {\n\t\t\tconst found = deleteFromNestedMap(\n\t\t\t\tthis.detachedNodeToField,\n\t\t\t\tdetachedNodeId.major,\n\t\t\t\tdetachedNodeId.minor,\n\t\t\t);\n\t\t\tassert(found, 0x9ba /* Unable to delete unknown entry */);\n\t\t}\n\t}\n\n\tpublic deleteEntry(nodeId: Delta.DetachedNodeId): void {\n\t\tconst entry = tryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tassert(entry !== undefined, 0x9bb /* Unable to delete unknown entry */);\n\t\tdeleteFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tdeleteFromNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tentry.latestRelevantRevision,\n\t\t\tentry.root,\n\t\t);\n\t}\n\n\t/**\n\t * Associates the DetachedNodeId with a field key and creates an entry for it in the index.\n\t * @param nodeId - The ID of the detached node.\n\t * @param revision - The revision that last detached the root.\n\t * See {@link DetachedField.latestRelevantRevision} for details.\n\t * @param count - The number of entries to create. These entries will have consecutive minor IDs.\n\t * @returns The atomic ID that the `DetachedFieldIndex` uses to uniquely identify the first root.\n\t */\n\tpublic createEntry(\n\t\tnodeId?: Delta.DetachedNodeId,\n\t\trevision?: RevisionTag,\n\t\tcount: number = 1,\n\t): ForestRootId {\n\t\tconst root = this.rootIdAllocator.allocate(count);\n\t\tif (nodeId !== undefined) {\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tassert(\n\t\t\t\t\ttryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i) ===\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t0x7ce /* Detached node ID already exists in index */,\n\t\t\t\t);\n\t\t\t\tsetInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i, {\n\t\t\t\t\troot: brand<ForestRootId>(root + i),\n\t\t\t\t\tlatestRelevantRevision: revision,\n\t\t\t\t});\n\t\t\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root, nodeId);\n\t\t\t}\n\t\t}\n\t\treturn root;\n\t}\n\n\t/**\n\t * Updates the latest revision that is relevant to the provided root\n\t */\n\tpublic updateLatestRevision(\n\t\tid: Delta.DetachedNodeId,\n\t\trevision: RevisionTag | undefined,\n\t): void {\n\t\tconst fieldEntry = tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor);\n\t\tassert(\n\t\t\tfieldEntry !== undefined,\n\t\t\t0x9bc /* detached node id does not exist in the detached field index */,\n\t\t);\n\t\tconst { root, latestRelevantRevision: previousRevision } = fieldEntry;\n\n\t\t// remove this root from the set of roots for the previous latest revision\n\t\tdeleteFromNestedMap(this.latestRelevantRevisionToFields, previousRevision, root);\n\n\t\t// add this root to the set of roots for the new latest revision\n\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root, id);\n\t\tsetInNestedMap(this.detachedNodeToField, id.major, id.minor, {\n\t\t\troot,\n\t\t\tlatestRelevantRevision: revision,\n\t\t});\n\t}\n\n\tpublic encode(): JsonCompatibleReadOnly {\n\t\treturn this.codec.encode({\n\t\t\tdata: this.detachedNodeToField,\n\t\t\tmaxId: this.rootIdAllocator.getMaxId(),\n\t\t});\n\t}\n\n\t/**\n\t * Loads the tree index from the given string, this overrides any existing data.\n\t */\n\tpublic loadData(data: JsonCompatibleReadOnly): void {\n\t\tconst detachedFieldIndex: DetachedFieldSummaryData = this.codec.decode(data as Format);\n\n\t\tthis.rootIdAllocator = idAllocatorFromMaxId(\n\t\t\tdetachedFieldIndex.maxId,\n\t\t) as IdAllocator<ForestRootId>;\n\n\t\tthis.detachedNodeToField = new Map();\n\t\tthis.latestRelevantRevisionToFields = new Map();\n\t\tthis.isFullyLoaded = false;\n\t\tconst rootMap = new Map<ForestRootId, Delta.DetachedNodeId>();\n\t\tforEachInNestedMap(detachedFieldIndex.data, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(this.detachedNodeToField, major, minor, { root });\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.latestRelevantRevisionToFields.set(undefined, rootMap);\n\t}\n\n\t/**\n\t * Sets the latest relevant revision for any roots that have an undefined latest relevant revision.\n\t * This occurs when the detached field index is loaded from a summary and can only be called once after\n\t * the summary has been loaded.\n\t */\n\tpublic setRevisionsForLoadedData(latestRevision: RevisionTag): void {\n\t\tassert(\n\t\t\t!this.isFullyLoaded,\n\t\t\t0x9bd /* revisions should only be set once using this function after loading data from a summary */,\n\t\t);\n\n\t\tconst newDetachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t\tconst rootMap = new Map();\n\t\tforEachInNestedMap(this.detachedNodeToField, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(newDetachedNodeToField, major, minor, {\n\t\t\t\troot,\n\t\t\t\tlatestRelevantRevision: latestRevision,\n\t\t\t});\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.detachedNodeToField = newDetachedNodeToField;\n\t\tthis.latestRelevantRevisionToFields.delete(undefined);\n\t\tthis.latestRelevantRevisionToFields.set(latestRevision, rootMap);\n\t\tthis.isFullyLoaded = true;\n\t}\n}\n"]}
1
+ {"version":3,"file":"detachedFieldIndex.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndex.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,mDAK8B;AAC9B,kDAW6B;AAY7B,+EAA4E;AAE5E;;GAEG;AACH,MAAa,kBAAkB;IA+B9B;;;OAGG;IACH,YACkB,IAAY,EACrB,eAA0C,EACjC,gBAAkC,EAClC,YAA2B,EAC5C,OAA2B;QAJV,SAAI,GAAJ,IAAI,CAAQ;QACrB,oBAAe,GAAf,eAAe,CAA2B;QACjC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,iBAAY,GAAZ,YAAY,CAAe;QAtC7C;;WAEG;QACK,wBAAmB,GAA2C,IAAI,GAAG,EAAE,CAAC;QAChF;;;;;;WAMG;QACK,mCAA8B,GAIlC,IAAI,GAAG,EAAE,CAAC;QAKd;;;;;;;WAOG;QACK,kBAAa,GAAG,IAAI,CAAC;QAa5B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI;YACzB,aAAa,EAAE,wBAAa;YAC5B,sBAAsB,EAAE,6BAAkB,CAAC,IAAI;SAC/C,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,IAAA,yDAA2B,EAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACxF,CAAC;IAEM,KAAK;QACX,MAAM,KAAK,GAAG,IAAI,kBAAkB,CACnC,IAAI,CAAC,IAAI,EACT,IAAA,+BAAoB,EAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAA8B,EAClF,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,CACZ,CAAC;QACF,IAAA,4BAAiB,EAAC,IAAI,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Content":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport {\n\ttype CodecWriteOptions,\n\tFluidClientVersion,\n\ttype IJsonCodec,\n\tnoopValidator,\n} from \"../../codec/index.js\";\nimport {\n\ttype IdAllocator,\n\ttype JsonCompatibleReadOnly,\n\ttype NestedMap,\n\tbrand,\n\tdeleteFromNestedMap,\n\tforEachInNestedMap,\n\tidAllocatorFromMaxId,\n\tpopulateNestedMap,\n\tsetInNestedMap,\n\ttryGetFromNestedMap,\n} from \"../../util/index.js\";\nimport type { RevisionTag, RevisionTagCodec } from \"../rebase/index.js\";\nimport type { FieldKey } from \"../schema-stored/index.js\";\n\nimport type * as Delta from \"./delta.js\";\nimport type {\n\tDetachedField,\n\tDetachedFieldSummaryData,\n\tForestRootId,\n\tMajor,\n\tMinor,\n} from \"./detachedFieldIndexTypes.js\";\nimport { makeDetachedFieldIndexCodec } from \"./detachedFieldIndexCodecs.js\";\n\n/**\n * The tree index records detached field IDs and associates them with a change atom ID.\n */\nexport class DetachedFieldIndex {\n\t/**\n\t * A mapping from detached node ids to detached fields.\n\t */\n\tprivate detachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t/**\n\t * A map from revisions to all detached fields for which the revision is the latest relevant revision.\n\t * See {@link DetachedField.latestRelevantRevision}.\n\t *\n\t * @remarks\n\t * undefined revisions are tolerated but any roots not associated with a revision must be disposed manually\n\t */\n\tprivate latestRelevantRevisionToFields: NestedMap<\n\t\tRevisionTag | undefined,\n\t\tForestRootId,\n\t\tDelta.DetachedNodeId\n\t> = new Map();\n\n\tprivate readonly codec: IJsonCodec<DetachedFieldSummaryData>;\n\tprivate readonly options: CodecWriteOptions;\n\n\t/**\n\t * The process for loading `DetachedFieldIndex` data from a summary is split into two steps:\n\t * 1. Call {@link loadData}\n\t * 2. Call {@link setRevisionsForLoadedData}\n\t *\n\t * This flag is only set to `false` after calling `loadData` and is set back to `true` after calling `setRevisionsForLoadedData`.\n\t * This helps ensure that `setRevisionsForLoadedData` is only called after `loadData` and only called once.\n\t */\n\tprivate isFullyLoaded = true;\n\n\t/**\n\t * @param name - A name for the index, used as a prefix for the generated field keys.\n\t * @param rootIdAllocator - An ID allocator used to generate unique field keys.\n\t */\n\tpublic constructor(\n\t\tprivate readonly name: string,\n\t\tprivate rootIdAllocator: IdAllocator<ForestRootId>,\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t\toptions?: CodecWriteOptions,\n\t) {\n\t\tthis.options = options ?? {\n\t\t\tjsonValidator: noopValidator,\n\t\t\toldestCompatibleClient: FluidClientVersion.v2_0,\n\t\t};\n\t\tthis.codec = makeDetachedFieldIndexCodec(revisionTagCodec, this.options, idCompressor);\n\t}\n\n\tpublic clone(): DetachedFieldIndex {\n\t\tconst clone = new DetachedFieldIndex(\n\t\t\tthis.name,\n\t\t\tidAllocatorFromMaxId(this.rootIdAllocator.getMaxId()) as IdAllocator<ForestRootId>,\n\t\t\tthis.revisionTagCodec,\n\t\t\tthis.idCompressor,\n\t\t\tthis.options,\n\t\t);\n\t\tpopulateNestedMap(this.detachedNodeToField, clone.detachedNodeToField, true);\n\t\tpopulateNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tclone.latestRelevantRevisionToFields,\n\t\t\ttrue,\n\t\t);\n\t\treturn clone;\n\t}\n\n\tpublic *entries(): Generator<{\n\t\troot: ForestRootId;\n\t\tlatestRelevantRevision?: RevisionTag;\n\t\tid: Delta.DetachedNodeId;\n\t}> {\n\t\tfor (const [major, innerMap] of this.detachedNodeToField) {\n\t\t\tif (major !== undefined) {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision !== undefined\n\t\t\t\t\t\t? { id: { major, minor }, root, latestRelevantRevision }\n\t\t\t\t\t\t: { id: { major, minor }, root };\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const [minor, { root, latestRelevantRevision }] of innerMap) {\n\t\t\t\t\tyield latestRelevantRevision !== undefined\n\t\t\t\t\t\t? { id: { minor }, root, latestRelevantRevision }\n\t\t\t\t\t\t: { id: { minor }, root };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all entries from the index.\n\t */\n\tpublic purge(): void {\n\t\tthis.detachedNodeToField.clear();\n\t\tthis.latestRelevantRevisionToFields.clear();\n\t}\n\n\tpublic updateMajor(current: Major, updated: Major): void {\n\t\t// Update latestRelevantRevision information corresponding to `current`\n\t\t{\n\t\t\tconst inner = this.latestRelevantRevisionToFields.get(current);\n\t\t\tif (inner !== undefined) {\n\t\t\t\tfor (const nodeId of inner.values()) {\n\t\t\t\t\tconst entry = tryGetFromNestedMap(\n\t\t\t\t\t\tthis.detachedNodeToField,\n\t\t\t\t\t\tnodeId.major,\n\t\t\t\t\t\tnodeId.minor,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentry !== undefined,\n\t\t\t\t\t\t0x9b8 /* Inconsistent data: missing detached node entry */,\n\t\t\t\t\t);\n\t\t\t\t\tsetInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor, {\n\t\t\t\t\t\t...entry,\n\t\t\t\t\t\tlatestRelevantRevision: updated,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthis.latestRelevantRevisionToFields.delete(current);\n\n\t\t\t\tconst updatedInner = this.latestRelevantRevisionToFields.get(updated);\n\t\t\t\tif (updatedInner !== undefined) {\n\t\t\t\t\tfor (const [root, nodeId] of inner) {\n\t\t\t\t\t\tupdatedInner.set(root, nodeId);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.latestRelevantRevisionToFields.set(updated, inner);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update the major keys corresponding to `current`\n\t\t{\n\t\t\tconst innerCurrent = this.detachedNodeToField.get(current);\n\t\t\tif (innerCurrent !== undefined) {\n\t\t\t\tthis.detachedNodeToField.delete(current);\n\t\t\t\tconst innerUpdated = this.detachedNodeToField.get(updated);\n\t\t\t\tif (innerUpdated === undefined) {\n\t\t\t\t\tthis.detachedNodeToField.set(updated, innerCurrent);\n\t\t\t\t} else {\n\t\t\t\t\tfor (const [minor, entry] of innerCurrent) {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tinnerUpdated.get(minor) === undefined,\n\t\t\t\t\t\t\t0x7a9 /* Collision during index update */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tinnerUpdated.set(minor, entry);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const [minor, entry] of innerCurrent) {\n\t\t\t\t\tconst entryInLatest = this.latestRelevantRevisionToFields.get(\n\t\t\t\t\t\tentry.latestRelevantRevision,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentryInLatest !== undefined,\n\t\t\t\t\t\t0x9b9 /* Inconsistent data: missing node entry in latestRelevantRevision */,\n\t\t\t\t\t);\n\t\t\t\t\tentryInLatest.set(entry.root, { major: updated, minor });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns a field key for the given ID.\n\t * This does not save the field key on the index. To do so, call {@link createEntry}.\n\t */\n\tpublic toFieldKey(id: ForestRootId): FieldKey {\n\t\treturn brand(`${this.name}-${id}`);\n\t}\n\n\t/**\n\t * Returns the FieldKey associated with the given id.\n\t * Returns undefined if no such id is known to the index.\n\t */\n\tpublic tryGetEntry(id: Delta.DetachedNodeId): ForestRootId | undefined {\n\t\treturn tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor)?.root;\n\t}\n\n\t/**\n\t * Returns the FieldKey associated with the given id.\n\t * Fails if no such id is known to the index.\n\t */\n\tpublic getEntry(id: Delta.DetachedNodeId): ForestRootId {\n\t\tconst key = this.tryGetEntry(id);\n\t\tassert(key !== undefined, 0x7aa /* Unknown removed node ID */);\n\t\treturn key;\n\t}\n\n\t/**\n\t * Returns the detached root IDs for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic *getRootsLastTouchedByRevision(revision: RevisionTag): Iterable<ForestRootId> {\n\t\tconst roots = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (roots !== undefined) {\n\t\t\tyield* roots.keys();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the detached roots for all the trees that were detached or last modified by the given revision.\n\t */\n\tpublic deleteRootsLastTouchedByRevision(revision: RevisionTag): void {\n\t\tconst entries = this.latestRelevantRevisionToFields.get(revision);\n\t\tif (entries === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.latestRelevantRevisionToFields.delete(revision);\n\t\tfor (const detachedNodeId of entries.values()) {\n\t\t\tconst found = deleteFromNestedMap(\n\t\t\t\tthis.detachedNodeToField,\n\t\t\t\tdetachedNodeId.major,\n\t\t\t\tdetachedNodeId.minor,\n\t\t\t);\n\t\t\tassert(found, 0x9ba /* Unable to delete unknown entry */);\n\t\t}\n\t}\n\n\tpublic deleteEntry(nodeId: Delta.DetachedNodeId): void {\n\t\tconst entry = tryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tassert(entry !== undefined, 0x9bb /* Unable to delete unknown entry */);\n\t\tdeleteFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor);\n\t\tdeleteFromNestedMap(\n\t\t\tthis.latestRelevantRevisionToFields,\n\t\t\tentry.latestRelevantRevision,\n\t\t\tentry.root,\n\t\t);\n\t}\n\n\t/**\n\t * Associates the DetachedNodeId with a field key and creates an entry for it in the index.\n\t * @param nodeId - The ID of the detached node.\n\t * @param revision - The revision that last detached the root.\n\t * See {@link DetachedField.latestRelevantRevision} for details.\n\t * @param count - The number of entries to create. These entries will have consecutive minor IDs.\n\t * @returns The atomic ID that the `DetachedFieldIndex` uses to uniquely identify the first root.\n\t */\n\tpublic createEntry(\n\t\tnodeId?: Delta.DetachedNodeId,\n\t\trevision?: RevisionTag,\n\t\tcount: number = 1,\n\t): ForestRootId {\n\t\tconst root = this.rootIdAllocator.allocate(count);\n\t\tif (nodeId !== undefined) {\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tassert(\n\t\t\t\t\ttryGetFromNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i) ===\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t0x7ce /* Detached node ID already exists in index */,\n\t\t\t\t);\n\t\t\t\tsetInNestedMap(this.detachedNodeToField, nodeId.major, nodeId.minor + i, {\n\t\t\t\t\troot: brand<ForestRootId>(root + i),\n\t\t\t\t\tlatestRelevantRevision: revision,\n\t\t\t\t});\n\t\t\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root, nodeId);\n\t\t\t}\n\t\t}\n\t\treturn root;\n\t}\n\n\t/**\n\t * Updates the latest revision that is relevant to the provided root\n\t */\n\tpublic updateLatestRevision(\n\t\tid: Delta.DetachedNodeId,\n\t\trevision: RevisionTag | undefined,\n\t): void {\n\t\tconst fieldEntry = tryGetFromNestedMap(this.detachedNodeToField, id.major, id.minor);\n\t\tassert(\n\t\t\tfieldEntry !== undefined,\n\t\t\t0x9bc /* detached node id does not exist in the detached field index */,\n\t\t);\n\t\tconst { root, latestRelevantRevision: previousRevision } = fieldEntry;\n\n\t\t// remove this root from the set of roots for the previous latest revision\n\t\tdeleteFromNestedMap(this.latestRelevantRevisionToFields, previousRevision, root);\n\n\t\t// add this root to the set of roots for the new latest revision\n\t\tsetInNestedMap(this.latestRelevantRevisionToFields, revision, root, id);\n\t\tsetInNestedMap(this.detachedNodeToField, id.major, id.minor, {\n\t\t\troot,\n\t\t\tlatestRelevantRevision: revision,\n\t\t});\n\t}\n\n\tpublic encode(): JsonCompatibleReadOnly {\n\t\treturn this.codec.encode({\n\t\t\tdata: this.detachedNodeToField,\n\t\t\tmaxId: this.rootIdAllocator.getMaxId(),\n\t\t});\n\t}\n\n\t/**\n\t * Loads the tree index from the given string, this overrides any existing data.\n\t */\n\tpublic loadData(data: JsonCompatibleReadOnly): void {\n\t\tconst detachedFieldIndex: DetachedFieldSummaryData = this.codec.decode(data);\n\n\t\tthis.rootIdAllocator = idAllocatorFromMaxId(\n\t\t\tdetachedFieldIndex.maxId,\n\t\t) as IdAllocator<ForestRootId>;\n\n\t\tthis.detachedNodeToField = new Map();\n\t\tthis.latestRelevantRevisionToFields = new Map();\n\t\tthis.isFullyLoaded = false;\n\t\tconst rootMap = new Map<ForestRootId, Delta.DetachedNodeId>();\n\t\tforEachInNestedMap(detachedFieldIndex.data, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(this.detachedNodeToField, major, minor, { root });\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.latestRelevantRevisionToFields.set(undefined, rootMap);\n\t}\n\n\t/**\n\t * Sets the latest relevant revision for any roots that have an undefined latest relevant revision.\n\t * This occurs when the detached field index is loaded from a summary and can only be called once after\n\t * the summary has been loaded.\n\t */\n\tpublic setRevisionsForLoadedData(latestRevision: RevisionTag): void {\n\t\tassert(\n\t\t\t!this.isFullyLoaded,\n\t\t\t0x9bd /* revisions should only be set once using this function after loading data from a summary */,\n\t\t);\n\n\t\tconst newDetachedNodeToField: NestedMap<Major, Minor, DetachedField> = new Map();\n\t\tconst rootMap = new Map();\n\t\tforEachInNestedMap(this.detachedNodeToField, ({ root }, major, minor) => {\n\t\t\tsetInNestedMap(newDetachedNodeToField, major, minor, {\n\t\t\t\troot,\n\t\t\t\tlatestRelevantRevision: latestRevision,\n\t\t\t});\n\t\t\trootMap.set(root, { major, minor });\n\t\t});\n\n\t\tthis.detachedNodeToField = newDetachedNodeToField;\n\t\tthis.latestRelevantRevisionToFields.delete(undefined);\n\t\tthis.latestRelevantRevisionToFields.set(latestRevision, rootMap);\n\t\tthis.isFullyLoaded = true;\n\t}\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type ICodecOptions, type IJsonCodec } from "../../codec/index.js";
6
+ import type { DetachedFieldSummaryData, Major } from "./detachedFieldIndexTypes.js";
7
+ import type { Static, TSchema } from "@sinclair/typebox";
8
+ export declare function makeDetachedFieldIndexCodecFromMajorCodec<TEncodedRevisionTag, TEncodedRevisionTagSchema extends TSchema, TVersion extends number>(options: ICodecOptions, majorCodec: IJsonCodec<Major, TEncodedRevisionTag>, version: TVersion, encodedRevisionTagSchema: TEncodedRevisionTagSchema): IJsonCodec<DetachedFieldSummaryData, {
9
+ data: ([Static<TEncodedRevisionTagSchema, unknown[] & []>, [number, import("./detachedFieldIndexTypes.js").ForestRootId][]] | [Static<TEncodedRevisionTagSchema, unknown[] & []>, number, import("./detachedFieldIndexTypes.js").ForestRootId])[];
10
+ version: TVersion;
11
+ maxId: import("./detachedFieldIndexTypes.js").ForestRootId;
12
+ }, {
13
+ data: ([Static<TEncodedRevisionTagSchema, unknown[] & []>, [number, import("./detachedFieldIndexTypes.js").ForestRootId][]] | [Static<TEncodedRevisionTagSchema, unknown[] & []>, number, import("./detachedFieldIndexTypes.js").ForestRootId])[];
14
+ version: TVersion;
15
+ maxId: import("./detachedFieldIndexTypes.js").ForestRootId;
16
+ }, void>;
17
+ //# sourceMappingURL=detachedFieldIndexCodecCommon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecCommon.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecCommon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,KAAK,EAEX,wBAAwB,EACxB,KAAK,EACL,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIzD,wBAAgB,yCAAyC,CACxD,mBAAmB,EACnB,yBAAyB,SAAS,OAAO,EACzC,QAAQ,SAAS,MAAM,EAEvB,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,UAAU,CAAC,KAAK,EAAE,mBAAmB,CAAC,EAClD,OAAO,EAAE,QAAQ,EACjB,wBAAwB,EAAE,yBAAyB;;;;;;;;SAoDnD"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.makeDetachedFieldIndexCodecFromMajorCodec = void 0;
8
+ const index_js_1 = require("../../codec/index.js");
9
+ const index_js_2 = require("../../util/index.js");
10
+ const detachedFieldIndexFormatCommon_js_1 = require("./detachedFieldIndexFormatCommon.js");
11
+ // Return type is intentionally derived.
12
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
13
+ function makeDetachedFieldIndexCodecFromMajorCodec(options, majorCodec, version, encodedRevisionTagSchema) {
14
+ const formatSchema = (0, detachedFieldIndexFormatCommon_js_1.Format)(version, encodedRevisionTagSchema);
15
+ return (0, index_js_1.makeVersionedValidatedCodec)(options, new Set([version]), formatSchema, {
16
+ encode: (data) => {
17
+ const rootsForRevisions = [];
18
+ for (const [major, innerMap] of data.data) {
19
+ const encodedRevision = majorCodec.encode(major);
20
+ const rootRanges = [];
21
+ for (const [minor, detachedField] of innerMap) {
22
+ rootRanges.push([minor, detachedField.root]);
23
+ }
24
+ if ((0, index_js_2.hasSingle)(rootRanges)) {
25
+ const firstRootRange = rootRanges[0];
26
+ const rootsForRevision = [
27
+ encodedRevision,
28
+ firstRootRange[0],
29
+ firstRootRange[1],
30
+ ];
31
+ rootsForRevisions.push(rootsForRevision);
32
+ }
33
+ else {
34
+ const rootsForRevision = [encodedRevision, rootRanges];
35
+ rootsForRevisions.push(rootsForRevision);
36
+ }
37
+ }
38
+ const encoded = {
39
+ version,
40
+ data: rootsForRevisions,
41
+ maxId: data.maxId,
42
+ };
43
+ return encoded;
44
+ },
45
+ decode: (parsed) => {
46
+ const map = new Map();
47
+ for (const rootsForRevision of parsed.data) {
48
+ const innerMap = new Map();
49
+ if (rootsForRevision.length === 2) {
50
+ for (const [minor, root] of rootsForRevision[1]) {
51
+ innerMap.set(minor, { root });
52
+ }
53
+ }
54
+ else {
55
+ innerMap.set(rootsForRevision[1], { root: rootsForRevision[2] });
56
+ }
57
+ const revision = rootsForRevision[0];
58
+ map.set(majorCodec.decode(revision), innerMap);
59
+ }
60
+ return {
61
+ data: map,
62
+ maxId: parsed.maxId,
63
+ };
64
+ },
65
+ });
66
+ }
67
+ exports.makeDetachedFieldIndexCodecFromMajorCodec = makeDetachedFieldIndexCodecFromMajorCodec;
68
+ //# sourceMappingURL=detachedFieldIndexCodecCommon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecCommon.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecCommon.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAI8B;AAC9B,kDAAgD;AAEhD,2FAI6C;AAQ7C,wCAAwC;AACxC,4EAA4E;AAC5E,SAAgB,yCAAyC,CAKxD,OAAsB,EACtB,UAAkD,EAClD,OAAiB,EACjB,wBAAmD;IAEnD,MAAM,YAAY,GAAG,IAAA,0CAAM,EAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC;IAC/D,OAAO,IAAA,sCAA2B,EAAC,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,YAAY,EAAE;QAC7E,MAAM,EAAE,CAAC,IAA8B,EAA+B,EAAE;YACvE,MAAM,iBAAiB,GAA8B,EAAE,CAAC;YACxD,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBAC3C,MAAM,eAAe,GAAG,UAAU,CAAC,MA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,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC/B,CAAC;gBACF,CAAC;qBAAM,CAAC;oBACP,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAClE,CAAC;gBACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAwB,CAAC;gBAC5D,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;YAChD,CAAC;YACD,OAAO;gBACN,IAAI,EAAE,GAAG;gBACT,KAAK,EAAE,MAAM,CAAC,KAAK;aACnB,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AA5DD,8FA4DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype ICodecOptions,\n\ttype IJsonCodec,\n\tmakeVersionedValidatedCodec,\n} from \"../../codec/index.js\";\nimport { hasSingle } from \"../../util/index.js\";\n\nimport {\n\tFormat,\n\ttype EncodedRootsForRevision,\n\ttype RootRanges,\n} from \"./detachedFieldIndexFormatCommon.js\";\nimport type {\n\tDetachedField,\n\tDetachedFieldSummaryData,\n\tMajor,\n} from \"./detachedFieldIndexTypes.js\";\nimport type { Static, TSchema } from \"@sinclair/typebox\";\n\n// Return type is intentionally derived.\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function makeDetachedFieldIndexCodecFromMajorCodec<\n\tTEncodedRevisionTag,\n\tTEncodedRevisionTagSchema extends TSchema,\n\tTVersion extends number,\n>(\n\toptions: ICodecOptions,\n\tmajorCodec: IJsonCodec<Major, TEncodedRevisionTag>,\n\tversion: TVersion,\n\tencodedRevisionTagSchema: TEncodedRevisionTagSchema,\n) {\n\tconst formatSchema = Format(version, encodedRevisionTagSchema);\n\treturn makeVersionedValidatedCodec(options, new Set([version]), formatSchema, {\n\t\tencode: (data: DetachedFieldSummaryData): Static<typeof formatSchema> => {\n\t\t\tconst rootsForRevisions: EncodedRootsForRevision[] = [];\n\t\t\tfor (const [major, innerMap] of data.data) {\n\t\t\t\tconst encodedRevision = majorCodec.encode(major);\n\t\t\t\tconst rootRanges: RootRanges = [];\n\t\t\t\tfor (const [minor, detachedField] of innerMap) {\n\t\t\t\t\trootRanges.push([minor, detachedField.root]);\n\t\t\t\t}\n\t\t\t\tif (hasSingle(rootRanges)) {\n\t\t\t\t\tconst firstRootRange = rootRanges[0];\n\t\t\t\t\tconst rootsForRevision: EncodedRootsForRevision = [\n\t\t\t\t\t\tencodedRevision,\n\t\t\t\t\t\tfirstRootRange[0],\n\t\t\t\t\t\tfirstRootRange[1],\n\t\t\t\t\t];\n\t\t\t\t\trootsForRevisions.push(rootsForRevision);\n\t\t\t\t} else {\n\t\t\t\t\tconst rootsForRevision: EncodedRootsForRevision = [encodedRevision, rootRanges];\n\t\t\t\t\trootsForRevisions.push(rootsForRevision);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst encoded: Static<typeof formatSchema> = {\n\t\t\t\tversion,\n\t\t\t\tdata: rootsForRevisions,\n\t\t\t\tmaxId: data.maxId,\n\t\t\t};\n\t\t\treturn encoded;\n\t\t},\n\t\tdecode: (parsed: Static<typeof formatSchema>): DetachedFieldSummaryData => {\n\t\t\tconst map = new Map();\n\t\t\tfor (const rootsForRevision of parsed.data) {\n\t\t\t\tconst innerMap = new Map<number, DetachedField>();\n\t\t\t\tif (rootsForRevision.length === 2) {\n\t\t\t\t\tfor (const [minor, root] of rootsForRevision[1]) {\n\t\t\t\t\t\tinnerMap.set(minor, { root });\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tinnerMap.set(rootsForRevision[1], { root: rootsForRevision[2] });\n\t\t\t\t}\n\t\t\t\tconst revision = rootsForRevision[0] as TEncodedRevisionTag;\n\t\t\t\tmap.set(majorCodec.decode(revision), innerMap);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdata: map,\n\t\t\t\tmaxId: parsed.maxId,\n\t\t\t};\n\t\t},\n\t});\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
6
+ import type { ICodecOptions, IJsonCodec } from "../../codec/index.js";
7
+ import { type RevisionTagCodec } from "../rebase/index.js";
8
+ import { type FormatV1 } from "./detachedFieldIndexFormatV1.js";
9
+ import type { DetachedFieldSummaryData } from "./detachedFieldIndexTypes.js";
10
+ export declare function makeDetachedNodeToFieldCodecV1(revisionTagCodec: RevisionTagCodec, options: ICodecOptions, idCompressor: IIdCompressor): IJsonCodec<DetachedFieldSummaryData, FormatV1>;
11
+ //# sourceMappingURL=detachedFieldIndexCodecV1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecV1.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAEN,KAAK,gBAAgB,EAGrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,wBAAwB,EAAS,MAAM,8BAA8B,CAAC;AAkDpF,wBAAgB,8BAA8B,CAC7C,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,aAAa,GACzB,UAAU,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAQhD"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.makeDetachedNodeToFieldCodecV1 = void 0;
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
9
+ const index_js_1 = require("../rebase/index.js");
10
+ const detachedFieldIndexFormatV1_js_1 = require("./detachedFieldIndexFormatV1.js");
11
+ const detachedFieldIndexCodecCommon_js_1 = require("./detachedFieldIndexCodecCommon.js");
12
+ class MajorCodec {
13
+ constructor(revisionTagCodec, options, idCompressor) {
14
+ this.revisionTagCodec = revisionTagCodec;
15
+ this.options = options;
16
+ this.idCompressor = idCompressor;
17
+ }
18
+ encode(major) {
19
+ (0, internal_1.assert)(major !== undefined, 0x88e /* Unexpected undefined revision */);
20
+ const id = this.revisionTagCodec.encode(major);
21
+ /**
22
+ * Preface: this codec is only used at summarization time (not for ops).
23
+ * Note that the decode path must provide a session id in which to interpret the revision tag.
24
+ * The revision associated with a detached root generally comes from the session which detaches that subtree,
25
+ * which isn't generally the local session (nor is it available at decode time with the layering of the tree
26
+ * package), despite decode using the local session id.
27
+ *
28
+ * This is made OK by enforcing that all ids on encode/decode are non-local, since local ids won't be interpretable
29
+ * at decode time.
30
+ * This assert is valid because the revision for an acked edit will have already been finalized, and a revision
31
+ * for a local-only edit will be finalizable at summarization time (local edits can only occur on a summarizing client
32
+ * if they're created while detached, and local ids made while detached are finalized before generating the attach summary).
33
+ *
34
+ * WARNING: the above is true when the whole container transitions from detached to attached,
35
+ * but not when the container is already attached and it's just the shared-tree that is attaching.
36
+ * The assert below will fail in such a scenario. This is addressed in the v2 codec.
37
+ */
38
+ (0, internal_1.assert)(id === "root" || id >= 0, 0x88f /* Expected final id on encode of detached field index revision */);
39
+ return id;
40
+ }
41
+ decode(major) {
42
+ (0, internal_1.assert)(major === "root" || major >= 0, 0x890 /* Expected final id on decode of detached field index revision */);
43
+ return this.revisionTagCodec.decode(major, {
44
+ originatorId: this.revisionTagCodec.localSessionId,
45
+ idCompressor: this.idCompressor,
46
+ revision: undefined,
47
+ });
48
+ }
49
+ }
50
+ function makeDetachedNodeToFieldCodecV1(revisionTagCodec, options, idCompressor) {
51
+ const majorCodec = new MajorCodec(revisionTagCodec, options, idCompressor);
52
+ return (0, detachedFieldIndexCodecCommon_js_1.makeDetachedFieldIndexCodecFromMajorCodec)(options, majorCodec, detachedFieldIndexFormatV1_js_1.version1, index_js_1.RevisionTagSchema);
53
+ }
54
+ exports.makeDetachedNodeToFieldCodecV1 = makeDetachedNodeToFieldCodecV1;
55
+ //# sourceMappingURL=detachedFieldIndexCodecV1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecV1.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecV1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAI7D,iDAK4B;AAE5B,mFAA0E;AAE1E,yFAA+F;AAE/F,MAAM,UAAU;IACf,YACkB,gBAAkC,EAClC,OAAsB,EACtB,YAA2B;QAF3B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,YAAO,GAAP,OAAO,CAAe;QACtB,iBAAY,GAAZ,YAAY,CAAe;IAC1C,CAAC;IAEG,MAAM,CAAC,KAAY;QACzB,IAAA,iBAAM,EAAC,KAAK,KAAK,SAAS,EAAE,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvE,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/C;;;;;;;;;;;;;;;;WAgBG;QACH,IAAA,iBAAM,EACL,EAAE,KAAK,MAAM,IAAI,EAAE,IAAI,CAAC,EACxB,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,OAAO,EAAE,CAAC;IACX,CAAC;IAEM,MAAM,CAAC,KAAyB;QACtC,IAAA,iBAAM,EACL,KAAK,KAAK,MAAM,IAAI,KAAK,IAAI,CAAC,EAC9B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE;YAC1C,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc;YAClD,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,SAAS;SACnB,CAAC,CAAC;IACJ,CAAC;CACD;AAED,SAAgB,8BAA8B,CAC7C,gBAAkC,EAClC,OAAsB,EACtB,YAA2B;IAE3B,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC3E,OAAO,IAAA,4EAAyC,EAC/C,OAAO,EACP,UAAU,EACV,wCAAQ,EACR,4BAAiB,CACjB,CAAC;AACH,CAAC;AAZD,wEAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../../codec/index.js\";\nimport {\n\ttype EncodedRevisionTag,\n\ttype RevisionTagCodec,\n\ttype RevisionTag,\n\tRevisionTagSchema,\n} from \"../rebase/index.js\";\n\nimport { type FormatV1, version1 } from \"./detachedFieldIndexFormatV1.js\";\nimport type { DetachedFieldSummaryData, Major } from \"./detachedFieldIndexTypes.js\";\nimport { makeDetachedFieldIndexCodecFromMajorCodec } from \"./detachedFieldIndexCodecCommon.js\";\n\nclass MajorCodec implements IJsonCodec<Major, EncodedRevisionTag> {\n\tpublic constructor(\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly options: ICodecOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic encode(major: Major): EncodedRevisionTag {\n\t\tassert(major !== undefined, 0x88e /* Unexpected undefined revision */);\n\t\tconst id = this.revisionTagCodec.encode(major);\n\t\t/**\n\t\t * Preface: this codec is only used at summarization time (not for ops).\n\t\t * Note that the decode path must provide a session id in which to interpret the revision tag.\n\t\t * The revision associated with a detached root generally comes from the session which detaches that subtree,\n\t\t * which isn't generally the local session (nor is it available at decode time with the layering of the tree\n\t\t * package), despite decode using the local session id.\n\t\t *\n\t\t * This is made OK by enforcing that all ids on encode/decode are non-local, since local ids won't be interpretable\n\t\t * at decode time.\n\t\t * This assert is valid because the revision for an acked edit will have already been finalized, and a revision\n\t\t * for a local-only edit will be finalizable at summarization time (local edits can only occur on a summarizing client\n\t\t * if they're created while detached, and local ids made while detached are finalized before generating the attach summary).\n\t\t *\n\t\t * WARNING: the above is true when the whole container transitions from detached to attached,\n\t\t * but not when the container is already attached and it's just the shared-tree that is attaching.\n\t\t * The assert below will fail in such a scenario. This is addressed in the v2 codec.\n\t\t */\n\t\tassert(\n\t\t\tid === \"root\" || id >= 0,\n\t\t\t0x88f /* Expected final id on encode of detached field index revision */,\n\t\t);\n\t\treturn id;\n\t}\n\n\tpublic decode(major: EncodedRevisionTag): RevisionTag {\n\t\tassert(\n\t\t\tmajor === \"root\" || major >= 0,\n\t\t\t0x890 /* Expected final id on decode of detached field index revision */,\n\t\t);\n\t\treturn this.revisionTagCodec.decode(major, {\n\t\t\toriginatorId: this.revisionTagCodec.localSessionId,\n\t\t\tidCompressor: this.idCompressor,\n\t\t\trevision: undefined,\n\t\t});\n\t}\n}\n\nexport function makeDetachedNodeToFieldCodecV1(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: ICodecOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData, FormatV1> {\n\tconst majorCodec = new MajorCodec(revisionTagCodec, options, idCompressor);\n\treturn makeDetachedFieldIndexCodecFromMajorCodec(\n\t\toptions,\n\t\tmajorCodec,\n\t\tversion1,\n\t\tRevisionTagSchema,\n\t);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
6
+ import type { ICodecOptions, IJsonCodec } from "../../codec/index.js";
7
+ import type { RevisionTagCodec } from "../rebase/index.js";
8
+ import { type FormatV2 } from "./detachedFieldIndexFormatV2.js";
9
+ import type { DetachedFieldSummaryData } from "./detachedFieldIndexTypes.js";
10
+ export declare function makeDetachedNodeToFieldCodecV2(revisionTagCodec: RevisionTagCodec, options: ICodecOptions, idCompressor: IIdCompressor): IJsonCodec<DetachedFieldSummaryData, FormatV2>;
11
+ //# sourceMappingURL=detachedFieldIndexCodecV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecV2.d.ts","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecV2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,+BAA+B,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAsB,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EACN,KAAK,QAAQ,EAGb,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,wBAAwB,EAAS,MAAM,8BAA8B,CAAC;AA2CpF,wBAAgB,8BAA8B,CAC7C,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,aAAa,GACzB,UAAU,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAQhD"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.makeDetachedNodeToFieldCodecV2 = void 0;
8
+ const internal_1 = require("@fluidframework/core-utils/internal");
9
+ const detachedFieldIndexFormatV2_js_1 = require("./detachedFieldIndexFormatV2.js");
10
+ const detachedFieldIndexCodecCommon_js_1 = require("./detachedFieldIndexCodecCommon.js");
11
+ const internal_2 = require("@fluidframework/id-compressor/internal");
12
+ class MajorCodec {
13
+ constructor(revisionTagCodec, options, idCompressor) {
14
+ this.revisionTagCodec = revisionTagCodec;
15
+ this.options = options;
16
+ this.idCompressor = idCompressor;
17
+ }
18
+ encode(major) {
19
+ (0, internal_1.assert)(major !== undefined, 0xbfb /* Unexpected undefined revision */);
20
+ const id = this.revisionTagCodec.encode(major);
21
+ if (id !== "root" && id < 0) {
22
+ /**
23
+ * This code path handles the case where the major revision is not finalized.
24
+ * This can happen the SharedTree is being attached to an already attached container.
25
+ */
26
+ (0, internal_1.assert)(major !== "root", 0xbfc /* Major revision cannot be 'root' */);
27
+ const long = this.idCompressor.decompress(major);
28
+ return long;
29
+ }
30
+ return id;
31
+ }
32
+ decode(major) {
33
+ (0, internal_1.assert)(major === "root" || (typeof major === "string" && (0, internal_2.isStableId)(major)) || major >= 0, 0xbfd /* Expected root, stable, or final compressed id */);
34
+ if (typeof major === "string" && (0, internal_2.isStableId)(major)) {
35
+ return this.idCompressor.recompress(major);
36
+ }
37
+ return this.revisionTagCodec.decode(major, {
38
+ originatorId: this.revisionTagCodec.localSessionId,
39
+ idCompressor: this.idCompressor,
40
+ revision: undefined,
41
+ });
42
+ }
43
+ }
44
+ function makeDetachedNodeToFieldCodecV2(revisionTagCodec, options, idCompressor) {
45
+ const majorCodec = new MajorCodec(revisionTagCodec, options, idCompressor);
46
+ return (0, detachedFieldIndexCodecCommon_js_1.makeDetachedFieldIndexCodecFromMajorCodec)(options, majorCodec, detachedFieldIndexFormatV2_js_1.version2, detachedFieldIndexFormatV2_js_1.StableOrFinalRevisionTag);
47
+ }
48
+ exports.makeDetachedNodeToFieldCodecV2 = makeDetachedNodeToFieldCodecV2;
49
+ //# sourceMappingURL=detachedFieldIndexCodecV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE;YAC1C,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,cAAc;YAClD,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,SAAS;SACnB,CAAC,CAAC;IACJ,CAAC;CACD;AAED,SAAgB,8BAA8B,CAC7C,gBAAkC,EAClC,OAAsB,EACtB,YAA2B;IAE3B,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC3E,OAAO,IAAA,4EAAyC,EAC/C,OAAO,EACP,UAAU,EACV,wCAAQ,EACR,wDAAwB,CACxB,CAAC;AACH,CAAC;AAZD,wEAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IIdCompressor, StableId } from \"@fluidframework/id-compressor\";\n\nimport type { ICodecOptions, IJsonCodec } from \"../../codec/index.js\";\nimport type { EncodedRevisionTag, RevisionTagCodec, RevisionTag } from \"../rebase/index.js\";\n\nimport {\n\ttype FormatV2,\n\tStableOrFinalRevisionTag,\n\tversion2,\n} from \"./detachedFieldIndexFormatV2.js\";\nimport type { DetachedFieldSummaryData, Major } from \"./detachedFieldIndexTypes.js\";\nimport { makeDetachedFieldIndexCodecFromMajorCodec } from \"./detachedFieldIndexCodecCommon.js\";\nimport { isStableId } from \"@fluidframework/id-compressor/internal\";\n\nclass MajorCodec implements IJsonCodec<Major> {\n\tpublic constructor(\n\t\tprivate readonly revisionTagCodec: RevisionTagCodec,\n\t\tprivate readonly options: ICodecOptions,\n\t\tprivate readonly idCompressor: IIdCompressor,\n\t) {}\n\n\tpublic encode(major: Major): EncodedRevisionTag | StableId {\n\t\tassert(major !== undefined, 0xbfb /* Unexpected undefined revision */);\n\t\tconst id = this.revisionTagCodec.encode(major);\n\n\t\tif (id !== \"root\" && id < 0) {\n\t\t\t/**\n\t\t\t * This code path handles the case where the major revision is not finalized.\n\t\t\t * This can happen the SharedTree is being attached to an already attached container.\n\t\t\t */\n\t\t\tassert(major !== \"root\", 0xbfc /* Major revision cannot be 'root' */);\n\t\t\tconst long = this.idCompressor.decompress(major);\n\t\t\treturn long;\n\t\t}\n\t\treturn id;\n\t}\n\n\tpublic decode(major: EncodedRevisionTag | StableId): RevisionTag {\n\t\tassert(\n\t\t\tmajor === \"root\" || (typeof major === \"string\" && isStableId(major)) || major >= 0,\n\t\t\t0xbfd /* Expected root, stable, or final compressed id */,\n\t\t);\n\t\tif (typeof major === \"string\" && isStableId(major)) {\n\t\t\treturn this.idCompressor.recompress(major);\n\t\t}\n\t\treturn this.revisionTagCodec.decode(major, {\n\t\t\toriginatorId: this.revisionTagCodec.localSessionId,\n\t\t\tidCompressor: this.idCompressor,\n\t\t\trevision: undefined,\n\t\t});\n\t}\n}\n\nexport function makeDetachedNodeToFieldCodecV2(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: ICodecOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData, FormatV2> {\n\tconst majorCodec = new MajorCodec(revisionTagCodec, options, idCompressor);\n\treturn makeDetachedFieldIndexCodecFromMajorCodec(\n\t\toptions,\n\t\tmajorCodec,\n\t\tversion2,\n\t\tStableOrFinalRevisionTag,\n\t);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IIdCompressor } from "@fluidframework/id-compressor";
6
+ import { type CodecWriteOptions, type ICodecFamily, type IJsonCodec } from "../../codec/index.js";
7
+ import type { RevisionTagCodec } from "../rebase/index.js";
8
+ import type { DetachedFieldSummaryData } from "./detachedFieldIndexTypes.js";
9
+ export declare function makeDetachedFieldIndexCodec(revisionTagCodec: RevisionTagCodec, options: CodecWriteOptions, idCompressor: IIdCompressor): IJsonCodec<DetachedFieldSummaryData>;
10
+ export declare function makeDetachedFieldIndexCodecFamily(revisionTagCodec: RevisionTagCodec, options: CodecWriteOptions, idCompressor: IIdCompressor): ICodecFamily<DetachedFieldSummaryData>;
11
+ //# sourceMappingURL=detachedFieldIndexCodecs.d.ts.map
@@ -0,0 +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;AAEnE,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,YAAY,EACjB,KAAK,UAAU,EAGf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7E,wBAAgB,2BAA2B,CAC1C,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,UAAU,CAAC,wBAAwB,CAAC,CAKtC;AAED,wBAAgB,iCAAiC,CAChD,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,aAAa,GACzB,YAAY,CAAC,wBAAwB,CAAC,CAKxC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.makeDetachedFieldIndexCodecFamily = exports.makeDetachedFieldIndexCodec = void 0;
8
+ const index_js_1 = require("../../codec/index.js");
9
+ const detachedFieldIndexFormatV1_js_1 = require("./detachedFieldIndexFormatV1.js");
10
+ const detachedFieldIndexFormatV2_js_1 = require("./detachedFieldIndexFormatV2.js");
11
+ const detachedFieldIndexCodecV1_js_1 = require("./detachedFieldIndexCodecV1.js");
12
+ const detachedFieldIndexCodecV2_js_1 = require("./detachedFieldIndexCodecV2.js");
13
+ function makeDetachedFieldIndexCodec(revisionTagCodec, options, idCompressor) {
14
+ const family = makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor);
15
+ const writeVersion = options.oldestCompatibleClient < index_js_1.FluidClientVersion.v2_52 ? detachedFieldIndexFormatV1_js_1.version1 : detachedFieldIndexFormatV2_js_1.version2;
16
+ return (0, index_js_1.makeVersionDispatchingCodec)(family, { ...options, writeVersion });
17
+ }
18
+ exports.makeDetachedFieldIndexCodec = makeDetachedFieldIndexCodec;
19
+ function makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor) {
20
+ return (0, index_js_1.makeCodecFamily)([
21
+ [detachedFieldIndexFormatV1_js_1.version1, (0, detachedFieldIndexCodecV1_js_1.makeDetachedNodeToFieldCodecV1)(revisionTagCodec, options, idCompressor)],
22
+ [detachedFieldIndexFormatV2_js_1.version2, (0, detachedFieldIndexCodecV2_js_1.makeDetachedNodeToFieldCodecV2)(revisionTagCodec, options, idCompressor)],
23
+ ]);
24
+ }
25
+ exports.makeDetachedFieldIndexCodecFamily = makeDetachedFieldIndexCodecFamily;
26
+ //# sourceMappingURL=detachedFieldIndexCodecs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachedFieldIndexCodecs.js","sourceRoot":"","sources":["../../../src/core/tree/detachedFieldIndexCodecs.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,mDAO8B;AAG9B,mFAA2D;AAC3D,mFAA2D;AAC3D,iFAAgF;AAChF,iFAAgF;AAGhF,SAAgB,2BAA2B,CAC1C,gBAAkC,EAClC,OAA0B,EAC1B,YAA2B;IAE3B,MAAM,MAAM,GAAG,iCAAiC,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1F,MAAM,YAAY,GACjB,OAAO,CAAC,sBAAsB,GAAG,6BAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,wCAAQ,CAAC,CAAC,CAAC,wCAAQ,CAAC;IACjF,OAAO,IAAA,sCAA2B,EAAC,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;AAC1E,CAAC;AATD,kEASC;AAED,SAAgB,iCAAiC,CAChD,gBAAkC,EAClC,OAA0B,EAC1B,YAA2B;IAE3B,OAAO,IAAA,0BAAe,EAAC;QACtB,CAAC,wCAAQ,EAAE,IAAA,6DAA8B,EAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACnF,CAAC,wCAAQ,EAAE,IAAA,6DAA8B,EAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;KACnF,CAAC,CAAC;AACJ,CAAC;AATD,8EASC","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\";\n\nimport {\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 { version1 } from \"./detachedFieldIndexFormatV1.js\";\nimport { version2 } from \"./detachedFieldIndexFormatV2.js\";\nimport { makeDetachedNodeToFieldCodecV1 } from \"./detachedFieldIndexCodecV1.js\";\nimport { makeDetachedNodeToFieldCodecV2 } from \"./detachedFieldIndexCodecV2.js\";\nimport type { DetachedFieldSummaryData } from \"./detachedFieldIndexTypes.js\";\n\nexport function makeDetachedFieldIndexCodec(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): IJsonCodec<DetachedFieldSummaryData> {\n\tconst family = makeDetachedFieldIndexCodecFamily(revisionTagCodec, options, idCompressor);\n\tconst writeVersion =\n\t\toptions.oldestCompatibleClient < FluidClientVersion.v2_52 ? version1 : version2;\n\treturn makeVersionDispatchingCodec(family, { ...options, writeVersion });\n}\n\nexport function makeDetachedFieldIndexCodecFamily(\n\trevisionTagCodec: RevisionTagCodec,\n\toptions: CodecWriteOptions,\n\tidCompressor: IIdCompressor,\n): ICodecFamily<DetachedFieldSummaryData> {\n\treturn makeCodecFamily([\n\t\t[version1, makeDetachedNodeToFieldCodecV1(revisionTagCodec, options, idCompressor)],\n\t\t[version2, makeDetachedNodeToFieldCodecV2(revisionTagCodec, options, idCompressor)],\n\t]);\n}\n"]}
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type Static, type TSchema } from "@sinclair/typebox";
6
+ import type { ForestRootId } from "./detachedFieldIndexTypes.js";
7
+ /**
8
+ * The ID of a detached node. Is not globally unique on.
9
+ * A `RevisionTag` + `DetachId` pair is globally unique and eventually consistent across clients.
10
+ */
11
+ export declare const DetachId: import("@sinclair/typebox").TNumber;
12
+ /**
13
+ * The ID of a root node in the forest associated with the owning checkout. Is unique for that forest.
14
+ * Is not consistent across clients.
15
+ */
16
+ export declare const ForestRootIdSchema: import("@sinclair/typebox").TUnsafe<ForestRootId>;
17
+ /**
18
+ * A mapping from a range of the detached node IDs the corresponding range root IDs.
19
+ * The detached node IDs need to be qualified with a revision (stored in the containing `EncodedRootsForRevision`).
20
+ * Note: the length of the range (currently always 1) can be looked up in the forest.
21
+ */
22
+ export declare const RootRange: import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>;
23
+ export type RootRange = Static<typeof RootRange>;
24
+ export declare const RootRanges: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>>;
25
+ export type RootRanges = Static<typeof RootRanges>;
26
+ /**
27
+ * For all the roots detached in a revision, represents a mapping from the detached node ID to corresponding root ID.
28
+ */
29
+ export declare const EncodedRootsForRevision: <Schema extends TSchema>(tRevisionTag: Schema) => import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[Schema, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[Schema, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>]>;
30
+ export type EncodedRootsForRevision = Static<ReturnType<typeof EncodedRootsForRevision>>;
31
+ export declare const Format: <TVersion extends number, TRevisionTagSchema extends TSchema>(tVersion: TVersion, tRevisionTag: TRevisionTagSchema) => import("@sinclair/typebox").TObject<{
32
+ version: import("@sinclair/typebox").TLiteral<TVersion>;
33
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TTuple<[TRevisionTagSchema, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TTuple<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>>]>, import("@sinclair/typebox").TTuple<[TRevisionTagSchema, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TUnsafe<ForestRootId>]>]>>;
34
+ maxId: import("@sinclair/typebox").TUnsafe<ForestRootId>;
35
+ }>;
36
+ export type Format = Static<ReturnType<typeof Format>>;
37
+ //# sourceMappingURL=detachedFieldIndexFormatCommon.d.ts.map