@fluidframework/tree 2.70.0 → 2.72.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 (684) hide show
  1. package/CHANGELOG.md +84 -40
  2. package/api-report/tree.alpha.api.md +52 -22
  3. package/api-report/tree.beta.api.md +45 -0
  4. package/api-report/tree.legacy.beta.api.md +45 -0
  5. package/dist/alpha.d.ts +12 -7
  6. package/dist/api.js +1 -1
  7. package/dist/api.js.map +1 -1
  8. package/dist/beta.d.ts +8 -0
  9. package/dist/codec/codec.d.ts +16 -1
  10. package/dist/codec/codec.d.ts.map +1 -1
  11. package/dist/codec/codec.js +16 -3
  12. package/dist/codec/codec.js.map +1 -1
  13. package/dist/codec/discriminatedUnions.d.ts +1 -1
  14. package/dist/codec/discriminatedUnions.js +1 -1
  15. package/dist/codec/discriminatedUnions.js.map +1 -1
  16. package/dist/core/index.d.ts +1 -1
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +2 -2
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/schema-stored/index.d.ts +1 -1
  21. package/dist/core/schema-stored/index.d.ts.map +1 -1
  22. package/dist/core/schema-stored/index.js +2 -2
  23. package/dist/core/schema-stored/index.js.map +1 -1
  24. package/dist/core/schema-stored/schema.d.ts +6 -6
  25. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  26. package/dist/core/schema-stored/schema.js +6 -7
  27. package/dist/core/schema-stored/schema.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
  29. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  30. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  31. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
  32. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  33. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
  34. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  35. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  36. package/dist/core/tree/detachedFieldIndexCodecV2.js +3 -1
  37. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  38. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
  39. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  40. package/dist/core/tree/detachedFieldIndexCodecs.js +29 -8
  41. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  42. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
  43. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  44. package/dist/core/tree/detachedFieldIndexFormatCommon.js +8 -1
  45. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  46. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
  47. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  48. package/dist/core/tree/detachedFieldIndexFormatV1.js +3 -3
  49. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  50. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  51. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  52. package/dist/core/tree/detachedFieldIndexFormatV2.js +3 -3
  53. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  54. package/dist/core/tree/index.d.ts +2 -1
  55. package/dist/core/tree/index.d.ts.map +1 -1
  56. package/dist/core/tree/index.js.map +1 -1
  57. package/dist/external-utilities/typeboxValidator.js +1 -1
  58. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  59. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
  60. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/codecs.js +12 -8
  62. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  63. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  65. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
  66. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  67. package/dist/feature-libraries/chunked-forest/codec/format.js +9 -4
  68. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  69. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  70. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/codec/index.js +1 -2
  72. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +1 -1
  75. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  77. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/index.js +1 -2
  79. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  80. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -9
  81. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  82. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +3 -21
  83. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  84. package/dist/feature-libraries/forest-summary/codec.d.ts +4 -5
  85. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  86. package/dist/feature-libraries/forest-summary/codec.js +15 -4
  87. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  88. package/dist/feature-libraries/forest-summary/forestSummarizer.js +1 -1
  89. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  90. package/dist/feature-libraries/forest-summary/format.d.ts +8 -1
  91. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  92. package/dist/feature-libraries/forest-summary/format.js +8 -3
  93. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  94. package/dist/feature-libraries/forest-summary/index.d.ts +2 -1
  95. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  96. package/dist/feature-libraries/forest-summary/index.js +3 -1
  97. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  98. package/dist/feature-libraries/index.d.ts +3 -3
  99. package/dist/feature-libraries/index.d.ts.map +1 -1
  100. package/dist/feature-libraries/index.js +2 -2
  101. package/dist/feature-libraries/index.js.map +1 -1
  102. package/dist/feature-libraries/schema-edits/index.d.ts +1 -1
  103. package/dist/feature-libraries/schema-edits/index.d.ts.map +1 -1
  104. package/dist/feature-libraries/schema-edits/index.js.map +1 -1
  105. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
  106. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  107. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +5 -4
  108. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  109. package/dist/feature-libraries/schema-index/codec.d.ts +10 -10
  110. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  111. package/dist/feature-libraries/schema-index/codec.js +22 -18
  112. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  113. package/dist/feature-libraries/schema-index/formatV1.d.ts +2 -2
  114. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  115. package/dist/feature-libraries/schema-index/formatV1.js +1 -1
  116. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
  117. package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -2
  118. package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  119. package/dist/feature-libraries/schema-index/formatV2.js +1 -1
  120. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  121. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  122. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  123. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  124. package/dist/index.d.ts +2 -2
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +6 -2
  127. package/dist/index.js.map +1 -1
  128. package/dist/legacy.d.ts +8 -0
  129. package/dist/packageVersion.d.ts +1 -1
  130. package/dist/packageVersion.js +1 -1
  131. package/dist/packageVersion.js.map +1 -1
  132. package/dist/shared-tree/independentView.d.ts +75 -6
  133. package/dist/shared-tree/independentView.d.ts.map +1 -1
  134. package/dist/shared-tree/independentView.js +116 -43
  135. package/dist/shared-tree/independentView.js.map +1 -1
  136. package/dist/shared-tree/index.d.ts +2 -1
  137. package/dist/shared-tree/index.d.ts.map +1 -1
  138. package/dist/shared-tree/index.js +6 -1
  139. package/dist/shared-tree/index.js.map +1 -1
  140. package/dist/shared-tree/sharedTree.d.ts +12 -16
  141. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  142. package/dist/shared-tree/sharedTree.js +105 -130
  143. package/dist/shared-tree/sharedTree.js.map +1 -1
  144. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
  145. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  146. package/dist/shared-tree/sharedTreeChangeCodecs.js +12 -11
  147. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  148. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  149. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  150. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  151. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  152. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  153. package/dist/shared-tree/treeAlpha.js +4 -2
  154. package/dist/shared-tree/treeAlpha.js.map +1 -1
  155. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  156. package/dist/shared-tree/treeCheckout.js +1 -3
  157. package/dist/shared-tree/treeCheckout.js.map +1 -1
  158. package/dist/shared-tree-core/editManagerCodecs.d.ts +19 -6
  159. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  160. package/dist/shared-tree-core/editManagerCodecs.js +35 -17
  161. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  162. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
  163. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  164. package/dist/shared-tree-core/editManagerFormatCommons.js +43 -1
  165. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  166. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  167. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  168. package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -4
  169. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  170. package/dist/shared-tree-core/editManagerFormatV5.d.ts +2 -2
  171. package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
  172. package/dist/shared-tree-core/editManagerFormatV5.js +1 -1
  173. package/dist/shared-tree-core/editManagerFormatV5.js.map +1 -1
  174. package/dist/shared-tree-core/index.d.ts +5 -3
  175. package/dist/shared-tree-core/index.d.ts.map +1 -1
  176. package/dist/shared-tree-core/index.js +11 -3
  177. package/dist/shared-tree-core/index.js.map +1 -1
  178. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
  179. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  180. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  181. package/dist/shared-tree-core/messageCodecV5.d.ts +2 -1
  182. package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -1
  183. package/dist/shared-tree-core/messageCodecV5.js.map +1 -1
  184. package/dist/shared-tree-core/messageCodecs.d.ts +19 -6
  185. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  186. package/dist/shared-tree-core/messageCodecs.js +38 -21
  187. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  188. package/dist/shared-tree-core/messageFormat.d.ts +50 -0
  189. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -0
  190. package/dist/shared-tree-core/messageFormat.js +51 -0
  191. package/dist/shared-tree-core/messageFormat.js.map +1 -0
  192. package/dist/shared-tree-core/sharedTreeCore.d.ts +8 -8
  193. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  194. package/dist/shared-tree-core/sharedTreeCore.js +3 -3
  195. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  196. package/dist/simple-tree/api/discrepancies.d.ts +2 -2
  197. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  198. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  199. package/dist/simple-tree/api/incrementalAllowedTypes.js +1 -1
  200. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  201. package/dist/simple-tree/api/index.d.ts +3 -2
  202. package/dist/simple-tree/api/index.d.ts.map +1 -1
  203. package/dist/simple-tree/api/index.js +4 -1
  204. package/dist/simple-tree/api/index.js.map +1 -1
  205. package/dist/simple-tree/api/schemaFactory.d.ts +2 -2
  206. package/dist/simple-tree/api/schemaFactory.js +2 -2
  207. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  208. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
  209. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  210. package/dist/simple-tree/api/schemaFactoryAlpha.js +1 -52
  211. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  212. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
  213. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  214. package/dist/simple-tree/api/schemaFactoryBeta.js +61 -7
  215. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  216. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  217. package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -0
  218. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  219. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  220. package/dist/simple-tree/api/schemaFromSimple.js +15 -8
  221. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  222. package/dist/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
  223. package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
  224. package/dist/simple-tree/api/simpleSchemaCodec.js +292 -0
  225. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -0
  226. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  227. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +4 -2
  228. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  229. package/dist/simple-tree/api/storedSchema.d.ts +2 -2
  230. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  231. package/dist/simple-tree/api/storedSchema.js +8 -6
  232. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  233. package/dist/simple-tree/api/tree.d.ts +2 -2
  234. package/dist/simple-tree/api/tree.js.map +1 -1
  235. package/dist/simple-tree/api/typesUnsafe.d.ts +6 -6
  236. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  237. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +17 -1
  238. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  239. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +71 -7
  240. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  241. package/dist/simple-tree/core/allowedTypes.d.ts +12 -7
  242. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
  243. package/dist/simple-tree/core/allowedTypes.js +18 -5
  244. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  245. package/dist/simple-tree/core/treeNode.js +1 -1
  246. package/dist/simple-tree/core/treeNode.js.map +1 -1
  247. package/dist/simple-tree/fieldSchema.d.ts +2 -1
  248. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  249. package/dist/simple-tree/fieldSchema.js +10 -0
  250. package/dist/simple-tree/fieldSchema.js.map +1 -1
  251. package/dist/simple-tree/index.d.ts +3 -2
  252. package/dist/simple-tree/index.d.ts.map +1 -1
  253. package/dist/simple-tree/index.js +4 -0
  254. package/dist/simple-tree/index.js.map +1 -1
  255. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  256. package/dist/simple-tree/node-kinds/array/arrayNode.js +7 -1
  257. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  258. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  259. package/dist/simple-tree/node-kinds/map/mapNode.js +7 -1
  260. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  261. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +17 -0
  262. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  263. package/dist/simple-tree/node-kinds/object/objectNode.js +21 -8
  264. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  265. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  266. package/dist/simple-tree/node-kinds/record/recordNode.js +8 -2
  267. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  268. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +16 -0
  269. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  270. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  271. package/dist/simple-tree/simpleSchema.d.ts +30 -6
  272. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  273. package/dist/simple-tree/simpleSchema.js.map +1 -1
  274. package/dist/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
  275. package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
  276. package/dist/simple-tree/simpleSchemaFormatV1.js +115 -0
  277. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -0
  278. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  279. package/dist/simple-tree/toStoredSchema.js +6 -3
  280. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  281. package/dist/tableSchema.d.ts.map +1 -1
  282. package/dist/tableSchema.js +1 -1
  283. package/dist/tableSchema.js.map +1 -1
  284. package/dist/treeFactory.d.ts +3 -1
  285. package/dist/treeFactory.d.ts.map +1 -1
  286. package/dist/treeFactory.js +26 -2
  287. package/dist/treeFactory.js.map +1 -1
  288. package/dist/util/brand.d.ts +31 -2
  289. package/dist/util/brand.d.ts.map +1 -1
  290. package/dist/util/brand.js +28 -2
  291. package/dist/util/brand.js.map +1 -1
  292. package/dist/util/brandedMap.d.ts +3 -1
  293. package/dist/util/brandedMap.d.ts.map +1 -1
  294. package/dist/util/brandedMap.js.map +1 -1
  295. package/dist/util/index.d.ts +1 -1
  296. package/dist/util/index.d.ts.map +1 -1
  297. package/dist/util/index.js +3 -2
  298. package/dist/util/index.js.map +1 -1
  299. package/dist/util/referenceCounting.d.ts.map +1 -1
  300. package/dist/util/referenceCounting.js +1 -0
  301. package/dist/util/referenceCounting.js.map +1 -1
  302. package/lib/alpha.d.ts +12 -7
  303. package/lib/api.js +2 -2
  304. package/lib/api.js.map +1 -1
  305. package/lib/beta.d.ts +8 -0
  306. package/lib/codec/codec.d.ts +16 -1
  307. package/lib/codec/codec.d.ts.map +1 -1
  308. package/lib/codec/codec.js +16 -3
  309. package/lib/codec/codec.js.map +1 -1
  310. package/lib/codec/discriminatedUnions.d.ts +1 -1
  311. package/lib/codec/discriminatedUnions.js +1 -1
  312. package/lib/codec/discriminatedUnions.js.map +1 -1
  313. package/lib/core/index.d.ts +1 -1
  314. package/lib/core/index.d.ts.map +1 -1
  315. package/lib/core/index.js +1 -1
  316. package/lib/core/index.js.map +1 -1
  317. package/lib/core/schema-stored/index.d.ts +1 -1
  318. package/lib/core/schema-stored/index.d.ts.map +1 -1
  319. package/lib/core/schema-stored/index.js +1 -1
  320. package/lib/core/schema-stored/index.js.map +1 -1
  321. package/lib/core/schema-stored/schema.d.ts +6 -6
  322. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  323. package/lib/core/schema-stored/schema.js +6 -7
  324. package/lib/core/schema-stored/schema.js.map +1 -1
  325. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
  326. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  327. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  328. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
  329. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  330. package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
  331. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  332. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  333. package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -2
  334. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  335. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
  336. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  337. package/lib/core/tree/detachedFieldIndexCodecs.js +29 -8
  338. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  339. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
  340. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  341. package/lib/core/tree/detachedFieldIndexFormatCommon.js +7 -0
  342. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  343. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
  344. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  345. package/lib/core/tree/detachedFieldIndexFormatV1.js +3 -3
  346. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  347. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  348. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  349. package/lib/core/tree/detachedFieldIndexFormatV2.js +3 -3
  350. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  351. package/lib/core/tree/index.d.ts +2 -1
  352. package/lib/core/tree/index.d.ts.map +1 -1
  353. package/lib/core/tree/index.js +1 -1
  354. package/lib/core/tree/index.js.map +1 -1
  355. package/lib/external-utilities/typeboxValidator.js +1 -1
  356. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  357. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
  358. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  359. package/lib/feature-libraries/chunked-forest/codec/codecs.js +13 -8
  360. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  361. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
  362. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  363. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
  364. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  365. package/lib/feature-libraries/chunked-forest/codec/format.js +8 -3
  366. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  367. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  368. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  369. package/lib/feature-libraries/chunked-forest/codec/index.js +2 -2
  370. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  371. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  372. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  373. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  374. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  375. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  376. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  377. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  378. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -9
  379. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  380. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +2 -20
  381. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  382. package/lib/feature-libraries/forest-summary/codec.d.ts +4 -5
  383. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  384. package/lib/feature-libraries/forest-summary/codec.js +16 -5
  385. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  386. package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -1
  387. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  388. package/lib/feature-libraries/forest-summary/format.d.ts +8 -1
  389. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  390. package/lib/feature-libraries/forest-summary/format.js +7 -2
  391. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  392. package/lib/feature-libraries/forest-summary/index.d.ts +2 -1
  393. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  394. package/lib/feature-libraries/forest-summary/index.js +1 -0
  395. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  396. package/lib/feature-libraries/index.d.ts +3 -3
  397. package/lib/feature-libraries/index.d.ts.map +1 -1
  398. package/lib/feature-libraries/index.js +2 -2
  399. package/lib/feature-libraries/index.js.map +1 -1
  400. package/lib/feature-libraries/schema-edits/index.d.ts +1 -1
  401. package/lib/feature-libraries/schema-edits/index.d.ts.map +1 -1
  402. package/lib/feature-libraries/schema-edits/index.js.map +1 -1
  403. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
  404. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  405. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +6 -5
  406. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  407. package/lib/feature-libraries/schema-index/codec.d.ts +10 -10
  408. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  409. package/lib/feature-libraries/schema-index/codec.js +24 -20
  410. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  411. package/lib/feature-libraries/schema-index/formatV1.d.ts +2 -2
  412. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  413. package/lib/feature-libraries/schema-index/formatV1.js +2 -2
  414. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -1
  415. package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -2
  416. package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  417. package/lib/feature-libraries/schema-index/formatV2.js +2 -2
  418. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
  419. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  420. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  421. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  422. package/lib/index.d.ts +2 -2
  423. package/lib/index.d.ts.map +1 -1
  424. package/lib/index.js +2 -2
  425. package/lib/index.js.map +1 -1
  426. package/lib/legacy.d.ts +8 -0
  427. package/lib/packageVersion.d.ts +1 -1
  428. package/lib/packageVersion.js +1 -1
  429. package/lib/packageVersion.js.map +1 -1
  430. package/lib/shared-tree/independentView.d.ts +75 -6
  431. package/lib/shared-tree/independentView.d.ts.map +1 -1
  432. package/lib/shared-tree/independentView.js +111 -39
  433. package/lib/shared-tree/independentView.js.map +1 -1
  434. package/lib/shared-tree/index.d.ts +2 -1
  435. package/lib/shared-tree/index.d.ts.map +1 -1
  436. package/lib/shared-tree/index.js +2 -1
  437. package/lib/shared-tree/index.js.map +1 -1
  438. package/lib/shared-tree/sharedTree.d.ts +12 -16
  439. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  440. package/lib/shared-tree/sharedTree.js +108 -133
  441. package/lib/shared-tree/sharedTree.js.map +1 -1
  442. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
  443. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  444. package/lib/shared-tree/sharedTreeChangeCodecs.js +7 -6
  445. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  446. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  447. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  448. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  449. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  450. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  451. package/lib/shared-tree/treeAlpha.js +5 -3
  452. package/lib/shared-tree/treeAlpha.js.map +1 -1
  453. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  454. package/lib/shared-tree/treeCheckout.js +1 -3
  455. package/lib/shared-tree/treeCheckout.js.map +1 -1
  456. package/lib/shared-tree-core/editManagerCodecs.d.ts +19 -6
  457. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  458. package/lib/shared-tree-core/editManagerCodecs.js +32 -16
  459. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  460. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
  461. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  462. package/lib/shared-tree-core/editManagerFormatCommons.js +42 -0
  463. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  464. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  465. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  466. package/lib/shared-tree-core/editManagerFormatV1toV4.js +5 -5
  467. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  468. package/lib/shared-tree-core/editManagerFormatV5.d.ts +2 -2
  469. package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
  470. package/lib/shared-tree-core/editManagerFormatV5.js +2 -2
  471. package/lib/shared-tree-core/editManagerFormatV5.js.map +1 -1
  472. package/lib/shared-tree-core/index.d.ts +5 -3
  473. package/lib/shared-tree-core/index.d.ts.map +1 -1
  474. package/lib/shared-tree-core/index.js +4 -2
  475. package/lib/shared-tree-core/index.js.map +1 -1
  476. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
  477. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  478. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  479. package/lib/shared-tree-core/messageCodecV5.d.ts +2 -1
  480. package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -1
  481. package/lib/shared-tree-core/messageCodecV5.js.map +1 -1
  482. package/lib/shared-tree-core/messageCodecs.d.ts +19 -6
  483. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  484. package/lib/shared-tree-core/messageCodecs.js +35 -20
  485. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  486. package/lib/shared-tree-core/messageFormat.d.ts +50 -0
  487. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -0
  488. package/lib/shared-tree-core/messageFormat.js +48 -0
  489. package/lib/shared-tree-core/messageFormat.js.map +1 -0
  490. package/lib/shared-tree-core/sharedTreeCore.d.ts +8 -8
  491. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  492. package/lib/shared-tree-core/sharedTreeCore.js +3 -3
  493. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  494. package/lib/simple-tree/api/discrepancies.d.ts +2 -2
  495. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  496. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  497. package/lib/simple-tree/api/incrementalAllowedTypes.js +1 -1
  498. package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  499. package/lib/simple-tree/api/index.d.ts +3 -2
  500. package/lib/simple-tree/api/index.d.ts.map +1 -1
  501. package/lib/simple-tree/api/index.js +1 -0
  502. package/lib/simple-tree/api/index.js.map +1 -1
  503. package/lib/simple-tree/api/schemaFactory.d.ts +2 -2
  504. package/lib/simple-tree/api/schemaFactory.js +2 -2
  505. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  506. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
  507. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  508. package/lib/simple-tree/api/schemaFactoryAlpha.js +1 -52
  509. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  510. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
  511. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  512. package/lib/simple-tree/api/schemaFactoryBeta.js +58 -4
  513. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  514. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  515. package/lib/simple-tree/api/schemaFactoryRecursive.js +1 -0
  516. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  517. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  518. package/lib/simple-tree/api/schemaFromSimple.js +15 -8
  519. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  520. package/lib/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
  521. package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
  522. package/lib/simple-tree/api/simpleSchemaCodec.js +264 -0
  523. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -0
  524. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  525. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +4 -2
  526. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  527. package/lib/simple-tree/api/storedSchema.d.ts +2 -2
  528. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  529. package/lib/simple-tree/api/storedSchema.js +5 -3
  530. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  531. package/lib/simple-tree/api/tree.d.ts +2 -2
  532. package/lib/simple-tree/api/tree.js.map +1 -1
  533. package/lib/simple-tree/api/typesUnsafe.d.ts +6 -6
  534. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  535. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +17 -1
  536. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  537. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +69 -7
  538. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  539. package/lib/simple-tree/core/allowedTypes.d.ts +12 -7
  540. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
  541. package/lib/simple-tree/core/allowedTypes.js +19 -6
  542. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  543. package/lib/simple-tree/core/treeNode.js +1 -1
  544. package/lib/simple-tree/core/treeNode.js.map +1 -1
  545. package/lib/simple-tree/fieldSchema.d.ts +2 -1
  546. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  547. package/lib/simple-tree/fieldSchema.js +10 -0
  548. package/lib/simple-tree/fieldSchema.js.map +1 -1
  549. package/lib/simple-tree/index.d.ts +3 -2
  550. package/lib/simple-tree/index.d.ts.map +1 -1
  551. package/lib/simple-tree/index.js +1 -0
  552. package/lib/simple-tree/index.js.map +1 -1
  553. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  554. package/lib/simple-tree/node-kinds/array/arrayNode.js +9 -3
  555. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  556. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  557. package/lib/simple-tree/node-kinds/map/mapNode.js +9 -3
  558. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  559. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +17 -0
  560. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  561. package/lib/simple-tree/node-kinds/object/objectNode.js +22 -9
  562. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  563. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  564. package/lib/simple-tree/node-kinds/record/recordNode.js +10 -4
  565. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  566. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +16 -0
  567. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  568. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  569. package/lib/simple-tree/simpleSchema.d.ts +30 -6
  570. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  571. package/lib/simple-tree/simpleSchema.js.map +1 -1
  572. package/lib/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
  573. package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
  574. package/lib/simple-tree/simpleSchemaFormatV1.js +112 -0
  575. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -0
  576. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  577. package/lib/simple-tree/toStoredSchema.js +6 -3
  578. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  579. package/lib/tableSchema.d.ts.map +1 -1
  580. package/lib/tableSchema.js +1 -1
  581. package/lib/tableSchema.js.map +1 -1
  582. package/lib/treeFactory.d.ts +3 -1
  583. package/lib/treeFactory.d.ts.map +1 -1
  584. package/lib/treeFactory.js +23 -1
  585. package/lib/treeFactory.js.map +1 -1
  586. package/lib/util/brand.d.ts +31 -2
  587. package/lib/util/brand.d.ts.map +1 -1
  588. package/lib/util/brand.js +26 -1
  589. package/lib/util/brand.js.map +1 -1
  590. package/lib/util/brandedMap.d.ts +3 -1
  591. package/lib/util/brandedMap.d.ts.map +1 -1
  592. package/lib/util/brandedMap.js.map +1 -1
  593. package/lib/util/index.d.ts +1 -1
  594. package/lib/util/index.d.ts.map +1 -1
  595. package/lib/util/index.js +1 -1
  596. package/lib/util/index.js.map +1 -1
  597. package/lib/util/referenceCounting.d.ts.map +1 -1
  598. package/lib/util/referenceCounting.js +1 -0
  599. package/lib/util/referenceCounting.js.map +1 -1
  600. package/package.json +26 -26
  601. package/src/api.ts +2 -2
  602. package/src/codec/codec.ts +17 -3
  603. package/src/codec/discriminatedUnions.ts +1 -1
  604. package/src/core/index.ts +1 -2
  605. package/src/core/schema-stored/index.ts +1 -2
  606. package/src/core/schema-stored/schema.ts +10 -7
  607. package/src/core/tree/detachedFieldIndexCodecCommon.ts +2 -1
  608. package/src/core/tree/detachedFieldIndexCodecV1.ts +4 -2
  609. package/src/core/tree/detachedFieldIndexCodecV2.ts +4 -6
  610. package/src/core/tree/detachedFieldIndexCodecs.ts +33 -11
  611. package/src/core/tree/detachedFieldIndexFormatCommon.ts +17 -2
  612. package/src/core/tree/detachedFieldIndexFormatV1.ts +6 -4
  613. package/src/core/tree/detachedFieldIndexFormatV2.ts +6 -4
  614. package/src/core/tree/index.ts +2 -4
  615. package/src/external-utilities/typeboxValidator.ts +1 -1
  616. package/src/feature-libraries/chunked-forest/codec/codecs.ts +18 -13
  617. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -2
  618. package/src/feature-libraries/chunked-forest/codec/format.ts +15 -4
  619. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -2
  620. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +2 -2
  621. package/src/feature-libraries/chunked-forest/index.ts +0 -1
  622. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +2 -29
  623. package/src/feature-libraries/forest-summary/codec.ts +24 -9
  624. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -1
  625. package/src/feature-libraries/forest-summary/format.ts +12 -2
  626. package/src/feature-libraries/forest-summary/index.ts +2 -1
  627. package/src/feature-libraries/index.ts +1 -2
  628. package/src/feature-libraries/schema-edits/index.ts +0 -1
  629. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +16 -16
  630. package/src/feature-libraries/schema-index/codec.ts +34 -22
  631. package/src/feature-libraries/schema-index/formatV1.ts +2 -2
  632. package/src/feature-libraries/schema-index/formatV2.ts +2 -2
  633. package/src/feature-libraries/schema-index/schemaSummarizer.ts +2 -1
  634. package/src/index.ts +6 -1
  635. package/src/packageVersion.ts +1 -1
  636. package/src/shared-tree/independentView.ts +161 -75
  637. package/src/shared-tree/index.ts +4 -0
  638. package/src/shared-tree/sharedTree.ts +137 -175
  639. package/src/shared-tree/sharedTreeChangeCodecs.ts +15 -9
  640. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  641. package/src/shared-tree/treeAlpha.ts +6 -5
  642. package/src/shared-tree/treeCheckout.ts +1 -3
  643. package/src/shared-tree-core/editManagerCodecs.ts +56 -19
  644. package/src/shared-tree-core/editManagerFormatCommons.ts +47 -0
  645. package/src/shared-tree-core/editManagerFormatV1toV4.ts +10 -5
  646. package/src/shared-tree-core/editManagerFormatV5.ts +3 -3
  647. package/src/shared-tree-core/index.ts +11 -5
  648. package/src/shared-tree-core/messageCodecV1ToV4.ts +6 -1
  649. package/src/shared-tree-core/messageCodecV5.ts +2 -1
  650. package/src/shared-tree-core/messageCodecs.ts +60 -26
  651. package/src/shared-tree-core/messageFormat.ts +56 -0
  652. package/src/shared-tree-core/sharedTreeCore.ts +11 -13
  653. package/src/simple-tree/api/discrepancies.ts +2 -2
  654. package/src/simple-tree/api/incrementalAllowedTypes.ts +1 -1
  655. package/src/simple-tree/api/index.ts +6 -2
  656. package/src/simple-tree/api/schemaFactory.ts +2 -2
  657. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -168
  658. package/src/simple-tree/api/schemaFactoryBeta.ts +180 -14
  659. package/src/simple-tree/api/schemaFactoryRecursive.ts +2 -0
  660. package/src/simple-tree/api/schemaFromSimple.ts +23 -17
  661. package/src/simple-tree/api/simpleSchemaCodec.ts +360 -0
  662. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +8 -2
  663. package/src/simple-tree/api/storedSchema.ts +8 -5
  664. package/src/simple-tree/api/tree.ts +2 -2
  665. package/src/simple-tree/api/typesUnsafe.ts +6 -6
  666. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +76 -7
  667. package/src/simple-tree/core/allowedTypes.ts +29 -16
  668. package/src/simple-tree/core/treeNode.ts +2 -2
  669. package/src/simple-tree/fieldSchema.ts +14 -1
  670. package/src/simple-tree/index.ts +6 -1
  671. package/src/simple-tree/node-kinds/array/arrayNode.ts +11 -2
  672. package/src/simple-tree/node-kinds/map/mapNode.ts +11 -2
  673. package/src/simple-tree/node-kinds/object/objectNode.ts +57 -21
  674. package/src/simple-tree/node-kinds/record/recordNode.ts +12 -3
  675. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +16 -0
  676. package/src/simple-tree/simpleSchema.ts +32 -6
  677. package/src/simple-tree/simpleSchemaFormatV1.ts +179 -0
  678. package/src/simple-tree/toStoredSchema.ts +12 -3
  679. package/src/tableSchema.ts +5 -2
  680. package/src/treeFactory.ts +33 -1
  681. package/src/util/brand.ts +40 -2
  682. package/src/util/brandedMap.ts +3 -1
  683. package/src/util/index.ts +1 -0
  684. package/src/util/referenceCounting.ts +1 -0
@@ -0,0 +1,264 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { objectToMap } from "../../util/index.js";
6
+ import { unreachableCase, transformMapValues } from "@fluidframework/core-utils/internal";
7
+ import { NodeKind } from "../core/index.js";
8
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
+ import * as Format from "../simpleSchemaFormatV1.js";
10
+ import { DiscriminatedUnionDispatcher, extractJsonValidator, FormatValidatorNoOp, } from "../../codec/index.js";
11
+ /**
12
+ * Encodes a simple schema (view or stored) into a serializable format.
13
+ * @remarks The JSON-compatible schema returned from this method is only intended for use in snapshots/comparisons of schemas.
14
+ * It is not possible to reconstruct a full schema (including metadata and persistedMetadata) from the encoded format.
15
+ * @param treeSchema - The tree schema to convert.
16
+ * @returns A serializable representation of the schema.
17
+ *
18
+ * @alpha
19
+ */
20
+ export function encodeSimpleSchema(simpleSchema) {
21
+ // Convert types to serializable forms
22
+ const encodedDefinitions = {};
23
+ for (const [identifier, schema] of simpleSchema.definitions) {
24
+ const encodedDefinition = encodeNodeSchema(schema);
25
+ encodedDefinitions[identifier] = encodedDefinition;
26
+ }
27
+ const encodedSchema = {
28
+ version: Format.SimpleSchemaFormatVersion.v1,
29
+ root: encodeField(simpleSchema.root),
30
+ definitions: encodedDefinitions,
31
+ };
32
+ return encodedSchema;
33
+ }
34
+ /**
35
+ * Decodes a JSON-compatible schema into a simple schema.
36
+ * @param encodedSchema - The encoded schema to decode.
37
+ * @param validator - The format validator to use to validate the encoded schema.
38
+ * @returns A decoded simple schema.
39
+ * @throws Will throw a usage error if the encoded schema is not in the expected format.
40
+ *
41
+ * @alpha
42
+ */
43
+ export function decodeSimpleSchema(encodedSchema, validator) {
44
+ const effectiveValidator = validator ?? FormatValidatorNoOp;
45
+ const compiledValidator = extractJsonValidator(effectiveValidator).compile(Format.SimpleTreeSchemaFormat);
46
+ if (!compiledValidator.check(encodedSchema)) {
47
+ throw new UsageError("The provided simple schema is not valid according to the schema format.");
48
+ }
49
+ return {
50
+ root: decodeSimpleFieldSchema(encodedSchema.root),
51
+ definitions: new Map(transformMapValues(objectToMap(encodedSchema.definitions), (value, key) => {
52
+ return decodeNodeSchema(value);
53
+ })),
54
+ };
55
+ }
56
+ /**
57
+ * Encodes a node schema to a serializable object.
58
+ * @param schema - The node schema to convert.
59
+ * @returns A serializable representation of the node schema.
60
+ */
61
+ function encodeNodeSchema(schema) {
62
+ const kind = schema.kind;
63
+ switch (kind) {
64
+ case NodeKind.Leaf:
65
+ return { leaf: encodeLeafNode(schema) };
66
+ case NodeKind.Array:
67
+ return { array: encodeContainerNode(schema) };
68
+ case NodeKind.Map:
69
+ return { map: encodeContainerNode(schema) };
70
+ case NodeKind.Record:
71
+ return { record: encodeContainerNode(schema) };
72
+ case NodeKind.Object:
73
+ return { object: encodeObjectNode(schema) };
74
+ default: {
75
+ unreachableCase(kind);
76
+ }
77
+ }
78
+ }
79
+ /**
80
+ * Encodes a leaf node schema to a serializable object.
81
+ * @param schema - The leaf node schema to convert.
82
+ * @returns A serializable representation of the leaf node schema.
83
+ */
84
+ function encodeLeafNode(schema) {
85
+ return {
86
+ kind: schema.kind,
87
+ leafKind: schema.leafKind,
88
+ };
89
+ }
90
+ /**
91
+ * Encodes a container node schema (a simple schema that is a Map, Array, or Record) to a serializable object.
92
+ * @param schema - The container node schema to convert.
93
+ * @returns A serializable representation of the container node schema. Includes the `kind` for disambiguation between different
94
+ * container kinds.
95
+ */
96
+ function encodeContainerNode(schema) {
97
+ return {
98
+ kind: schema.kind,
99
+ simpleAllowedTypes: encodeSimpleAllowedTypes(schema.simpleAllowedTypes),
100
+ };
101
+ }
102
+ /**
103
+ * Encodes a simple allowed types map to a serializable object. Needed because JSON serialization does not support Maps.
104
+ * @param simpleAllowedTypes - The simple allowed types map to convert.
105
+ * @returns A serializable representation of the simple allowed types.
106
+ */
107
+ function encodeSimpleAllowedTypes(simpleAllowedTypes) {
108
+ const encodedAllowedTypes = {};
109
+ for (const [identifier, attributes] of simpleAllowedTypes) {
110
+ encodedAllowedTypes[identifier] = {
111
+ isStaged: attributes.isStaged,
112
+ };
113
+ }
114
+ return encodedAllowedTypes;
115
+ }
116
+ /**
117
+ * Encodes an object node schema to a serializable object.
118
+ * @param schema - The object node schema to convert.
119
+ * @returns A serializable representation of the object node schema.
120
+ */
121
+ function encodeObjectNode(schema) {
122
+ const encodedFields = {};
123
+ for (const [fieldKey, fieldSchema] of schema.fields) {
124
+ encodedFields[fieldKey] = encodeObjectField(fieldSchema);
125
+ }
126
+ return {
127
+ kind: schema.kind,
128
+ fields: encodedFields,
129
+ allowUnknownOptionalFields: schema.allowUnknownOptionalFields,
130
+ };
131
+ }
132
+ /**
133
+ * Encodes an object field schema to a serializable object.
134
+ * @param fieldSchema - The object field schema to convert.
135
+ * @returns A serializable representation of the object field schema.
136
+ */
137
+ function encodeObjectField(fieldSchema) {
138
+ const encodedField = encodeField(fieldSchema);
139
+ return { ...encodedField, storedKey: fieldSchema.storedKey };
140
+ }
141
+ /**
142
+ * Encodes a field schema to a serializable object.
143
+ * @param fieldSchema - The field schema to convert.
144
+ * @returns A serializable representation of the field schema.
145
+ */
146
+ function encodeField(fieldSchema) {
147
+ return {
148
+ kind: fieldSchema.kind,
149
+ simpleAllowedTypes: encodeSimpleAllowedTypes(fieldSchema.simpleAllowedTypes),
150
+ };
151
+ }
152
+ const decodeNodeSchemaDispatcher = new DiscriminatedUnionDispatcher({
153
+ leaf: decodeLeafNode,
154
+ array: decodeContainerNode,
155
+ map: decodeContainerNode,
156
+ record: decodeContainerNode,
157
+ object: decodeObjectNode,
158
+ });
159
+ /**
160
+ * Decodes a node schema from a JSON-compatible object.
161
+ * @param encodedNodeSchema - The encoded node schema to decode.
162
+ * @returns The decoded node schema.
163
+ */
164
+ function decodeNodeSchema(encodedNodeSchema) {
165
+ return decodeNodeSchemaDispatcher.dispatch(encodedNodeSchema);
166
+ }
167
+ /**
168
+ * Decodes a container node schema (array, map, record) from a JSON-compatible object.
169
+ * @param encodedContainerSchema - The encoded schema to decode.
170
+ * @returns The decoded container node schema.
171
+ */
172
+ function decodeContainerNode(encodedContainerSchema) {
173
+ return {
174
+ kind: encodedContainerSchema.kind,
175
+ simpleAllowedTypes: decodeSimpleAllowedTypes(encodedContainerSchema.simpleAllowedTypes),
176
+ // We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values.
177
+ persistedMetadata: undefined,
178
+ metadata: {},
179
+ };
180
+ }
181
+ /**
182
+ * Decodes a leaf node schema from a JSON-compatible object.
183
+ * @param encodedLeafSchema - The encoded leaf node schema.
184
+ * @returns The decoded leaf node schema.
185
+ */
186
+ function decodeLeafNode(encodedLeafSchema) {
187
+ return {
188
+ kind: NodeKind.Leaf,
189
+ leafKind: encodedLeafSchema.leafKind,
190
+ // We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values.
191
+ persistedMetadata: undefined,
192
+ metadata: {},
193
+ };
194
+ }
195
+ /**
196
+ * Decodes a object node schema from a JSON-compatible object.
197
+ * @param encodedObjectSchema - The encoded object node schema.
198
+ * @returns The decoded object node schema.
199
+ */
200
+ function decodeObjectNode(encodedObjectSchema) {
201
+ return {
202
+ kind: NodeKind.Object,
203
+ fields: decodeObjectFields(encodedObjectSchema.fields),
204
+ // It is possible for allowUnknownOptionalFields to be undefined. This happens when serializing a Simple Schema derived
205
+ // from a stored schema.
206
+ allowUnknownOptionalFields: encodedObjectSchema.allowUnknownOptionalFields,
207
+ // We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values when decoding.
208
+ persistedMetadata: undefined,
209
+ metadata: {},
210
+ };
211
+ }
212
+ /**
213
+ * Decodes a map of object fields from a JSON-compatible object.
214
+ * @param encodedFields - The encoded fields.
215
+ * @returns A map of the decoded object fields.
216
+ */
217
+ function decodeObjectFields(encodedFields) {
218
+ const fields = new Map();
219
+ for (const [fieldKey, fieldSchema] of Object.entries(encodedFields)) {
220
+ fields.set(fieldKey, decodeObjectField(fieldSchema));
221
+ }
222
+ return fields;
223
+ }
224
+ /**
225
+ * Decodes a {@link SimpleObjectFieldSchema} from a JSON-compatible object.
226
+ * @param encodedField - The encoded field schema.
227
+ * @returns The decoded simple object field schema.
228
+ */
229
+ function decodeObjectField(encodedField) {
230
+ const baseField = decodeSimpleFieldSchema(encodedField);
231
+ return {
232
+ ...baseField,
233
+ storedKey: encodedField.storedKey,
234
+ };
235
+ }
236
+ /**
237
+ * Decodes a {@link SimpleFieldSchema} from a JSON-compatible object.
238
+ * @param encodedField - The encoded field schema.
239
+ * @returns The decoded simple field schema.
240
+ */
241
+ function decodeSimpleFieldSchema(encodedField) {
242
+ return {
243
+ kind: encodedField.kind,
244
+ simpleAllowedTypes: decodeSimpleAllowedTypes(encodedField.simpleAllowedTypes),
245
+ // We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values when decoding.
246
+ persistedMetadata: undefined,
247
+ metadata: {},
248
+ };
249
+ }
250
+ /**
251
+ * Decodes a simple allowed types map from a JSON-compatible object.
252
+ * @param encodedAllowedTypes - The encoded simple allowed types.
253
+ * @returns A map of the decoded simple allowed types.
254
+ */
255
+ function decodeSimpleAllowedTypes(encodedAllowedTypes) {
256
+ const untypedMap = objectToMap(encodedAllowedTypes);
257
+ const simpleAllowedTypes = transformMapValues(untypedMap, (value) => {
258
+ return {
259
+ isStaged: value.isStaged,
260
+ };
261
+ });
262
+ return simpleAllowedTypes;
263
+ }
264
+ //# sourceMappingURL=simpleSchemaCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleSchemaCodec.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaCodec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAA+B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAa1F,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACN,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,GAEnB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAA8B;IAChE,sCAAsC;IACtC,MAAM,kBAAkB,GAAyC,EAAE,CAAC;IAEpE,KAAK,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACnD,kBAAkB,CAAC,UAAU,CAAC,GA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AS,wBAAwB,CAChC,mBAAoD;IAEpD,MAAM,UAAU,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAEpD,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;QACnE,OAAO;YACN,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACc,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,OAAO,kBAAkB,CAAC;AAC3B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { objectToMap, type JsonCompatibleReadOnly } from \"../../util/index.js\";\nimport { unreachableCase, transformMapValues } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tSimpleAllowedTypeAttributes,\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectFieldSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleRecordNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind } from \"../core/index.js\";\nimport type { FieldKind } from \"../fieldSchema.js\";\nimport type { ValueSchema } from \"../../core/index.js\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport * as Format from \"../simpleSchemaFormatV1.js\";\nimport {\n\tDiscriminatedUnionDispatcher,\n\textractJsonValidator,\n\tFormatValidatorNoOp,\n\ttype FormatValidator,\n} from \"../../codec/index.js\";\n\n/**\n * Encodes a simple schema (view or stored) into a serializable format.\n * @remarks The JSON-compatible schema returned from this method is only intended for use in snapshots/comparisons of schemas.\n * It is not possible to reconstruct a full schema (including metadata and persistedMetadata) from the encoded format.\n * @param treeSchema - The tree schema to convert.\n * @returns A serializable representation of the schema.\n *\n * @alpha\n */\nexport function encodeSimpleSchema(simpleSchema: SimpleTreeSchema): JsonCompatibleReadOnly {\n\t// Convert types to serializable forms\n\tconst encodedDefinitions: Format.SimpleSchemaDefinitionsFormat = {};\n\n\tfor (const [identifier, schema] of simpleSchema.definitions) {\n\t\tconst encodedDefinition = encodeNodeSchema(schema);\n\t\tencodedDefinitions[identifier] = encodedDefinition;\n\t}\n\n\tconst encodedSchema: Format.SimpleTreeSchemaFormat = {\n\t\tversion: Format.SimpleSchemaFormatVersion.v1,\n\t\troot: encodeField(simpleSchema.root),\n\t\tdefinitions: encodedDefinitions,\n\t};\n\n\treturn encodedSchema;\n}\n\n/**\n * Decodes a JSON-compatible schema into a simple schema.\n * @param encodedSchema - The encoded schema to decode.\n * @param validator - The format validator to use to validate the encoded schema.\n * @returns A decoded simple schema.\n * @throws Will throw a usage error if the encoded schema is not in the expected format.\n *\n * @alpha\n */\nexport function decodeSimpleSchema(\n\tencodedSchema: JsonCompatibleReadOnly,\n\tvalidator?: FormatValidator,\n): SimpleTreeSchema {\n\tconst effectiveValidator = validator ?? FormatValidatorNoOp;\n\tconst compiledValidator = extractJsonValidator(effectiveValidator).compile(\n\t\tFormat.SimpleTreeSchemaFormat,\n\t);\n\tif (!compiledValidator.check(encodedSchema)) {\n\t\tthrow new UsageError(\n\t\t\t\"The provided simple schema is not valid according to the schema format.\",\n\t\t);\n\t}\n\n\treturn {\n\t\troot: decodeSimpleFieldSchema(encodedSchema.root),\n\t\tdefinitions: new Map(\n\t\t\ttransformMapValues(objectToMap(encodedSchema.definitions), (value, key) => {\n\t\t\t\treturn decodeNodeSchema(value);\n\t\t\t}),\n\t\t),\n\t};\n}\n\n/**\n * Encodes a node schema to a serializable object.\n * @param schema - The node schema to convert.\n * @returns A serializable representation of the node schema.\n */\nfunction encodeNodeSchema(schema: SimpleNodeSchema): Format.SimpleNodeSchemaUnionFormat {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf:\n\t\t\treturn { leaf: encodeLeafNode(schema) };\n\t\tcase NodeKind.Array:\n\t\t\treturn { array: encodeContainerNode(schema) };\n\t\tcase NodeKind.Map:\n\t\t\treturn { map: encodeContainerNode(schema) };\n\t\tcase NodeKind.Record:\n\t\t\treturn { record: encodeContainerNode(schema) };\n\t\tcase NodeKind.Object:\n\t\t\treturn { object: encodeObjectNode(schema) };\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\n/**\n * Encodes a leaf node schema to a serializable object.\n * @param schema - The leaf node schema to convert.\n * @returns A serializable representation of the leaf node schema.\n */\nfunction encodeLeafNode(schema: SimpleLeafNodeSchema): Format.SimpleLeafNodeSchemaFormat {\n\treturn {\n\t\tkind: schema.kind,\n\t\tleafKind: schema.leafKind,\n\t};\n}\n\n/**\n * Encodes a container node schema (a simple schema that is a Map, Array, or Record) to a serializable object.\n * @param schema - The container node schema to convert.\n * @returns A serializable representation of the container node schema. Includes the `kind` for disambiguation between different\n * container kinds.\n */\nfunction encodeContainerNode(\n\tschema: SimpleArrayNodeSchema | SimpleMapNodeSchema | SimpleRecordNodeSchema,\n):\n\t| Format.SimpleArrayNodeSchemaFormat\n\t| Format.SimpleMapNodeSchemaFormat\n\t| Format.SimpleRecordNodeSchemaFormat {\n\treturn {\n\t\tkind: schema.kind,\n\t\tsimpleAllowedTypes: encodeSimpleAllowedTypes(schema.simpleAllowedTypes),\n\t};\n}\n\n/**\n * Encodes a simple allowed types map to a serializable object. Needed because JSON serialization does not support Maps.\n * @param simpleAllowedTypes - The simple allowed types map to convert.\n * @returns A serializable representation of the simple allowed types.\n */\nfunction encodeSimpleAllowedTypes(\n\tsimpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>,\n): Format.SimpleAllowedTypesFormat {\n\tconst encodedAllowedTypes: Format.SimpleAllowedTypesFormat = {};\n\tfor (const [identifier, attributes] of simpleAllowedTypes) {\n\t\tencodedAllowedTypes[identifier] = {\n\t\t\tisStaged: attributes.isStaged,\n\t\t};\n\t}\n\treturn encodedAllowedTypes;\n}\n\n/**\n * Encodes an object node schema to a serializable object.\n * @param schema - The object node schema to convert.\n * @returns A serializable representation of the object node schema.\n */\nfunction encodeObjectNode(\n\tschema: SimpleObjectNodeSchema,\n): Format.SimpleObjectNodeSchemaFormat {\n\tconst encodedFields: Format.SimpleObjectFieldSchemasFormat = {};\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tencodedFields[fieldKey] = encodeObjectField(fieldSchema);\n\t}\n\n\treturn {\n\t\tkind: schema.kind,\n\t\tfields: encodedFields,\n\t\tallowUnknownOptionalFields: schema.allowUnknownOptionalFields,\n\t};\n}\n\n/**\n * Encodes an object field schema to a serializable object.\n * @param fieldSchema - The object field schema to convert.\n * @returns A serializable representation of the object field schema.\n */\nfunction encodeObjectField(\n\tfieldSchema: SimpleObjectFieldSchema,\n): Format.SimpleObjectFieldSchemaFormat {\n\tconst encodedField = encodeField(fieldSchema);\n\treturn { ...encodedField, storedKey: fieldSchema.storedKey };\n}\n\n/**\n * Encodes a field schema to a serializable object.\n * @param fieldSchema - The field schema to convert.\n * @returns A serializable representation of the field schema.\n */\nfunction encodeField(fieldSchema: SimpleFieldSchema): Format.SimpleFieldSchemaFormat {\n\treturn {\n\t\tkind: fieldSchema.kind,\n\t\tsimpleAllowedTypes: encodeSimpleAllowedTypes(fieldSchema.simpleAllowedTypes),\n\t};\n}\n\nconst decodeNodeSchemaDispatcher: DiscriminatedUnionDispatcher<\n\tFormat.SimpleNodeSchemaUnionFormat,\n\t[],\n\t| SimpleLeafNodeSchema\n\t| SimpleArrayNodeSchema\n\t| SimpleMapNodeSchema\n\t| SimpleRecordNodeSchema\n\t| SimpleObjectNodeSchema\n> = new DiscriminatedUnionDispatcher({\n\tleaf: decodeLeafNode,\n\tarray: decodeContainerNode,\n\tmap: decodeContainerNode,\n\trecord: decodeContainerNode,\n\tobject: decodeObjectNode,\n});\n\n/**\n * Decodes a node schema from a JSON-compatible object.\n * @param encodedNodeSchema - The encoded node schema to decode.\n * @returns The decoded node schema.\n */\nfunction decodeNodeSchema(\n\tencodedNodeSchema: Format.SimpleNodeSchemaUnionFormat,\n):\n\t| SimpleLeafNodeSchema\n\t| SimpleArrayNodeSchema\n\t| SimpleMapNodeSchema\n\t| SimpleRecordNodeSchema\n\t| SimpleObjectNodeSchema {\n\treturn decodeNodeSchemaDispatcher.dispatch(encodedNodeSchema);\n}\n\n/**\n * Decodes a container node schema (array, map, record) from a JSON-compatible object.\n * @param encodedContainerSchema - The encoded schema to decode.\n * @returns The decoded container node schema.\n */\nfunction decodeContainerNode(\n\tencodedContainerSchema:\n\t\t| Format.SimpleArrayNodeSchemaFormat\n\t\t| Format.SimpleMapNodeSchemaFormat\n\t\t| Format.SimpleRecordNodeSchemaFormat,\n): SimpleArrayNodeSchema | SimpleMapNodeSchema | SimpleRecordNodeSchema {\n\treturn {\n\t\tkind: encodedContainerSchema.kind as NodeKind.Array | NodeKind.Map | NodeKind.Record,\n\t\tsimpleAllowedTypes: decodeSimpleAllowedTypes(encodedContainerSchema.simpleAllowedTypes),\n\t\t// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values.\n\t\tpersistedMetadata: undefined,\n\t\tmetadata: {},\n\t};\n}\n\n/**\n * Decodes a leaf node schema from a JSON-compatible object.\n * @param encodedLeafSchema - The encoded leaf node schema.\n * @returns The decoded leaf node schema.\n */\nfunction decodeLeafNode(\n\tencodedLeafSchema: Format.SimpleLeafNodeSchemaFormat,\n): SimpleLeafNodeSchema {\n\treturn {\n\t\tkind: NodeKind.Leaf,\n\t\tleafKind: encodedLeafSchema.leafKind as ValueSchema,\n\t\t// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values.\n\t\tpersistedMetadata: undefined,\n\t\tmetadata: {},\n\t};\n}\n\n/**\n * Decodes a object node schema from a JSON-compatible object.\n * @param encodedObjectSchema - The encoded object node schema.\n * @returns The decoded object node schema.\n */\nfunction decodeObjectNode(\n\tencodedObjectSchema: Format.SimpleObjectNodeSchemaFormat,\n): SimpleObjectNodeSchema {\n\treturn {\n\t\tkind: NodeKind.Object,\n\t\tfields: decodeObjectFields(encodedObjectSchema.fields),\n\t\t// It is possible for allowUnknownOptionalFields to be undefined. This happens when serializing a Simple Schema derived\n\t\t// from a stored schema.\n\t\tallowUnknownOptionalFields: encodedObjectSchema.allowUnknownOptionalFields,\n\t\t// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values when decoding.\n\t\tpersistedMetadata: undefined,\n\t\tmetadata: {},\n\t};\n}\n\n/**\n * Decodes a map of object fields from a JSON-compatible object.\n * @param encodedFields - The encoded fields.\n * @returns A map of the decoded object fields.\n */\nfunction decodeObjectFields(\n\tencodedFields: Format.SimpleObjectFieldSchemasFormat,\n): ReadonlyMap<string, SimpleObjectFieldSchema> {\n\tconst fields = new Map<string, SimpleObjectFieldSchema>();\n\tfor (const [fieldKey, fieldSchema] of Object.entries(encodedFields)) {\n\t\tfields.set(fieldKey, decodeObjectField(fieldSchema));\n\t}\n\treturn fields;\n}\n\n/**\n * Decodes a {@link SimpleObjectFieldSchema} from a JSON-compatible object.\n * @param encodedField - The encoded field schema.\n * @returns The decoded simple object field schema.\n */\nfunction decodeObjectField(\n\tencodedField: Format.SimpleObjectFieldSchemaFormat,\n): SimpleObjectFieldSchema {\n\tconst baseField = decodeSimpleFieldSchema(encodedField);\n\treturn {\n\t\t...baseField,\n\t\tstoredKey: encodedField.storedKey,\n\t};\n}\n\n/**\n * Decodes a {@link SimpleFieldSchema} from a JSON-compatible object.\n * @param encodedField - The encoded field schema.\n * @returns The decoded simple field schema.\n */\nfunction decodeSimpleFieldSchema(\n\tencodedField: Format.SimpleFieldSchemaFormat,\n): SimpleFieldSchema {\n\treturn {\n\t\tkind: encodedField.kind as FieldKind,\n\t\tsimpleAllowedTypes: decodeSimpleAllowedTypes(encodedField.simpleAllowedTypes),\n\t\t// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values when decoding.\n\t\tpersistedMetadata: undefined,\n\t\tmetadata: {},\n\t};\n}\n\n/**\n * Decodes a simple allowed types map from a JSON-compatible object.\n * @param encodedAllowedTypes - The encoded simple allowed types.\n * @returns A map of the decoded simple allowed types.\n */\nfunction decodeSimpleAllowedTypes(\n\tencodedAllowedTypes: Format.SimpleAllowedTypesFormat,\n): ReadonlyMap<string, SimpleAllowedTypeAttributes> {\n\tconst untypedMap = objectToMap(encodedAllowedTypes);\n\n\tconst simpleAllowedTypes = transformMapValues(untypedMap, (value) => {\n\t\treturn {\n\t\t\tisStaged: value.isStaged,\n\t\t} satisfies SimpleAllowedTypeAttributes;\n\t});\n\n\treturn simpleAllowedTypes;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAQX,oBAAoB,EACpB,cAAc,EAGd,MAAM,iBAAiB,CAAC;AASzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAIN,gBAAgB,EAChB,MAAM,wBAAwB,CAAC;AAIhC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,cAAc,CAqBhB;AAkFD,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,oBAAoB,CA4CtB"}
1
+ {"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAQX,oBAAoB,EACpB,cAAc,EAGd,MAAM,iBAAiB,CAAC;AASzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAIN,gBAAgB,EAChB,MAAM,wBAAwB,CAAC;AAIhC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,cAAc,CAqBhB;AAqFD,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,oBAAoB,CA4CtB"}
@@ -68,7 +68,8 @@ function convertNodeSchema(schema, options) {
68
68
  }
69
69
  function convertArrayNodeSchema(schema) {
70
70
  const allowedTypes = [];
71
- schema.allowedTypesIdentifiers.forEach((type) => {
71
+ const allowedTypesIdentifiers = new Set(schema.simpleAllowedTypes.keys());
72
+ allowedTypesIdentifiers.forEach((type) => {
72
73
  allowedTypes.push(createSchemaRef(type));
73
74
  });
74
75
  const items = hasSingle(allowedTypes)
@@ -145,7 +146,8 @@ export function convertObjectNodeSchema(schema, options) {
145
146
  }
146
147
  function convertRecordLikeNodeSchema(schema) {
147
148
  const allowedTypes = [];
148
- schema.allowedTypesIdentifiers.forEach((type) => {
149
+ const allowedTypesIdentifiers = new Set(schema.simpleAllowedTypes.keys());
150
+ allowedTypesIdentifiers.forEach((type) => {
149
151
  allowedTypes.push(createSchemaRef(type));
150
152
  });
151
153
  const output = {
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;AAc5E,OAAO,EAAE,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AAC,QAAgB;IACxC,OAAO;QACN,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n\tJsonRecordNodeSchema,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../fieldSchema.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleRecordNodeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport type { TreeSchema } from \"./configuration.js\";\nimport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nimport {\n\tArrayNodeSchema,\n\tisMapNodeSchema,\n\tisRecordNodeSchema,\n\tObjectNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport { KeyEncodingOptions } from \"./customTree.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @remarks\n * This expects the data to be in the {@link ConciseTree} format.\n *\n * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.\n * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.\n */\nexport function toJsonSchema(\n\tschema: TreeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions, options);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.root.allowedTypesIdentifiers) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\t// TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.\n\t// TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes\n\t// TODO: handle case where allowedTypes is empty.\n\t// TODO: handle staged types in a controllable way.\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, TreeNodeSchema>,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value, options);\n\t}\n\treturn result;\n}\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(\n\tschema: TreeNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonNodeSchema {\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn convertArrayNodeSchema(schema);\n\t} else if (isMapNodeSchema(schema) || isRecordNodeSchema(schema)) {\n\t\treturn convertRecordLikeNodeSchema(schema);\n\t} else if (schema instanceof ObjectNodeSchema) {\n\t\treturn convertObjectNodeSchema(schema, options);\n\t} else if (schema instanceof LeafNodeSchema) {\n\t\treturn convertLeafNodeSchema(schema);\n\t}\n\tthrow new TypeError(`Unknown node schema kind: ${schema.kind}`);\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String:\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Number:\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Boolean:\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Null:\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\tcase ValueSchema.FluidHandle:\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\tdefault:\n\t\t\tunreachableCase(schema.leafKind);\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nexport function convertObjectNodeSchema(\n\tschema: ObjectNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\tconst key =\n\t\t\toptions.keys === KeyEncodingOptions.usePropertyKeys\n\t\t\t\t? propertyKey\n\t\t\t\t: fieldSchema.storedKey;\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypesIdentifiers) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (fieldSchema.kind !== FieldKind.Optional) {\n\t\t\tif (\n\t\t\t\toptions.requireFieldsWithDefaults ||\n\t\t\t\tfieldSchema.props?.defaultProvider === undefined\n\t\t\t) {\n\t\t\t\trequired.push(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\t// TODO: support unknown optional fields (only when using \"allStoredKeys\", and constrain the content to be in schema somehow)\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertRecordLikeNodeSchema(\n\tschema: SimpleRecordNodeSchema | SimpleMapNodeSchema,\n): JsonMapNodeSchema | JsonRecordNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: schema.kind,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t} as const;\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}
1
+ {"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;AAc5E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAO9C,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EACN,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC3B,MAAkB,EAClB,OAA4C;IAE5C,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAEpE,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/D,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,gHAAgH;IAChH,qFAAqF;IACrF,iDAAiD;IACjD,mDAAmD;IACnD,OAAO,SAAS,CAAC,YAAY,CAAC;QAC7B,CAAC,CAAC;YACA,GAAG,YAAY,CAAC,CAAC,CAAC;YAClB,KAAK,EAAE,WAAW;SAClB;QACF,CAAC,CAAC;YACA,KAAK,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BAAkB,CAAC,IAAI,EAAE,CAChC,CAAC;IACF,uBAAuB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACxC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG;QACd,IAAI,EAAE,QAAQ;QACd,mBAAmB,EAAE,MAAM,CAAC,IAAI;QAChC,iBAAiB,EAAE;YAClB,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC;gBAC9B,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;gBACjB,CAAC,CAAC;oBACA,KAAK,EAAE,YAAY;iBACnB;SACH;KACQ,CAAC;IAEX,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,QAAgB;IACxC,OAAO;QACN,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n\tJsonRecordNodeSchema,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../fieldSchema.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleRecordNodeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport type { TreeSchema } from \"./configuration.js\";\nimport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nimport {\n\tArrayNodeSchema,\n\tisMapNodeSchema,\n\tisRecordNodeSchema,\n\tObjectNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport { KeyEncodingOptions } from \"./customTree.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @remarks\n * This expects the data to be in the {@link ConciseTree} format.\n *\n * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.\n * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.\n */\nexport function toJsonSchema(\n\tschema: TreeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions, options);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.root.allowedTypesIdentifiers) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\t// TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.\n\t// TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes\n\t// TODO: handle case where allowedTypes is empty.\n\t// TODO: handle staged types in a controllable way.\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, TreeNodeSchema>,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value, options);\n\t}\n\treturn result;\n}\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(\n\tschema: TreeNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonNodeSchema {\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn convertArrayNodeSchema(schema);\n\t} else if (isMapNodeSchema(schema) || isRecordNodeSchema(schema)) {\n\t\treturn convertRecordLikeNodeSchema(schema);\n\t} else if (schema instanceof ObjectNodeSchema) {\n\t\treturn convertObjectNodeSchema(schema, options);\n\t} else if (schema instanceof LeafNodeSchema) {\n\t\treturn convertLeafNodeSchema(schema);\n\t}\n\tthrow new TypeError(`Unknown node schema kind: ${schema.kind}`);\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tconst allowedTypesIdentifiers: ReadonlySet<string> = new Set(\n\t\tschema.simpleAllowedTypes.keys(),\n\t);\n\tallowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String:\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Number:\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Boolean:\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Null:\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\tcase ValueSchema.FluidHandle:\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\tdefault:\n\t\t\tunreachableCase(schema.leafKind);\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nexport function convertObjectNodeSchema(\n\tschema: ObjectNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\tconst key =\n\t\t\toptions.keys === KeyEncodingOptions.usePropertyKeys\n\t\t\t\t? propertyKey\n\t\t\t\t: fieldSchema.storedKey;\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypesIdentifiers) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (fieldSchema.kind !== FieldKind.Optional) {\n\t\t\tif (\n\t\t\t\toptions.requireFieldsWithDefaults ||\n\t\t\t\tfieldSchema.props?.defaultProvider === undefined\n\t\t\t) {\n\t\t\t\trequired.push(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\t// TODO: support unknown optional fields (only when using \"allStoredKeys\", and constrain the content to be in schema somehow)\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertRecordLikeNodeSchema(\n\tschema: SimpleRecordNodeSchema | SimpleMapNodeSchema,\n): JsonMapNodeSchema | JsonRecordNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tconst allowedTypesIdentifiers: ReadonlySet<string> = new Set(\n\t\tschema.simpleAllowedTypes.keys(),\n\t);\n\tallowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: schema.kind,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t} as const;\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
6
- import type { ICodecOptions } from "../../codec/index.js";
7
- import type { JsonCompatible } from "../../util/index.js";
6
+ import { type ICodecOptions } from "../../codec/index.js";
7
+ import { type JsonCompatible } from "../../util/index.js";
8
8
  import type { SchemaUpgrade } from "../core/index.js";
9
9
  import { type ImplicitFieldSchema } from "../fieldSchema.js";
10
10
  import type { SchemaCompatibilityStatus } from "./tree.js";
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,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BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,mBAAmB,EAAE,uBAAuB,EAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,GAChD,cAAc,CAIhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,aAAa,GACpB,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAalD"}
@@ -2,11 +2,13 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { SchemaVersion } from "../../core/index.js";
5
+ import { FluidClientVersion } from "../../codec/index.js";
6
+ import { SchemaFormatVersion } from "../../core/index.js";
6
7
  import { encodeTreeSchema, makeSchemaCodec } from "../../feature-libraries/index.js";
7
8
  import { clientVersionToSchemaVersion,
8
- // eslint-disable-next-line import/no-internal-modules
9
+ // eslint-disable-next-line import-x/no-internal-modules
9
10
  } from "../../feature-libraries/schema-index/index.js";
11
+ import { brand } from "../../util/index.js";
10
12
  import { normalizeFieldSchema } from "../fieldSchema.js";
11
13
  import { toStoredSchema } from "../toStoredSchema.js";
12
14
  import { TreeViewConfigurationAlpha } from "./configuration.js";
@@ -81,7 +83,7 @@ export function extractPersistedSchema(schema, minVersionForCollab, includeStage
81
83
  export function comparePersistedSchema(persisted, view, options) {
82
84
  // Any version can be passed down to makeSchemaCodec here.
83
85
  // We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.
84
- const schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);
86
+ const schemaCodec = makeSchemaCodec({ ...options, minVersionForCollab: FluidClientVersion.v2_0 }, brand(SchemaFormatVersion.v1));
85
87
  const stored = schemaCodec.decode(persisted);
86
88
  const config = new TreeViewConfigurationAlpha({
87
89
  schema: normalizeFieldS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AAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport type { ICodecOptions } from \"../../codec/index.js\";\nimport { SchemaVersion } from \"../../core/index.js\";\nimport { encodeTreeSchema, makeSchemaCodec } from \"../../feature-libraries/index.js\";\nimport {\n\tclientVersionToSchemaVersion,\n\ttype FormatV1,\n\t// eslint-disable-next-line import/no-internal-modules\n} from \"../../feature-libraries/schema-index/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\n\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, { includeStaged });\n\tconst schemaWriteVersion = clientVersionToSchemaVersion(minVersionForCollab);\n\treturn encodeTreeSchema(stored, schemaWriteVersion);\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// Any version can be passed down to makeSchemaCodec here.\n\t// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.\n\tconst schemaCodec = makeSchemaCodec(options, SchemaVersion.v1);\n\tconst stored = schemaCodec.decode(persisted as FormatV1);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
1
+ {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAsB,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EACN,4BAA4B;AAE5B,wDAAwD;EACxD,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,KAAK,EAAuB,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAA4B,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA2B,EAC3B,mBAA4C,EAC5C,aAAkD;IAElD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,4BAA4B,CAAC,mBAAmB,CAAC,CAAC;IAC7E,OAAO,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CACrC,SAAyB,EACzB,IAAyB,EACzB,OAAsB;IAEtB,0DAA0D;IAC1D,2JAA2J;IAC3J,MAAM,WAAW,GAAG,eAAe,CAClC,EAAE,GAAG,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,IAAI,EAAE,EAC5D,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAC7B,CAAC;IACF,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAqB,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC;QAC7C,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport { FluidClientVersion, type ICodecOptions } from \"../../codec/index.js\";\nimport { SchemaFormatVersion } from \"../../core/index.js\";\nimport { encodeTreeSchema, makeSchemaCodec } from \"../../feature-libraries/index.js\";\nimport {\n\tclientVersionToSchemaVersion,\n\ttype FormatV1,\n\t// eslint-disable-next-line import-x/no-internal-modules\n} from \"../../feature-libraries/schema-index/index.js\";\nimport { brand, type JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\n\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, { includeStaged });\n\tconst schemaWriteVersion = clientVersionToSchemaVersion(minVersionForCollab);\n\treturn encodeTreeSchema(stored, schemaWriteVersion);\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// Any version can be passed down to makeSchemaCodec here.\n\t// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.\n\tconst schemaCodec = makeSchemaCodec(\n\t\t{ ...options, minVersionForCollab: FluidClientVersion.v2_0 },\n\t\tbrand(SchemaFormatVersion.v1),\n\t);\n\tconst stored = schemaCodec.decode(persisted as FormatV1);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
@@ -357,7 +357,7 @@ export interface SchemaCompatibilityStatus {
357
357
  *
358
358
  * Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.
359
359
  *
360
- * For the computation of this equivalence, {@link SchemaStaticsAlpha.staged | staged} schemas are not included.
360
+ * For the computation of this equivalence, {@link SchemaStaticsBeta.staged | staged} schemas are not included.
361
361
  * If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.
362
362
  */
363
363
  readonly isEquivalent: boolean;
@@ -370,7 +370,7 @@ export interface SchemaCompatibilityStatus {
370
370
  *
371
371
  * - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.
372
372
  *
373
- * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsAlpha.staged | staged} in the view schema.
373
+ * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsBeta.staged | staged} in the view schema.
374
374
  *
375
375
  * In these cases `canUpgrade` and `isEquivalent` will be false.
376
376
  *