@fluidframework/tree 2.71.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 (603) hide show
  1. package/CHANGELOG.md +26 -40
  2. package/api-report/tree.alpha.api.md +27 -18
  3. package/api-report/tree.beta.api.md +42 -0
  4. package/api-report/tree.legacy.beta.api.md +42 -0
  5. package/dist/alpha.d.ts +9 -7
  6. package/dist/api.js +1 -1
  7. package/dist/api.js.map +1 -1
  8. package/dist/beta.d.ts +7 -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/core/index.d.ts +1 -1
  14. package/dist/core/index.d.ts.map +1 -1
  15. package/dist/core/index.js +2 -2
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/core/schema-stored/index.d.ts +1 -1
  18. package/dist/core/schema-stored/index.d.ts.map +1 -1
  19. package/dist/core/schema-stored/index.js +2 -2
  20. package/dist/core/schema-stored/index.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +6 -6
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +6 -7
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
  26. package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  27. package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  28. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
  29. package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  30. package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
  31. package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  32. package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  33. package/dist/core/tree/detachedFieldIndexCodecV2.js +3 -1
  34. package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  35. package/dist/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
  36. package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  37. package/dist/core/tree/detachedFieldIndexCodecs.js +29 -8
  38. package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  39. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
  40. package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  41. package/dist/core/tree/detachedFieldIndexFormatCommon.js +8 -1
  42. package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  43. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
  44. package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  45. package/dist/core/tree/detachedFieldIndexFormatV1.js +3 -3
  46. package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  47. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  48. package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  49. package/dist/core/tree/detachedFieldIndexFormatV2.js +3 -3
  50. package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  51. package/dist/core/tree/index.d.ts +2 -1
  52. package/dist/core/tree/index.d.ts.map +1 -1
  53. package/dist/core/tree/index.js.map +1 -1
  54. package/dist/external-utilities/typeboxValidator.js +1 -1
  55. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
  57. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  58. package/dist/feature-libraries/chunked-forest/codec/codecs.js +12 -8
  59. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  60. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
  61. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  62. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
  63. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  64. package/dist/feature-libraries/chunked-forest/codec/format.js +9 -4
  65. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  66. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  67. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/codec/index.js +1 -2
  69. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  71. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +1 -1
  72. package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  73. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  74. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  75. package/dist/feature-libraries/chunked-forest/index.js +1 -2
  76. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  77. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -9
  78. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  79. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +3 -21
  80. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  81. package/dist/feature-libraries/forest-summary/codec.d.ts +4 -5
  82. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  83. package/dist/feature-libraries/forest-summary/codec.js +15 -4
  84. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  85. package/dist/feature-libraries/forest-summary/forestSummarizer.js +1 -1
  86. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  87. package/dist/feature-libraries/forest-summary/format.d.ts +8 -1
  88. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  89. package/dist/feature-libraries/forest-summary/format.js +8 -3
  90. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  91. package/dist/feature-libraries/forest-summary/index.d.ts +2 -1
  92. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  93. package/dist/feature-libraries/forest-summary/index.js +3 -1
  94. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  95. package/dist/feature-libraries/index.d.ts +3 -3
  96. package/dist/feature-libraries/index.d.ts.map +1 -1
  97. package/dist/feature-libraries/index.js +2 -2
  98. package/dist/feature-libraries/index.js.map +1 -1
  99. package/dist/feature-libraries/schema-edits/index.d.ts +1 -1
  100. package/dist/feature-libraries/schema-edits/index.d.ts.map +1 -1
  101. package/dist/feature-libraries/schema-edits/index.js.map +1 -1
  102. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
  103. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  104. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +5 -4
  105. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  106. package/dist/feature-libraries/schema-index/codec.d.ts +10 -10
  107. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  108. package/dist/feature-libraries/schema-index/codec.js +22 -18
  109. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  110. package/dist/feature-libraries/schema-index/formatV1.d.ts +2 -2
  111. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  112. package/dist/feature-libraries/schema-index/formatV1.js +1 -1
  113. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
  114. package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -2
  115. package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  116. package/dist/feature-libraries/schema-index/formatV2.js +1 -1
  117. package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
  118. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  119. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  120. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  121. package/dist/index.d.ts +1 -1
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +3 -1
  124. package/dist/index.js.map +1 -1
  125. package/dist/legacy.d.ts +7 -0
  126. package/dist/packageVersion.d.ts +1 -1
  127. package/dist/packageVersion.js +1 -1
  128. package/dist/packageVersion.js.map +1 -1
  129. package/dist/shared-tree/independentView.d.ts +1 -1
  130. package/dist/shared-tree/independentView.d.ts.map +1 -1
  131. package/dist/shared-tree/independentView.js +22 -15
  132. package/dist/shared-tree/independentView.js.map +1 -1
  133. package/dist/shared-tree/sharedTree.d.ts +12 -16
  134. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  135. package/dist/shared-tree/sharedTree.js +87 -127
  136. package/dist/shared-tree/sharedTree.js.map +1 -1
  137. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
  138. package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  139. package/dist/shared-tree/sharedTreeChangeCodecs.js +12 -11
  140. package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  141. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  142. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  143. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  144. package/dist/shared-tree/treeAlpha.d.ts +1 -1
  145. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  146. package/dist/shared-tree/treeAlpha.js +4 -2
  147. package/dist/shared-tree/treeAlpha.js.map +1 -1
  148. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  149. package/dist/shared-tree/treeCheckout.js +1 -3
  150. package/dist/shared-tree/treeCheckout.js.map +1 -1
  151. package/dist/shared-tree-core/editManagerCodecs.d.ts +19 -6
  152. package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  153. package/dist/shared-tree-core/editManagerCodecs.js +35 -17
  154. package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
  155. package/dist/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
  156. package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  157. package/dist/shared-tree-core/editManagerFormatCommons.js +43 -1
  158. package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  159. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  160. package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  161. package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -4
  162. package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  163. package/dist/shared-tree-core/editManagerFormatV5.d.ts +2 -2
  164. package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
  165. package/dist/shared-tree-core/editManagerFormatV5.js +1 -1
  166. package/dist/shared-tree-core/editManagerFormatV5.js.map +1 -1
  167. package/dist/shared-tree-core/index.d.ts +5 -3
  168. package/dist/shared-tree-core/index.d.ts.map +1 -1
  169. package/dist/shared-tree-core/index.js +11 -3
  170. package/dist/shared-tree-core/index.js.map +1 -1
  171. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
  172. package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  173. package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  174. package/dist/shared-tree-core/messageCodecV5.d.ts +2 -1
  175. package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -1
  176. package/dist/shared-tree-core/messageCodecV5.js.map +1 -1
  177. package/dist/shared-tree-core/messageCodecs.d.ts +19 -6
  178. package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
  179. package/dist/shared-tree-core/messageCodecs.js +38 -21
  180. package/dist/shared-tree-core/messageCodecs.js.map +1 -1
  181. package/dist/shared-tree-core/messageFormat.d.ts +50 -0
  182. package/dist/shared-tree-core/messageFormat.d.ts.map +1 -0
  183. package/dist/shared-tree-core/messageFormat.js +51 -0
  184. package/dist/shared-tree-core/messageFormat.js.map +1 -0
  185. package/dist/shared-tree-core/sharedTreeCore.d.ts +8 -8
  186. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  187. package/dist/shared-tree-core/sharedTreeCore.js +3 -3
  188. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  189. package/dist/simple-tree/api/discrepancies.d.ts +2 -2
  190. package/dist/simple-tree/api/discrepancies.js.map +1 -1
  191. package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  192. package/dist/simple-tree/api/incrementalAllowedTypes.js +1 -1
  193. package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  194. package/dist/simple-tree/api/index.d.ts +3 -2
  195. package/dist/simple-tree/api/index.d.ts.map +1 -1
  196. package/dist/simple-tree/api/index.js +4 -1
  197. package/dist/simple-tree/api/index.js.map +1 -1
  198. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
  199. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  200. package/dist/simple-tree/api/schemaFactoryAlpha.js +1 -52
  201. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  202. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
  203. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  204. package/dist/simple-tree/api/schemaFactoryBeta.js +61 -7
  205. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  206. package/dist/simple-tree/api/schemaFromSimple.js +6 -3
  207. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  208. package/dist/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
  209. package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
  210. package/dist/simple-tree/api/simpleSchemaCodec.js +292 -0
  211. package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -0
  212. package/dist/simple-tree/api/storedSchema.d.ts +2 -2
  213. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  214. package/dist/simple-tree/api/storedSchema.js +8 -6
  215. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  216. package/dist/simple-tree/api/tree.d.ts +2 -2
  217. package/dist/simple-tree/api/tree.js.map +1 -1
  218. package/dist/simple-tree/api/typesUnsafe.d.ts +6 -6
  219. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  220. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +18 -3
  221. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  222. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +78 -35
  223. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  224. package/dist/simple-tree/core/allowedTypes.d.ts +3 -3
  225. package/dist/simple-tree/core/allowedTypes.js +1 -1
  226. package/dist/simple-tree/core/allowedTypes.js.map +1 -1
  227. package/dist/simple-tree/core/treeNode.js +1 -1
  228. package/dist/simple-tree/core/treeNode.js.map +1 -1
  229. package/dist/simple-tree/index.d.ts +2 -1
  230. package/dist/simple-tree/index.d.ts.map +1 -1
  231. package/dist/simple-tree/index.js +4 -0
  232. package/dist/simple-tree/index.js.map +1 -1
  233. package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
  234. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  235. package/dist/simple-tree/node-kinds/map/mapNode.js +1 -1
  236. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  237. package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
  238. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  239. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
  240. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  241. package/dist/simple-tree/simpleSchema.d.ts +11 -3
  242. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  243. package/dist/simple-tree/simpleSchema.js.map +1 -1
  244. package/dist/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
  245. package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
  246. package/dist/simple-tree/simpleSchemaFormatV1.js +115 -0
  247. package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -0
  248. package/dist/tableSchema.d.ts.map +1 -1
  249. package/dist/tableSchema.js +1 -1
  250. package/dist/tableSchema.js.map +1 -1
  251. package/dist/treeFactory.d.ts +3 -1
  252. package/dist/treeFactory.d.ts.map +1 -1
  253. package/dist/treeFactory.js +26 -2
  254. package/dist/treeFactory.js.map +1 -1
  255. package/dist/util/brand.d.ts +31 -2
  256. package/dist/util/brand.d.ts.map +1 -1
  257. package/dist/util/brand.js +28 -2
  258. package/dist/util/brand.js.map +1 -1
  259. package/dist/util/brandedMap.d.ts +3 -1
  260. package/dist/util/brandedMap.d.ts.map +1 -1
  261. package/dist/util/brandedMap.js.map +1 -1
  262. package/dist/util/index.d.ts +1 -1
  263. package/dist/util/index.d.ts.map +1 -1
  264. package/dist/util/index.js +3 -2
  265. package/dist/util/index.js.map +1 -1
  266. package/lib/alpha.d.ts +9 -7
  267. package/lib/api.js +2 -2
  268. package/lib/api.js.map +1 -1
  269. package/lib/beta.d.ts +7 -0
  270. package/lib/codec/codec.d.ts +16 -1
  271. package/lib/codec/codec.d.ts.map +1 -1
  272. package/lib/codec/codec.js +16 -3
  273. package/lib/codec/codec.js.map +1 -1
  274. package/lib/core/index.d.ts +1 -1
  275. package/lib/core/index.d.ts.map +1 -1
  276. package/lib/core/index.js +1 -1
  277. package/lib/core/index.js.map +1 -1
  278. package/lib/core/schema-stored/index.d.ts +1 -1
  279. package/lib/core/schema-stored/index.d.ts.map +1 -1
  280. package/lib/core/schema-stored/index.js +1 -1
  281. package/lib/core/schema-stored/index.js.map +1 -1
  282. package/lib/core/schema-stored/schema.d.ts +6 -6
  283. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  284. package/lib/core/schema-stored/schema.js +6 -7
  285. package/lib/core/schema-stored/schema.js.map +1 -1
  286. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
  287. package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
  288. package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
  289. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
  290. package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
  291. package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
  292. package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
  293. package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
  294. package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -2
  295. package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
  296. package/lib/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
  297. package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
  298. package/lib/core/tree/detachedFieldIndexCodecs.js +29 -8
  299. package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
  300. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
  301. package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
  302. package/lib/core/tree/detachedFieldIndexFormatCommon.js +7 -0
  303. package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
  304. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
  305. package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
  306. package/lib/core/tree/detachedFieldIndexFormatV1.js +3 -3
  307. package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
  308. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
  309. package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
  310. package/lib/core/tree/detachedFieldIndexFormatV2.js +3 -3
  311. package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
  312. package/lib/core/tree/index.d.ts +2 -1
  313. package/lib/core/tree/index.d.ts.map +1 -1
  314. package/lib/core/tree/index.js +1 -1
  315. package/lib/core/tree/index.js.map +1 -1
  316. package/lib/external-utilities/typeboxValidator.js +1 -1
  317. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
  319. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  320. package/lib/feature-libraries/chunked-forest/codec/codecs.js +13 -8
  321. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  322. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
  323. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  324. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
  325. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  326. package/lib/feature-libraries/chunked-forest/codec/format.js +8 -3
  327. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  328. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
  329. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  330. package/lib/feature-libraries/chunked-forest/codec/index.js +2 -2
  331. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  332. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
  333. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
  334. package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js.map +1 -1
  335. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  336. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  337. package/lib/feature-libraries/chunked-forest/index.js +1 -1
  338. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  339. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -9
  340. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  341. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +2 -20
  342. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  343. package/lib/feature-libraries/forest-summary/codec.d.ts +4 -5
  344. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  345. package/lib/feature-libraries/forest-summary/codec.js +16 -5
  346. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  347. package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -1
  348. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  349. package/lib/feature-libraries/forest-summary/format.d.ts +8 -1
  350. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  351. package/lib/feature-libraries/forest-summary/format.js +7 -2
  352. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  353. package/lib/feature-libraries/forest-summary/index.d.ts +2 -1
  354. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  355. package/lib/feature-libraries/forest-summary/index.js +1 -0
  356. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  357. package/lib/feature-libraries/index.d.ts +3 -3
  358. package/lib/feature-libraries/index.d.ts.map +1 -1
  359. package/lib/feature-libraries/index.js +2 -2
  360. package/lib/feature-libraries/index.js.map +1 -1
  361. package/lib/feature-libraries/schema-edits/index.d.ts +1 -1
  362. package/lib/feature-libraries/schema-edits/index.d.ts.map +1 -1
  363. package/lib/feature-libraries/schema-edits/index.js.map +1 -1
  364. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
  365. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  366. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +6 -5
  367. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  368. package/lib/feature-libraries/schema-index/codec.d.ts +10 -10
  369. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  370. package/lib/feature-libraries/schema-index/codec.js +24 -20
  371. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  372. package/lib/feature-libraries/schema-index/formatV1.d.ts +2 -2
  373. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
  374. package/lib/feature-libraries/schema-index/formatV1.js +2 -2
  375. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -1
  376. package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -2
  377. package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
  378. package/lib/feature-libraries/schema-index/formatV2.js +2 -2
  379. package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
  380. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
  381. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  382. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  383. package/lib/index.d.ts +1 -1
  384. package/lib/index.d.ts.map +1 -1
  385. package/lib/index.js +1 -1
  386. package/lib/index.js.map +1 -1
  387. package/lib/legacy.d.ts +7 -0
  388. package/lib/packageVersion.d.ts +1 -1
  389. package/lib/packageVersion.js +1 -1
  390. package/lib/packageVersion.js.map +1 -1
  391. package/lib/shared-tree/independentView.d.ts +1 -1
  392. package/lib/shared-tree/independentView.d.ts.map +1 -1
  393. package/lib/shared-tree/independentView.js +11 -4
  394. package/lib/shared-tree/independentView.js.map +1 -1
  395. package/lib/shared-tree/sharedTree.d.ts +12 -16
  396. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  397. package/lib/shared-tree/sharedTree.js +90 -130
  398. package/lib/shared-tree/sharedTree.js.map +1 -1
  399. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
  400. package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
  401. package/lib/shared-tree/sharedTreeChangeCodecs.js +7 -6
  402. package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
  403. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  404. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  405. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  406. package/lib/shared-tree/treeAlpha.d.ts +1 -1
  407. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  408. package/lib/shared-tree/treeAlpha.js +5 -3
  409. package/lib/shared-tree/treeAlpha.js.map +1 -1
  410. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  411. package/lib/shared-tree/treeCheckout.js +1 -3
  412. package/lib/shared-tree/treeCheckout.js.map +1 -1
  413. package/lib/shared-tree-core/editManagerCodecs.d.ts +19 -6
  414. package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
  415. package/lib/shared-tree-core/editManagerCodecs.js +32 -16
  416. package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
  417. package/lib/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
  418. package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
  419. package/lib/shared-tree-core/editManagerFormatCommons.js +42 -0
  420. package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
  421. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
  422. package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
  423. package/lib/shared-tree-core/editManagerFormatV1toV4.js +5 -5
  424. package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
  425. package/lib/shared-tree-core/editManagerFormatV5.d.ts +2 -2
  426. package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
  427. package/lib/shared-tree-core/editManagerFormatV5.js +2 -2
  428. package/lib/shared-tree-core/editManagerFormatV5.js.map +1 -1
  429. package/lib/shared-tree-core/index.d.ts +5 -3
  430. package/lib/shared-tree-core/index.d.ts.map +1 -1
  431. package/lib/shared-tree-core/index.js +4 -2
  432. package/lib/shared-tree-core/index.js.map +1 -1
  433. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
  434. package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
  435. package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
  436. package/lib/shared-tree-core/messageCodecV5.d.ts +2 -1
  437. package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -1
  438. package/lib/shared-tree-core/messageCodecV5.js.map +1 -1
  439. package/lib/shared-tree-core/messageCodecs.d.ts +19 -6
  440. package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
  441. package/lib/shared-tree-core/messageCodecs.js +35 -20
  442. package/lib/shared-tree-core/messageCodecs.js.map +1 -1
  443. package/lib/shared-tree-core/messageFormat.d.ts +50 -0
  444. package/lib/shared-tree-core/messageFormat.d.ts.map +1 -0
  445. package/lib/shared-tree-core/messageFormat.js +48 -0
  446. package/lib/shared-tree-core/messageFormat.js.map +1 -0
  447. package/lib/shared-tree-core/sharedTreeCore.d.ts +8 -8
  448. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  449. package/lib/shared-tree-core/sharedTreeCore.js +3 -3
  450. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  451. package/lib/simple-tree/api/discrepancies.d.ts +2 -2
  452. package/lib/simple-tree/api/discrepancies.js.map +1 -1
  453. package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
  454. package/lib/simple-tree/api/incrementalAllowedTypes.js +1 -1
  455. package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
  456. package/lib/simple-tree/api/index.d.ts +3 -2
  457. package/lib/simple-tree/api/index.d.ts.map +1 -1
  458. package/lib/simple-tree/api/index.js +1 -0
  459. package/lib/simple-tree/api/index.js.map +1 -1
  460. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
  461. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  462. package/lib/simple-tree/api/schemaFactoryAlpha.js +1 -52
  463. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  464. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
  465. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
  466. package/lib/simple-tree/api/schemaFactoryBeta.js +58 -4
  467. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
  468. package/lib/simple-tree/api/schemaFromSimple.js +6 -3
  469. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  470. package/lib/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
  471. package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
  472. package/lib/simple-tree/api/simpleSchemaCodec.js +264 -0
  473. package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -0
  474. package/lib/simple-tree/api/storedSchema.d.ts +2 -2
  475. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  476. package/lib/simple-tree/api/storedSchema.js +5 -3
  477. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  478. package/lib/simple-tree/api/tree.d.ts +2 -2
  479. package/lib/simple-tree/api/tree.js.map +1 -1
  480. package/lib/simple-tree/api/typesUnsafe.d.ts +6 -6
  481. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  482. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +18 -3
  483. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  484. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +75 -34
  485. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  486. package/lib/simple-tree/core/allowedTypes.d.ts +3 -3
  487. package/lib/simple-tree/core/allowedTypes.js +1 -1
  488. package/lib/simple-tree/core/allowedTypes.js.map +1 -1
  489. package/lib/simple-tree/core/treeNode.js +1 -1
  490. package/lib/simple-tree/core/treeNode.js.map +1 -1
  491. package/lib/simple-tree/index.d.ts +2 -1
  492. package/lib/simple-tree/index.d.ts.map +1 -1
  493. package/lib/simple-tree/index.js +1 -0
  494. package/lib/simple-tree/index.js.map +1 -1
  495. package/lib/simple-tree/node-kinds/array/arrayNode.js +2 -2
  496. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  497. package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
  498. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  499. package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
  500. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  501. package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
  502. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  503. package/lib/simple-tree/simpleSchema.d.ts +11 -3
  504. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  505. package/lib/simple-tree/simpleSchema.js.map +1 -1
  506. package/lib/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
  507. package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
  508. package/lib/simple-tree/simpleSchemaFormatV1.js +112 -0
  509. package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -0
  510. package/lib/tableSchema.d.ts.map +1 -1
  511. package/lib/tableSchema.js +1 -1
  512. package/lib/tableSchema.js.map +1 -1
  513. package/lib/treeFactory.d.ts +3 -1
  514. package/lib/treeFactory.d.ts.map +1 -1
  515. package/lib/treeFactory.js +23 -1
  516. package/lib/treeFactory.js.map +1 -1
  517. package/lib/util/brand.d.ts +31 -2
  518. package/lib/util/brand.d.ts.map +1 -1
  519. package/lib/util/brand.js +26 -1
  520. package/lib/util/brand.js.map +1 -1
  521. package/lib/util/brandedMap.d.ts +3 -1
  522. package/lib/util/brandedMap.d.ts.map +1 -1
  523. package/lib/util/brandedMap.js.map +1 -1
  524. package/lib/util/index.d.ts +1 -1
  525. package/lib/util/index.d.ts.map +1 -1
  526. package/lib/util/index.js +1 -1
  527. package/lib/util/index.js.map +1 -1
  528. package/package.json +24 -24
  529. package/src/api.ts +2 -2
  530. package/src/codec/codec.ts +17 -3
  531. package/src/core/index.ts +1 -2
  532. package/src/core/schema-stored/index.ts +1 -2
  533. package/src/core/schema-stored/schema.ts +10 -7
  534. package/src/core/tree/detachedFieldIndexCodecCommon.ts +2 -1
  535. package/src/core/tree/detachedFieldIndexCodecV1.ts +4 -2
  536. package/src/core/tree/detachedFieldIndexCodecV2.ts +4 -6
  537. package/src/core/tree/detachedFieldIndexCodecs.ts +33 -11
  538. package/src/core/tree/detachedFieldIndexFormatCommon.ts +17 -2
  539. package/src/core/tree/detachedFieldIndexFormatV1.ts +6 -4
  540. package/src/core/tree/detachedFieldIndexFormatV2.ts +6 -4
  541. package/src/core/tree/index.ts +2 -4
  542. package/src/external-utilities/typeboxValidator.ts +1 -1
  543. package/src/feature-libraries/chunked-forest/codec/codecs.ts +18 -13
  544. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -2
  545. package/src/feature-libraries/chunked-forest/codec/format.ts +15 -4
  546. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -2
  547. package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +2 -2
  548. package/src/feature-libraries/chunked-forest/index.ts +0 -1
  549. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +2 -29
  550. package/src/feature-libraries/forest-summary/codec.ts +24 -9
  551. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -1
  552. package/src/feature-libraries/forest-summary/format.ts +12 -2
  553. package/src/feature-libraries/forest-summary/index.ts +2 -1
  554. package/src/feature-libraries/index.ts +1 -2
  555. package/src/feature-libraries/schema-edits/index.ts +0 -1
  556. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +16 -16
  557. package/src/feature-libraries/schema-index/codec.ts +34 -22
  558. package/src/feature-libraries/schema-index/formatV1.ts +2 -2
  559. package/src/feature-libraries/schema-index/formatV2.ts +2 -2
  560. package/src/feature-libraries/schema-index/schemaSummarizer.ts +2 -1
  561. package/src/index.ts +3 -1
  562. package/src/packageVersion.ts +1 -1
  563. package/src/shared-tree/independentView.ts +16 -5
  564. package/src/shared-tree/sharedTree.ts +112 -172
  565. package/src/shared-tree/sharedTreeChangeCodecs.ts +15 -9
  566. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  567. package/src/shared-tree/treeAlpha.ts +6 -5
  568. package/src/shared-tree/treeCheckout.ts +1 -3
  569. package/src/shared-tree-core/editManagerCodecs.ts +56 -19
  570. package/src/shared-tree-core/editManagerFormatCommons.ts +47 -0
  571. package/src/shared-tree-core/editManagerFormatV1toV4.ts +10 -5
  572. package/src/shared-tree-core/editManagerFormatV5.ts +3 -3
  573. package/src/shared-tree-core/index.ts +11 -5
  574. package/src/shared-tree-core/messageCodecV1ToV4.ts +6 -1
  575. package/src/shared-tree-core/messageCodecV5.ts +2 -1
  576. package/src/shared-tree-core/messageCodecs.ts +60 -26
  577. package/src/shared-tree-core/messageFormat.ts +56 -0
  578. package/src/shared-tree-core/sharedTreeCore.ts +11 -13
  579. package/src/simple-tree/api/discrepancies.ts +2 -2
  580. package/src/simple-tree/api/incrementalAllowedTypes.ts +1 -1
  581. package/src/simple-tree/api/index.ts +6 -2
  582. package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -168
  583. package/src/simple-tree/api/schemaFactoryBeta.ts +180 -14
  584. package/src/simple-tree/api/schemaFromSimple.ts +6 -3
  585. package/src/simple-tree/api/simpleSchemaCodec.ts +360 -0
  586. package/src/simple-tree/api/storedSchema.ts +8 -5
  587. package/src/simple-tree/api/tree.ts +2 -2
  588. package/src/simple-tree/api/typesUnsafe.ts +6 -6
  589. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -47
  590. package/src/simple-tree/core/allowedTypes.ts +3 -3
  591. package/src/simple-tree/core/treeNode.ts +2 -2
  592. package/src/simple-tree/index.ts +5 -1
  593. package/src/simple-tree/node-kinds/array/arrayNode.ts +2 -2
  594. package/src/simple-tree/node-kinds/map/mapNode.ts +2 -2
  595. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
  596. package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
  597. package/src/simple-tree/simpleSchema.ts +12 -3
  598. package/src/simple-tree/simpleSchemaFormatV1.ts +179 -0
  599. package/src/tableSchema.ts +5 -2
  600. package/src/treeFactory.ts +33 -1
  601. package/src/util/brand.ts +40 -2
  602. package/src/util/brandedMap.ts +3 -1
  603. package/src/util/index.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryBeta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EACN,YAAY,EACZ,YAAY,GAKZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,iCAAiC,EACjC,aAAa,EACb,MAAM,EACN,cAAc,GAId,MAAM,oBAAoB,CAAC;AAe5B,6GAA6G;AAE7G;;;;GAIG;AACH,MAAM,OAAO,iBAGX,SAAQ,aAA4B;IACrC;;;;;OAKG;IACI,aAAa,CACnB,IAAO;QAEP,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAmB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;OAMG;IACa,MAAM,CAKrB,IAAU,EACV,MAAS,EACT,OAA8C;QAW9C,OAAO,YAAY,CAAC,MAAM,CAAsB,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE;YAC1E,GAAG,iCAAiC;YACpC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;SAClB,CAAC,CAAC;IACJ,CAAC;IAEe,eAAe,CAK9B,IAAU,EACV,CAAI,EACJ,OAA8C;QAY9C,OAAO,IAAI,CAAC,MAAM,CACjB,IAAI,EACJ,CAAqD,EACrD,OAAO,CAUP,CAAC;IACH,CAAC;IAoGD;;;;;OAKG;IACI,MAAM,CACZ,kBAA8E,EAC9E,iBAAqB,EACrB,OAA2B;QAS3B,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,KAAK,GAAG,kBAAsE,CAAC;YACrF,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CACnD,IAAI,CAAC,WAAW,CACf,QAAQ,EACR,kBAAuB;YACvB,kBAAkB,CAAC,KAAK;YACxB,6BAA6B,CAAC,IAAI,CAClC,CASD,CAAC;QACH,CAAC;QACD,MAAM,GAAG,GAQL,IAAI,CAAC,WAAW,CACnB,kBAA2B,EAC3B,iBAAiB;QACjB,kBAAkB,CAAC,IAAI;QACvB,6BAA6B,CAAC,IAAI,EAClC,OAAO,CACP,CAAC;QACF,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;;;;;;OAOG;IACK,WAAW,CAMlB,IAAU,EACV,YAAe,EACf,YAAqB,EACrB,uBAAgD,EAChD,OAA4C;QAW5C,OAAO,YAAY,CAAC;YACnB,UAAU,EAAE,MAAM,CAAsB,IAAI,EAAE,IAAI,CAAC;YACnD,IAAI,EAAE,YAAY;YAClB,YAAY;YACZ,uBAAuB;YACvB,WAAW,EAAE,OAAO;SACpB,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,4EAA4E;IACrE,eAAe,CAIpB,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CACpC,IAAI,EACJ,YAAwC;QACxC,kBAAkB,CAAC,IAAI;QACvB,iFAAiF;QACjF,8GAA8G;QAC9G,6BAA6B,CAAC,KAAK,EACnC,OAAO,CACP,CAAC;QAEF,OAAO,YAgBN,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tImplicitAllowedTypes,\n\tNodeKind,\n\tTreeNodeSchema,\n\tTreeNodeSchemaBoth,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchemaNonClass,\n\tWithType,\n} from \"../core/index.js\";\n\nimport {\n\tobjectSchema,\n\trecordSchema,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype RecordNodeInsertableData,\n\ttype TreeObjectNode,\n\ttype TreeRecordNode,\n} from \"../node-kinds/index.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tscoped,\n\tstructuralName,\n\ttype NodeSchemaOptions,\n\ttype ObjectSchemaOptions,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport type { System_Unsafe, TreeRecordNodeUnsafe } from \"./typesUnsafe.js\";\n\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\nimport type {\n\tFieldProps,\n\tFieldSchemaAlpha,\n\tFieldPropsAlpha,\n\tFieldKind,\n\tImplicitFieldSchema,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */\n\n/**\n * {@link SchemaFactory} with additional beta APIs.\n * @beta\n * @privateRemarks\n */\nexport class SchemaFactoryBeta<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryBeta<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryBeta(scoped<TScope, TName, T>(this, name));\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\ttrue,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> {\n\t\treturn objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {\n\t\t\t...defaultSchemaFactoryObjectOptions,\n\t\t\t...(options ?? {}),\n\t\t});\n\t}\n\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param allowedTypes - The types that may appear in the record.\n\t *\n\t * @remarks\n\t * The identifier for this record is defined as a function of the provided types.\n\t * It is still scoped to this `SchemaFactory`, but multiple calls with the same arguments will return the same\n\t * schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named records, other types in this schema builder should avoid names of the form `Record<${string}>`.\n\t *\n\t * The underlying data format for `Record` nodes is the same as that for `Map` nodes.\n\t * Therefore, changing an existing `Map` schema to a `Record` schema (or vice versa) is\n\t * a non-breaking change and does not require schema migration.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyRecord = factory.record(factory.number);\n\t * type MyRecord = NodeFromSchema<typeof Record>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", { myRecord: factory.record(factory.number) });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * The name produced at the type-level here is not as specific as it could be; however, doing type-level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal, since TypeScript's structural types will allow assignment between runtime incompatible types at compile time.\n\t * For example, attempts to narrow unions of structural records by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls to this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\t/* Name */ ScopedSchemaName<TScope, `Record<${string}>`>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @remarks\n\t * The underlying data format for `Record` nodes is the same as that for `Map` nodes.\n\t * Therefore, changing an existing `Map` schema to a `Record` schema (or vice versa) is\n\t * a non-breaking change and does not require schema migration.\n\t *\n\t * Like TypeScript `Record`s, record nodes have some potential pitfalls.\n\t * For example: TypeScript makes assumptions about built-in keys being present (e.g. `toString`, `hasOwnProperty`, etc.).\n\t * Since these are otherwise valid keys in a record, this can lead to unexpected behavior.\n\t * To prevent inconsistent behavior, these built-ins are hidden by record nodes.\n\t * This means that if you try to call these built-ins (e.g. `toString()`) on a record node, you will get an error.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.record(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic record<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined,\n\t\t/* TCustomMetadata */ TCustomMetadata\n\t>;\n\n\t/**\n\t * {@link SchemaFactoryBeta.record} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return {@link TreeNodeSchemaBoth}: see note on {@link SchemaFactory.map} implementation for details.\n\t */\n\tpublic record<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tmaybeAllowedTypes?: T,\n\t\toptions?: NodeSchemaOptions,\n\t): TreeNodeSchema<\n\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T\n\t> {\n\t\tif (maybeAllowedTypes === undefined) {\n\t\t\tconst types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Record\", types);\n\t\t\treturn this.getStructuralType(fullName, types, () =>\n\t\t\t\tthis.namedRecord(\n\t\t\t\t\tfullName,\n\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t/* customizable */ false,\n\t\t\t\t\t/* implicitlyConstructable */ true,\n\t\t\t\t),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t\t/* Info */ T,\n\t\t\t\t/* TConstructorExtra */ undefined\n\t\t\t>;\n\t\t}\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t> = this.namedRecord(\n\t\t\tnameOrAllowedTypes as TName,\n\t\t\tmaybeAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t/* implicitlyConstructable */ true,\n\t\t\toptions,\n\t\t);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `record` which takes a name instead.\n\t */\n\tprivate namedRecord<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaBoth<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable,\n\t\t\timplicitlyConstructable,\n\t\t\tnodeOptions: options,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\tconst RecordSchema = this.namedRecord(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\t/* implicitlyConstructable */ false,\n\t\t\toptions,\n\t\t);\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFactoryBeta.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryBeta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,6BAA6B,EAC7B,mBAAmB,EACnB,+BAA+B,GAY/B,MAAM,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E,eAAe,CAIpB,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CACpC,IAAI,EACJ,YAAwC;QACxC,kBAAkB,CAAC,IAAI;QACvB,iFAAiF;QACjF,8GAA8G;QAC9G,6BAA6B,CAAC,KAAK,EACnC,OAAO,CACP,CAAC;QAEF,OAAO,YAgBN,CAAC;IACH,CAAC;;AA9VD;;GAEG;AACW,wBAAM,GAAG,iBAAiB,CAAC,MAAM,AAA3B,CAA4B;AAOhD;;GAEG;AACW,iCAAe,GAAG,iBAAiB,CAAC,eAAe,AAApC,CAAqC;AAOlE;;GAEG;AACW,uBAAK,GAAG,iBAAiB,CAAC,KAAK,AAA1B,CAA2B;AAO9C;;GAEG;AACW,gCAAc,GAAG,iBAAiB,CAAC,cAAc,AAAnC,CAAoC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tAnnotatedAllowedTypesInternal,\n\tcreateSchemaUpgrade,\n\tnormalizeToAnnotatedAllowedType,\n\ttype AllowedTypesFullFromMixed,\n\ttype AllowedTypesMetadata,\n\ttype AnnotatedAllowedType,\n\ttype ImplicitAllowedTypes,\n\ttype LazyItem,\n\ttype NodeKind,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaBoth,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype WithType,\n} from \"../core/index.js\";\n\nimport {\n\tobjectSchema,\n\trecordSchema,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype RecordNodeInsertableData,\n\ttype TreeObjectNode,\n\ttype TreeRecordNode,\n} from \"../node-kinds/index.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tscoped,\n\tstructuralName,\n\ttype NodeSchemaOptions,\n\ttype ObjectSchemaOptions,\n\ttype ScopedSchemaName,\n} from \"./schemaFactory.js\";\nimport type {\n\tAllowedTypesFullFromMixedUnsafe,\n\tAnnotatedAllowedTypeUnsafe,\n\tSystem_Unsafe,\n\tTreeRecordNodeUnsafe,\n\tUnannotateAllowedTypeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\n\n// These imports prevent a large number of type references in the API reports from showing up as *_2.\n/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\nimport type {\n\tFieldProps,\n\tFieldSchemaAlpha,\n\tFieldPropsAlpha,\n\tFieldKind,\n\tImplicitFieldSchema,\n} from \"../fieldSchema.js\";\nimport type { LeafSchema } from \"../leafNodeSchema.js\";\nimport type { SimpleLeafNodeSchema } from \"../simpleSchema.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\n/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import-x/no-duplicates */\n\n/**\n * Stateless APIs exposed via {@link SchemaFactoryBeta} as both instance properties and as statics.\n * @see {@link SchemaStatics} for why this is useful.\n * @system @sealed @beta\n */\nexport interface SchemaStaticsBeta {\n\t/**\n\t * Declares a staged type in a set of {@link AllowedTypes}.\n\t *\n\t * @remarks\n\t * Staged allowed types add support for loading documents which may contain that type at the declared location.\n\t * This allows for an incremental rollout of a schema change to add a {@link TreeNodeSchema} to an {@link AllowedTypes} without breaking cross version collaboration.\n\t * A guide on this process can be found here: https://fluidframework.com/docs/data-structures/tree/schema-evolution/allowed-types-rollout\n\t *\n\t * Once enough clients have the type staged (and thus can read documents which allow it), documents can start being created and upgraded to allow the staged type.\n\t * This is done by deploying a new version of the app which removes the `staged` wrapper around the allowed type in the the schema definition.\n\t * This will also require {@link TreeView.upgradeSchema|upgrading the schema} for existing documents.\n\t *\n\t * Using a staged allowed type in a schema is just like using the schema as an allowed type with the following exceptions:\n\t *\n\t * 1. {@link TreeView.initialize} will omit the staged allowed type from the newly created stored schema.\n\t * 2. {@link TreeView.upgradeSchema} will omit the staged allowed type from the the upgraded stored schema.\n\t * 3. When evaluating {@link TreeView.compatibility}, it will be viewable even if the staged allowed type is not present in the stored schema's corresponding allowed types.\n\t * 4. Because of the above, it is possible to get errors when inserting content which uses the staged allowed type into a tree whose stored schema does not permit it.\n\t *\n\t * For recursive schemas, use {@link SchemaStaticsBeta.stagedRecursive} instead.\n\t * It offers equivalent runtime behavior with relaxed compile-time typing for recursive type.\n\t *\n\t * @example\n\t * A full code example of the schema migration process can be found in our {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/src/test/simple-tree/api/stagedSchemaUpgrade.spec.ts | tests}.\n\t *\n\t * @privateRemarks\n\t * TODO:#44317 staged allowed types rely on schema validation of stored schema to output errors, these errors are not very\n\t * user friendly and should be improved, particularly in the case of staged allowed types\n\t *\n\t * TODO: AB#45711: Update the docs above when recursive type support is added.\n\t */\n\treadonly staged: <const T extends LazyItem<TreeNodeSchema>>(\n\t\tt: T | AnnotatedAllowedType<T>,\n\t) => AnnotatedAllowedType<T>;\n\n\t/**\n\t * Normalize information about a set of {@link AllowedTypes} into an {@link AllowedTypesFull}.\n\t * @remarks\n\t * This can take in {@link AnnotatedAllowedType} to preserve their annotations.\n\t */\n\treadonly types: <\n\t\tconst T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],\n\t>(\n\t\tt: T,\n\t\tmetadata?: AllowedTypesMetadata,\n\t) => AllowedTypesFullFromMixed<T>;\n\n\t/**\n\t * {@link SchemaStaticsBeta.staged} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsBeta.staged} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\tstagedRecursive: <\n\t\tconst T extends Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>,\n\t>(\n\t\tt: T,\n\t) => AnnotatedAllowedTypeUnsafe<UnannotateAllowedTypeUnsafe<T>>;\n\n\t/**\n\t * {@link SchemaStaticsBeta.types} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of {@link SchemaStaticsBeta.types} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t * @privateRemarks\n\t * If all inputs (at least recursive ones) were required to be annotated, this could be typed more strongly.\n\t * In that case it could use `T extends readonly (AnnotatedAllowedTypeUnsafe | LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>)[]`.\n\t */\n\treadonly typesRecursive: <\n\t\tconst T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],\n\t>(\n\t\tt: T,\n\t\tmetadata?: AllowedTypesMetadata,\n\t) => AllowedTypesFullFromMixedUnsafe<T>;\n}\n\nconst staged = <const T extends LazyItem<TreeNodeSchema>>(\n\tt: T | AnnotatedAllowedType<T>,\n): AnnotatedAllowedType<T> => {\n\tconst annotatedType = normalizeToAnnotatedAllowedType(t);\n\treturn {\n\t\ttype: annotatedType.type,\n\t\tmetadata: {\n\t\t\t...annotatedType.metadata,\n\t\t\tstagedSchemaUpgrade: createSchemaUpgrade(),\n\t\t},\n\t};\n};\n\nconst types = <const T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]>(\n\tt: T,\n\tmetadata: AllowedTypesMetadata = {},\n): AllowedTypesFullFromMixed<T> => {\n\treturn AnnotatedAllowedTypesInternal.createMixed<T>(t, metadata);\n};\n\nconst schemaStaticsBeta: SchemaStaticsBeta = {\n\tstaged,\n\ttypes,\n\n\tstagedRecursive: staged as SchemaStaticsBeta[\"stagedRecursive\"],\n\ttypesRecursive: types as unknown as SchemaStaticsBeta[\"typesRecursive\"],\n};\n\n/**\n * {@link SchemaFactory} with additional beta APIs.\n * @beta\n * @privateRemarks\n */\nexport class SchemaFactoryBeta<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.staged}\n\t */\n\tpublic static staged = schemaStaticsBeta.staged;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.staged}\n\t */\n\tpublic staged = schemaStaticsBeta.staged;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.stagedRecursive}\n\t */\n\tpublic static stagedRecursive = schemaStaticsBeta.stagedRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.stagedRecursive}\n\t */\n\tpublic stagedRecursive = schemaStaticsBeta.stagedRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.types}\n\t */\n\tpublic static types = schemaStaticsBeta.types;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.types}\n\t */\n\tpublic types = schemaStaticsBeta.types;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.typesRecursive}\n\t */\n\tpublic static typesRecursive = schemaStaticsBeta.typesRecursive;\n\n\t/**\n\t * {@inheritDoc SchemaStaticsBeta.typesRecursive}\n\t */\n\tpublic typesRecursive = schemaStaticsBeta.typesRecursive;\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryBeta<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryBeta(scoped<TScope, TName, T>(this, name));\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: ObjectSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\ttrue,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> {\n\t\treturn objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {\n\t\t\t...defaultSchemaFactoryObjectOptions,\n\t\t\t...(options ?? {}),\n\t\t});\n\t}\n\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<System_Unsafe.ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: ObjectSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tSystem_Unsafe.TreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & System_Unsafe.InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param allowedTypes - The types that may appear in the record.\n\t *\n\t * @remarks\n\t * The identifier for this record is defined as a function of the provided types.\n\t * It is still scoped to this `SchemaFactory`, but multiple calls with the same arguments will return the same\n\t * schema object, providing somewhat structural typing.\n\t * This does not support recursive types.\n\t *\n\t * If using these structurally named records, other types in this schema builder should avoid names of the form `Record<${string}>`.\n\t *\n\t * The underlying data format for `Record` nodes is the same as that for `Map` nodes.\n\t * Therefore, changing an existing `Map` schema to a `Record` schema (or vice versa) is\n\t * a non-breaking change and does not require schema migration.\n\t *\n\t * @example\n\t * The returned schema should be used as a schema directly:\n\t * ```typescript\n\t * const MyRecord = factory.record(factory.number);\n\t * type MyRecord = NodeFromSchema<typeof Record>;\n\t * ```\n\t * Or inline:\n\t * ```typescript\n\t * factory.object(\"Foo\", { myRecord: factory.record(factory.number) });\n\t * ```\n\t *\n\t * @privateRemarks\n\t * The name produced at the type-level here is not as specific as it could be; however, doing type-level sorting and escaping is a real mess.\n\t * There are cases where not having this full type provided will be less than ideal, since TypeScript's structural types will allow assignment between runtime incompatible types at compile time.\n\t * For example, attempts to narrow unions of structural records by name won't work.\n\t * Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,\n\t * though there may still be some problematic cases even after that work is done.\n\t *\n\t * The return value is a class, but its type is intentionally not specific enough to indicate it is a class.\n\t * This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls to this different subclasses)\n\t * when working with structural typing.\n\t *\n\t * {@label STRUCTURAL}\n\t */\n\tpublic record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(\n\t\tallowedTypes: T,\n\t): TreeNodeSchemaNonClass<\n\t\t/* Name */ ScopedSchemaName<TScope, `Record<${string}>`>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t>;\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the record.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @remarks\n\t * The underlying data format for `Record` nodes is the same as that for `Map` nodes.\n\t * Therefore, changing an existing `Map` schema to a `Record` schema (or vice versa) is\n\t * a non-breaking change and does not require schema migration.\n\t *\n\t * Like TypeScript `Record`s, record nodes have some potential pitfalls.\n\t * For example: TypeScript makes assumptions about built-in keys being present (e.g. `toString`, `hasOwnProperty`, etc.).\n\t * Since these are otherwise valid keys in a record, this can lead to unexpected behavior.\n\t * To prevent inconsistent behavior, these built-ins are hidden by record nodes.\n\t * This means that if you try to call these built-ins (e.g. `toString()`) on a record node, you will get an error.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedRecord extends factory.record(\"name\", factory.number) {}\n\t * ```\n\t *\n\t * {@label NAMED}\n\t */\n\tpublic record<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined,\n\t\t/* TCustomMetadata */ TCustomMetadata\n\t>;\n\n\t/**\n\t * {@link SchemaFactoryBeta.record} implementation.\n\t *\n\t * @privateRemarks\n\t * This should return {@link TreeNodeSchemaBoth}: see note on {@link SchemaFactory.map} implementation for details.\n\t */\n\tpublic record<const T extends ImplicitAllowedTypes>(\n\t\tnameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),\n\t\tmaybeAllowedTypes?: T,\n\t\toptions?: NodeSchemaOptions,\n\t): TreeNodeSchema<\n\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ true,\n\t\t/* Info */ T\n\t> {\n\t\tif (maybeAllowedTypes === undefined) {\n\t\t\tconst nodeTypes = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];\n\t\t\tconst fullName = structuralName(\"Record\", nodeTypes);\n\t\t\treturn this.getStructuralType(fullName, nodeTypes, () =>\n\t\t\t\tthis.namedRecord(\n\t\t\t\t\tfullName,\n\t\t\t\t\tnameOrAllowedTypes as T,\n\t\t\t\t\t/* customizable */ false,\n\t\t\t\t\t/* implicitlyConstructable */ true,\n\t\t\t\t),\n\t\t\t) as TreeNodeSchemaClass<\n\t\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t\t/* Info */ T,\n\t\t\t\t/* TConstructorExtra */ undefined\n\t\t\t>;\n\t\t}\n\t\tconst out: TreeNodeSchemaBoth<\n\t\t\t/* Name */ ScopedSchemaName<TScope, string>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<T>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined\n\t\t> = this.namedRecord(\n\t\t\tnameOrAllowedTypes as TName,\n\t\t\tmaybeAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t/* implicitlyConstructable */ true,\n\t\t\toptions,\n\t\t);\n\t\treturn out;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t *\n\t * @remarks\n\t * This is not intended to be used directly, use the overload of `record` which takes a name instead.\n\t */\n\tprivate namedRecord<\n\t\tName extends TName | string,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst ImplicitlyConstructable extends boolean,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\tcustomizable: boolean,\n\t\timplicitlyConstructable: ImplicitlyConstructable,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaBoth<\n\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t/* Kind */ NodeKind.Record,\n\t\t/* TNode */ TreeRecordNode<T> &\n\t\t\tWithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,\n\t\t/* TInsertable */ RecordNodeInsertableData<T>,\n\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t/* Info */ T,\n\t\t/* TConstructorExtra */ undefined\n\t> {\n\t\treturn recordSchema({\n\t\t\tidentifier: scoped<TScope, TName, Name>(this, name),\n\t\t\tinfo: allowedTypes,\n\t\t\tcustomizable,\n\t\t\timplicitlyConstructable,\n\t\t\tnodeOptions: options,\n\t\t});\n\t}\n\n\t/**\n\t * {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.\n\t * Use with {@link ValidateRecursiveSchema} for improved type safety.\n\t * @remarks\n\t * This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.\n\t * See {@link ValidateRecursiveSchema} for additional information about using recursive schema.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic recordRecursive<\n\t\tName extends TName,\n\t\tconst T extends System_Unsafe.ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\tconst RecordSchema = this.namedRecord(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\t/* customizable */ true,\n\t\t\t// Setting this to true seems to work ok currently, but not for other node kinds.\n\t\t\t// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.\n\t\t\t/* implicitlyConstructable */ false,\n\t\t\toptions,\n\t\t);\n\n\t\treturn RecordSchema as TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<TScope, Name>,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNodeUnsafe<T> &\n\t\t\t\tWithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,\n\t\t\t/* TInsertable */ {\n\t\t\t\t// Ideally this would be\n\t\t\t\t// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,\n\t\t\t\t// but doing so breaks recursive types.\n\t\t\t\t// Instead we do a less nice version:\n\t\t\t\treadonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t},\n\t\t\t/* ImplicitlyConstructable */ false,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ undefined,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>;\n\t}\n}\n"]}
@@ -65,9 +65,12 @@ function generateNode(id, schema, context) {
65
65
  for (const [key, field] of schema.fields) {
66
66
  fields[key] = generateFieldSchema(field, context, field.storedKey);
67
67
  }
68
- // Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:
69
- // users of this code are expected to handle what ever choice this code makes for cases like this.
70
- return factory.objectAlpha(id, fields, { metadata: schema.metadata });
68
+ // Here allowUnknownOptionalFields is implicitly defaulting in the case where the input schema does not explicitly specify the value.
69
+ // This is a subjective policy choice: users of this code are expected to handle what ever choice this code makes for cases like this.
70
+ return factory.objectAlpha(id, fields, {
71
+ metadata: schema.metadata,
72
+ allowUnknownOptionalFields: schema.allowUnknownOptionalFields ?? false,
73
+ });
71
74
  }
72
75
  case NodeKind.Array:
73
76
  return factory.arrayAlpha(id, generateAllowedTypes(schema.simpleAllowedTypes, context), {
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFromSimple.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAA0C,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAGN,SAAS,GAET,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAwB;IACtE,MAAM,OAAO,GAAY,IAAI,GAAG,CAC/B,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAqD,EAAE,CAAC;QACpE,EAAE;QACF,8EAA8E;QAC9E,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC;KACvC,CACD,CACD,CAAC;IACF,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA6C,CAAC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C,CAAC;QACH;YACC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport { NodeKind, type TreeNodeSchema, type AllowedTypes } from \"../core/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype FieldSchemaAlpha,\n\tFieldKind,\n\ttype FieldProps,\n} from \"../fieldSchema.js\";\nimport type {\n\tSimpleAllowedTypeAttributes,\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\n\nimport type { TreeSchema } from \"./configuration.js\";\nimport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\n\nconst factory = new SchemaFactoryAlpha(undefined);\n\n/**\n * Create {@link FieldSchema} from a SimpleTreeSchema.\n * @remarks\n * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.\n *\n * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}\n * will produce a poor TypeScript typing experience which is subject to change.\n *\n * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.\n *\n * This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.\n * If any particular choice is required for such cases, this API should not be used.\n * @alpha\n */\nexport function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema {\n\tconst context: Context = new Map(\n\t\t[...simple.definitions].map(\n\t\t\t([id, schema]): [string, () => TreeNodeSchema & SimpleNodeSchema] => [\n\t\t\t\tid,\n\t\t\t\t// This relies on the caching in evaluateLazySchema so that it only runs once.\n\t\t\t\t() => generateNode(id, schema, context),\n\t\t\t],\n\t\t),\n\t);\n\tconst root = generateFieldSchema(simple.root, context, undefined);\n\tconst definitions = new Map<string, TreeNodeSchema & SimpleNodeSchema>();\n\tfor (const [id, lazy] of context) {\n\t\tdefinitions.set(id, lazy());\n\t}\n\treturn {\n\t\troot,\n\t\tdefinitions,\n\t};\n}\n\ntype Context = ReadonlyMap<string, () => TreeNodeSchema & SimpleNodeSchema>;\n\nfunction generateFieldSchema(\n\tsimple: SimpleFieldSchema,\n\tcontext: Context,\n\tstoredKey: string | undefined,\n): FieldSchemaAlpha {\n\tconst allowed = generateAllowedTypes(simple.simpleAllowedTypes, context);\n\tconst props: Omit<FieldProps, \"defaultProvider\"> = {\n\t\tmetadata: simple.metadata,\n\t\tkey: storedKey,\n\t};\n\n\t// Using createFieldSchema could work, but would require setting up the default providers.\n\tswitch (simple.kind) {\n\t\tcase FieldKind.Identifier:\n\t\t\treturn SchemaFactoryAlpha.identifier(props);\n\t\tcase FieldKind.Optional:\n\t\t\treturn SchemaFactoryAlpha.optional(allowed, props);\n\t\tcase FieldKind.Required:\n\t\t\treturn SchemaFactoryAlpha.required(allowed, props);\n\t\tdefault:\n\t\t\treturn unreachableCase(simple.kind);\n\t}\n}\n\nfunction generateAllowedTypes(\n\tallowed: ReadonlyMap<string, SimpleAllowedTypeAttributes>,\n\tcontext: Context,\n): AllowedTypes {\n\treturn Array.from(\n\t\tallowed.keys(),\n\t\t(id) => context.get(id) ?? fail(0xb5a /* Missing schema */),\n\t);\n}\n\nfunction generateNode(\n\tid: string,\n\tschema: SimpleNodeSchema,\n\tcontext: Context,\n): TreeNodeSchema & SimpleNodeSchema {\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Record<string, FieldSchema> = {};\n\t\t\tfor (const [key, field] of schema.fields) {\n\t\t\t\tfields[key] = generateFieldSchema(field, context, field.storedKey);\n\t\t\t}\n\t\t\t// Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:\n\t\t\t// users of this code are expected to handle what ever choice this code makes for cases like this.\n\t\t\treturn factory.objectAlpha(id, fields, { metadata: schema.metadata });\n\t\t}\n\t\tcase NodeKind.Array:\n\t\t\treturn factory.arrayAlpha(id, generateAllowedTypes(schema.simpleAllowedTypes, context), {\n\t\t\t\tmetadata: schema.metadata,\n\t\t\t});\n\t\tcase NodeKind.Map:\n\t\t\treturn factory.mapAlpha(id, generateAllowedTypes(schema.simpleAllowedTypes, context), {\n\t\t\t\tmetadata: schema.metadata,\n\t\t\t});\n\t\tcase NodeKind.Record:\n\t\t\treturn factory.recordAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.simpleAllowedTypes, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Leaf:\n\t\t\treturn (\n\t\t\t\tSchemaFactoryAlpha.leaves.find((leaf) => leaf.identifier === id) ??\n\t\t\t\tfail(0xb5b /* Missing schema */)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn unreachableCase(schema);\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFromSimple.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAA0C,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAGN,SAAS,GAET,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAwB;IACtE,MAAM,OAAO,GAAY,IAAI,GAAG,CAC/B,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAC1B,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAqD,EAAE,CAAC;QACpE,EAAE;QACF,8EAA8E;QAC9E,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,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,CAAC,QAAQ,EAAE,CAC7B,CAAC;QACH,KAAK,QAAQ,CAAC,IAAI;YACjB,OAAO,CACN,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC;gBAChE,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAChC,CAAC;QACH;YACC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\n\nimport { NodeKind, type TreeNodeSchema, type AllowedTypes } from \"../core/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype FieldSchemaAlpha,\n\tFieldKind,\n\ttype FieldProps,\n} from \"../fieldSchema.js\";\nimport type {\n\tSimpleAllowedTypeAttributes,\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\n\nimport type { TreeSchema } from \"./configuration.js\";\nimport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\n\nconst factory = new SchemaFactoryAlpha(undefined);\n\n/**\n * Create {@link FieldSchema} from a SimpleTreeSchema.\n * @remarks\n * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.\n *\n * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}\n * will produce a poor TypeScript typing experience which is subject to change.\n *\n * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.\n *\n * This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.\n * If any particular choice is required for such cases, this API should not be used.\n * @alpha\n */\nexport function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema {\n\tconst context: Context = new Map(\n\t\t[...simple.definitions].map(\n\t\t\t([id, schema]): [string, () => TreeNodeSchema & SimpleNodeSchema] => [\n\t\t\t\tid,\n\t\t\t\t// This relies on the caching in evaluateLazySchema so that it only runs once.\n\t\t\t\t() => generateNode(id, schema, context),\n\t\t\t],\n\t\t),\n\t);\n\tconst root = generateFieldSchema(simple.root, context, undefined);\n\tconst definitions = new Map<string, TreeNodeSchema & SimpleNodeSchema>();\n\tfor (const [id, lazy] of context) {\n\t\tdefinitions.set(id, lazy());\n\t}\n\treturn {\n\t\troot,\n\t\tdefinitions,\n\t};\n}\n\ntype Context = ReadonlyMap<string, () => TreeNodeSchema & SimpleNodeSchema>;\n\nfunction generateFieldSchema(\n\tsimple: SimpleFieldSchema,\n\tcontext: Context,\n\tstoredKey: string | undefined,\n): FieldSchemaAlpha {\n\tconst allowed = generateAllowedTypes(simple.simpleAllowedTypes, context);\n\tconst props: Omit<FieldProps, \"defaultProvider\"> = {\n\t\tmetadata: simple.metadata,\n\t\tkey: storedKey,\n\t};\n\n\t// Using createFieldSchema could work, but would require setting up the default providers.\n\tswitch (simple.kind) {\n\t\tcase FieldKind.Identifier:\n\t\t\treturn SchemaFactoryAlpha.identifier(props);\n\t\tcase FieldKind.Optional:\n\t\t\treturn SchemaFactoryAlpha.optional(allowed, props);\n\t\tcase FieldKind.Required:\n\t\t\treturn SchemaFactoryAlpha.required(allowed, props);\n\t\tdefault:\n\t\t\treturn unreachableCase(simple.kind);\n\t}\n}\n\nfunction generateAllowedTypes(\n\tallowed: ReadonlyMap<string, SimpleAllowedTypeAttributes>,\n\tcontext: Context,\n): AllowedTypes {\n\treturn Array.from(\n\t\tallowed.keys(),\n\t\t(id) => context.get(id) ?? fail(0xb5a /* Missing schema */),\n\t);\n}\n\nfunction generateNode(\n\tid: string,\n\tschema: SimpleNodeSchema,\n\tcontext: Context,\n): TreeNodeSchema & SimpleNodeSchema {\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Record<string, FieldSchema> = {};\n\t\t\tfor (const [key, field] of schema.fields) {\n\t\t\t\tfields[key] = generateFieldSchema(field, context, field.storedKey);\n\t\t\t}\n\t\t\t// Here allowUnknownOptionalFields is implicitly defaulting in the case where the input schema does not explicitly specify the value.\n\t\t\t// This is a subjective policy choice: users of this code are expected to handle what ever choice this code makes for cases like this.\n\t\t\treturn factory.objectAlpha(id, fields, {\n\t\t\t\tmetadata: schema.metadata,\n\t\t\t\tallowUnknownOptionalFields: schema.allowUnknownOptionalFields ?? false,\n\t\t\t});\n\t\t}\n\t\tcase NodeKind.Array:\n\t\t\treturn factory.arrayAlpha(id, generateAllowedTypes(schema.simpleAllowedTypes, context), {\n\t\t\t\tmetadata: schema.metadata,\n\t\t\t});\n\t\tcase NodeKind.Map:\n\t\t\treturn factory.mapAlpha(id, generateAllowedTypes(schema.simpleAllowedTypes, context), {\n\t\t\t\tmetadata: schema.metadata,\n\t\t\t});\n\t\tcase NodeKind.Record:\n\t\t\treturn factory.recordAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.simpleAllowedTypes, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Leaf:\n\t\t\treturn (\n\t\t\t\tSchemaFactoryAlpha.leaves.find((leaf) => leaf.identifier === id) ??\n\t\t\t\tfail(0xb5b /* Missing schema */)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn unreachableCase(schema);\n\t}\n}\n"]}
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type JsonCompatibleReadOnly } from "../../util/index.js";
6
+ import type { SimpleTreeSchema } from "../simpleSchema.js";
7
+ import { type FormatValidator } from "../../codec/index.js";
8
+ /**
9
+ * Encodes a simple schema (view or stored) into a serializable format.
10
+ * @remarks The JSON-compatible schema returned from this method is only intended for use in snapshots/comparisons of schemas.
11
+ * It is not possible to reconstruct a full schema (including metadata and persistedMetadata) from the encoded format.
12
+ * @param treeSchema - The tree schema to convert.
13
+ * @returns A serializable representation of the schema.
14
+ *
15
+ * @alpha
16
+ */
17
+ export declare function encodeSimpleSchema(simpleSchema: SimpleTreeSchema): JsonCompatibleReadOnly;
18
+ /**
19
+ * Decodes a JSON-compatible schema into a simple schema.
20
+ * @param encodedSchema - The encoded schema to decode.
21
+ * @param validator - The format validator to use to validate the encoded schema.
22
+ * @returns A decoded simple schema.
23
+ * @throws Will throw a usage error if the encoded schema is not in the expected format.
24
+ *
25
+ * @alpha
26
+ */
27
+ export declare function decodeSimpleSchema(encodedSchema: JsonCompatibleReadOnly, validator?: FormatValidator): SimpleTreeSchema;
28
+ //# sourceMappingURL=simpleSchemaCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleSchemaCodec.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaCodec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,KAAK,EAUX,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAIN,KAAK,eAAe,EACpB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,GAAG,sBAAsB,CAgBzF;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,aAAa,EAAE,sBAAsB,EACrC,SAAS,CAAC,EAAE,eAAe,GACzB,gBAAgB,CAmBlB"}
@@ -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,EA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,CAAC,IAAiB;QACpC,kBAAkB,EAAE,wBAAwB,CAAC,YAAY,CAAC,kBAAkB,CAAC;QAC7E,2GAA2G;QAC3G,iBAAiB,EAAE,SAAS;QAC5B,QAAQ,EAAE,EAAE;KACZ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,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"]}
@@ -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,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQ1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAA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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: normalizeFieldSchema(view),
@@ -1 +1 @@
1
- {"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EACN,4BAA4B;AAE5B,sDAAsD;EACtD,MAAM,+CAA+C,CAAC;AAGvD,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,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;IAC/D,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 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
  *