@fluidframework/tree 2.53.0 → 2.60.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 (424) hide show
  1. package/.eslintrc.cjs +0 -19
  2. package/.mocharc.customBenchmarks.cjs +1 -9
  3. package/CHANGELOG.md +56 -0
  4. package/api-report/tree.alpha.api.md +50 -36
  5. package/api-report/tree.beta.api.md +15 -1
  6. package/api-report/{tree.legacy.alpha.api.md → tree.legacy.beta.api.md} +5 -5
  7. package/api-report/tree.legacy.public.api.md +1 -1
  8. package/api-report/tree.public.api.md +1 -1
  9. package/dist/alpha.d.ts +8 -2
  10. package/dist/beta.d.ts +3 -0
  11. package/dist/codec/codec.d.ts +43 -6
  12. package/dist/codec/codec.d.ts.map +1 -1
  13. package/dist/codec/codec.js +22 -2
  14. package/dist/codec/codec.js.map +1 -1
  15. package/dist/codec/index.d.ts +1 -1
  16. package/dist/codec/index.d.ts.map +1 -1
  17. package/dist/codec/index.js +4 -1
  18. package/dist/codec/index.js.map +1 -1
  19. package/dist/external-utilities/index.d.ts +1 -1
  20. package/dist/external-utilities/index.d.ts.map +1 -1
  21. package/dist/external-utilities/index.js +2 -1
  22. package/dist/external-utilities/index.js.map +1 -1
  23. package/dist/external-utilities/typeboxValidator.d.ts +6 -1
  24. package/dist/external-utilities/typeboxValidator.d.ts.map +1 -1
  25. package/dist/external-utilities/typeboxValidator.js +7 -1
  26. package/dist/external-utilities/typeboxValidator.js.map +1 -1
  27. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  28. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +28 -5
  30. package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  32. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  34. package/dist/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  35. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  36. package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  37. package/dist/feature-libraries/chunked-forest/codec/codecs.js +9 -2
  38. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  40. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  41. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +91 -16
  42. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  44. package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/codec/format.js +10 -1
  46. package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  47. package/dist/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  48. package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  50. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  51. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  52. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +17 -6
  53. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  54. package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
  55. package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  56. package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
  57. package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  58. package/dist/feature-libraries/forest-summary/codec.js +3 -0
  59. package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
  60. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  61. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  62. package/dist/feature-libraries/forest-summary/forestSummarizer.js +76 -38
  63. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  64. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  65. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  66. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +322 -0
  67. package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  68. package/dist/feature-libraries/forest-summary/index.d.ts +1 -1
  69. package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
  70. package/dist/feature-libraries/forest-summary/index.js +2 -1
  71. package/dist/feature-libraries/forest-summary/index.js.map +1 -1
  72. package/dist/feature-libraries/index.d.ts +1 -1
  73. package/dist/feature-libraries/index.d.ts.map +1 -1
  74. package/dist/feature-libraries/index.js +2 -1
  75. package/dist/feature-libraries/index.js.map +1 -1
  76. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  77. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  78. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -1
  79. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  80. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  81. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  82. package/dist/feature-libraries/treeCompressionUtils.d.ts +15 -0
  83. package/dist/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  84. package/dist/feature-libraries/treeCompressionUtils.js +16 -1
  85. package/dist/feature-libraries/treeCompressionUtils.js.map +1 -1
  86. package/dist/index.d.ts +3 -3
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +6 -2
  89. package/dist/index.js.map +1 -1
  90. package/dist/jsonDomainSchema.d.ts +1 -1
  91. package/dist/jsonDomainSchema.d.ts.map +1 -1
  92. package/dist/packageVersion.d.ts +1 -1
  93. package/dist/packageVersion.js +1 -1
  94. package/dist/packageVersion.js.map +1 -1
  95. package/dist/shared-tree/schematizingTreeView.d.ts +1 -1
  96. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  97. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  98. package/dist/shared-tree/sharedTree.d.ts +23 -6
  99. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  100. package/dist/shared-tree/sharedTree.js +4 -1
  101. package/dist/shared-tree/sharedTree.js.map +1 -1
  102. package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  103. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  104. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  105. package/dist/shared-tree/tree.d.ts.map +1 -1
  106. package/dist/shared-tree/tree.js +3 -0
  107. package/dist/shared-tree/tree.js.map +1 -1
  108. package/dist/shared-tree/treeAlpha.d.ts +9 -11
  109. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  110. package/dist/shared-tree/treeAlpha.js.map +1 -1
  111. package/dist/shared-tree/treeCheckout.d.ts +2 -2
  112. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  113. package/dist/shared-tree/treeCheckout.js.map +1 -1
  114. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  115. package/dist/shared-tree-core/sharedTreeCore.js +13 -0
  116. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  117. package/dist/sharedTreeAttributes.d.ts +2 -2
  118. package/dist/sharedTreeAttributes.js +2 -2
  119. package/dist/sharedTreeAttributes.js.map +1 -1
  120. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  121. package/dist/simple-tree/api/conciseTree.js +1 -1
  122. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  123. package/dist/simple-tree/api/customTree.d.ts +39 -11
  124. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  125. package/dist/simple-tree/api/customTree.js +79 -19
  126. package/dist/simple-tree/api/customTree.js.map +1 -1
  127. package/dist/simple-tree/api/getJsonSchema.d.ts +7 -2
  128. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  129. package/dist/simple-tree/api/getJsonSchema.js +1 -0
  130. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  131. package/dist/simple-tree/api/index.d.ts +2 -1
  132. package/dist/simple-tree/api/index.d.ts.map +1 -1
  133. package/dist/simple-tree/api/index.js +4 -1
  134. package/dist/simple-tree/api/index.js.map +1 -1
  135. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  136. package/dist/simple-tree/api/schemaCreationUtilities.js +1 -1
  137. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  138. package/dist/simple-tree/api/schemaFactory.d.ts +9 -6
  139. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  140. package/dist/simple-tree/api/schemaFactory.js +8 -7
  141. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  142. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  143. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  144. package/dist/simple-tree/api/schemaFactoryAlpha.js +21 -25
  145. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  146. package/dist/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  147. package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  148. package/dist/simple-tree/api/schemaFactoryBeta.js +26 -0
  149. package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  150. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  151. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  152. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  153. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  154. package/dist/simple-tree/api/transactionTypes.d.ts +1 -0
  155. package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
  156. package/dist/simple-tree/api/transactionTypes.js.map +1 -1
  157. package/dist/simple-tree/api/tree.d.ts +68 -74
  158. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  159. package/dist/simple-tree/api/tree.js.map +1 -1
  160. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  161. package/dist/simple-tree/api/verboseTree.js +3 -3
  162. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  163. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  164. package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  165. package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  166. package/dist/simple-tree/fieldSchema.d.ts +3 -4
  167. package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
  168. package/dist/simple-tree/fieldSchema.js +0 -3
  169. package/dist/simple-tree/fieldSchema.js.map +1 -1
  170. package/dist/simple-tree/index.d.ts +1 -1
  171. package/dist/simple-tree/index.d.ts.map +1 -1
  172. package/dist/simple-tree/index.js +4 -2
  173. package/dist/simple-tree/index.js.map +1 -1
  174. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  175. package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
  176. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  177. package/dist/simple-tree/simpleSchema.d.ts +12 -0
  178. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  179. package/dist/simple-tree/simpleSchema.js.map +1 -1
  180. package/dist/simple-tree/toStoredSchema.d.ts +0 -3
  181. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  182. package/dist/simple-tree/toStoredSchema.js +0 -3
  183. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  184. package/dist/tableSchema.d.ts +11 -80
  185. package/dist/tableSchema.d.ts.map +1 -1
  186. package/dist/tableSchema.js +200 -117
  187. package/dist/tableSchema.js.map +1 -1
  188. package/dist/treeFactory.d.ts +1 -2
  189. package/dist/treeFactory.d.ts.map +1 -1
  190. package/dist/treeFactory.js +1 -2
  191. package/dist/treeFactory.js.map +1 -1
  192. package/lib/alpha.d.ts +8 -2
  193. package/lib/beta.d.ts +3 -0
  194. package/lib/codec/codec.d.ts +43 -6
  195. package/lib/codec/codec.d.ts.map +1 -1
  196. package/lib/codec/codec.js +19 -1
  197. package/lib/codec/codec.js.map +1 -1
  198. package/lib/codec/index.d.ts +1 -1
  199. package/lib/codec/index.d.ts.map +1 -1
  200. package/lib/codec/index.js +1 -1
  201. package/lib/codec/index.js.map +1 -1
  202. package/lib/external-utilities/index.d.ts +1 -1
  203. package/lib/external-utilities/index.d.ts.map +1 -1
  204. package/lib/external-utilities/index.js +1 -1
  205. package/lib/external-utilities/index.js.map +1 -1
  206. package/lib/external-utilities/typeboxValidator.d.ts +6 -1
  207. package/lib/external-utilities/typeboxValidator.d.ts.map +1 -1
  208. package/lib/external-utilities/typeboxValidator.js +6 -0
  209. package/lib/external-utilities/typeboxValidator.js.map +1 -1
  210. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +10 -1
  211. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
  212. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +27 -5
  213. package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
  214. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts +19 -2
  215. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.d.ts.map +1 -1
  216. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js +10 -2
  217. package/lib/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.js.map +1 -1
  218. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +59 -4
  219. package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
  220. package/lib/feature-libraries/chunked-forest/codec/codecs.js +10 -3
  221. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  222. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +46 -8
  223. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts.map +1 -1
  224. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +87 -14
  225. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  226. package/lib/feature-libraries/chunked-forest/codec/format.d.ts +14 -0
  227. package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
  228. package/lib/feature-libraries/chunked-forest/codec/format.js +9 -0
  229. package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
  230. package/lib/feature-libraries/chunked-forest/codec/index.d.ts +1 -1
  231. package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
  232. package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
  233. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts +8 -3
  234. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  235. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +18 -7
  236. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  237. package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
  238. package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
  239. package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
  240. package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
  241. package/lib/feature-libraries/forest-summary/codec.js +3 -0
  242. package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
  243. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +13 -8
  244. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  245. package/lib/feature-libraries/forest-summary/forestSummarizer.js +75 -37
  246. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  247. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +178 -0
  248. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -0
  249. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +318 -0
  250. package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -0
  251. package/lib/feature-libraries/forest-summary/index.d.ts +1 -1
  252. package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
  253. package/lib/feature-libraries/forest-summary/index.js +1 -1
  254. package/lib/feature-libraries/forest-summary/index.js.map +1 -1
  255. package/lib/feature-libraries/index.d.ts +1 -1
  256. package/lib/feature-libraries/index.d.ts.map +1 -1
  257. package/lib/feature-libraries/index.js +1 -1
  258. package/lib/feature-libraries/index.js.map +1 -1
  259. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
  260. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  261. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +3 -3
  262. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  263. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +6 -9
  264. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  265. package/lib/feature-libraries/treeCompressionUtils.d.ts +15 -0
  266. package/lib/feature-libraries/treeCompressionUtils.d.ts.map +1 -1
  267. package/lib/feature-libraries/treeCompressionUtils.js +15 -0
  268. package/lib/feature-libraries/treeCompressionUtils.js.map +1 -1
  269. package/lib/index.d.ts +3 -3
  270. package/lib/index.d.ts.map +1 -1
  271. package/lib/index.js +4 -4
  272. package/lib/index.js.map +1 -1
  273. package/lib/jsonDomainSchema.d.ts +1 -1
  274. package/lib/jsonDomainSchema.d.ts.map +1 -1
  275. package/lib/packageVersion.d.ts +1 -1
  276. package/lib/packageVersion.js +1 -1
  277. package/lib/packageVersion.js.map +1 -1
  278. package/lib/shared-tree/schematizingTreeView.d.ts +1 -1
  279. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  280. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  281. package/lib/shared-tree/sharedTree.d.ts +23 -6
  282. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  283. package/lib/shared-tree/sharedTree.js +4 -1
  284. package/lib/shared-tree/sharedTree.js.map +1 -1
  285. package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
  286. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  287. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  288. package/lib/shared-tree/tree.d.ts.map +1 -1
  289. package/lib/shared-tree/tree.js +3 -0
  290. package/lib/shared-tree/tree.js.map +1 -1
  291. package/lib/shared-tree/treeAlpha.d.ts +9 -11
  292. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  293. package/lib/shared-tree/treeAlpha.js.map +1 -1
  294. package/lib/shared-tree/treeCheckout.d.ts +2 -2
  295. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  296. package/lib/shared-tree/treeCheckout.js.map +1 -1
  297. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  298. package/lib/shared-tree-core/sharedTreeCore.js +13 -0
  299. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  300. package/lib/sharedTreeAttributes.d.ts +2 -2
  301. package/lib/sharedTreeAttributes.js +2 -2
  302. package/lib/sharedTreeAttributes.js.map +1 -1
  303. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  304. package/lib/simple-tree/api/conciseTree.js +2 -2
  305. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  306. package/lib/simple-tree/api/customTree.d.ts +39 -11
  307. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  308. package/lib/simple-tree/api/customTree.js +79 -19
  309. package/lib/simple-tree/api/customTree.js.map +1 -1
  310. package/lib/simple-tree/api/getJsonSchema.d.ts +7 -2
  311. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  312. package/lib/simple-tree/api/getJsonSchema.js +1 -0
  313. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  314. package/lib/simple-tree/api/index.d.ts +2 -1
  315. package/lib/simple-tree/api/index.d.ts.map +1 -1
  316. package/lib/simple-tree/api/index.js +2 -1
  317. package/lib/simple-tree/api/index.js.map +1 -1
  318. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +1 -1
  319. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  320. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  321. package/lib/simple-tree/api/schemaFactory.d.ts +9 -6
  322. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  323. package/lib/simple-tree/api/schemaFactory.js +6 -6
  324. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  325. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +13 -17
  326. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  327. package/lib/simple-tree/api/schemaFactoryAlpha.js +22 -26
  328. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  329. package/lib/simple-tree/api/schemaFactoryBeta.d.ts +20 -0
  330. package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -0
  331. package/lib/simple-tree/api/schemaFactoryBeta.js +22 -0
  332. package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -0
  333. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +0 -2
  334. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  335. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -3
  336. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  337. package/lib/simple-tree/api/transactionTypes.d.ts +1 -0
  338. package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
  339. package/lib/simple-tree/api/transactionTypes.js.map +1 -1
  340. package/lib/simple-tree/api/tree.d.ts +68 -74
  341. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  342. package/lib/simple-tree/api/tree.js.map +1 -1
  343. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  344. package/lib/simple-tree/api/verboseTree.js +4 -4
  345. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  346. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +6 -0
  347. package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -1
  348. package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -1
  349. package/lib/simple-tree/fieldSchema.d.ts +3 -4
  350. package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
  351. package/lib/simple-tree/fieldSchema.js +0 -3
  352. package/lib/simple-tree/fieldSchema.js.map +1 -1
  353. package/lib/simple-tree/index.d.ts +1 -1
  354. package/lib/simple-tree/index.d.ts.map +1 -1
  355. package/lib/simple-tree/index.js +1 -1
  356. package/lib/simple-tree/index.js.map +1 -1
  357. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  358. package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
  359. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  360. package/lib/simple-tree/simpleSchema.d.ts +12 -0
  361. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  362. package/lib/simple-tree/simpleSchema.js.map +1 -1
  363. package/lib/simple-tree/toStoredSchema.d.ts +0 -3
  364. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  365. package/lib/simple-tree/toStoredSchema.js +0 -3
  366. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  367. package/lib/tableSchema.d.ts +11 -80
  368. package/lib/tableSchema.d.ts.map +1 -1
  369. package/lib/tableSchema.js +201 -118
  370. package/lib/tableSchema.js.map +1 -1
  371. package/lib/treeFactory.d.ts +1 -2
  372. package/lib/treeFactory.d.ts.map +1 -1
  373. package/lib/treeFactory.js +1 -2
  374. package/lib/treeFactory.js.map +1 -1
  375. package/package.json +22 -22
  376. package/src/codec/codec.ts +52 -7
  377. package/src/codec/index.ts +4 -0
  378. package/src/external-utilities/index.ts +1 -1
  379. package/src/external-utilities/typeboxValidator.ts +7 -1
  380. package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +38 -4
  381. package/src/feature-libraries/chunked-forest/codec/chunkDecodingGeneric.ts +10 -3
  382. package/src/feature-libraries/chunked-forest/codec/codecs.ts +96 -8
  383. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +123 -19
  384. package/src/feature-libraries/chunked-forest/codec/format.ts +11 -0
  385. package/src/feature-libraries/chunked-forest/codec/index.ts +4 -0
  386. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +28 -3
  387. package/src/feature-libraries/chunked-forest/index.ts +2 -0
  388. package/src/feature-libraries/forest-summary/codec.ts +3 -0
  389. package/src/feature-libraries/forest-summary/forestSummarizer.ts +118 -50
  390. package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +511 -0
  391. package/src/feature-libraries/forest-summary/index.ts +1 -1
  392. package/src/feature-libraries/index.ts +5 -1
  393. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +8 -4
  394. package/src/feature-libraries/treeCompressionUtils.ts +19 -0
  395. package/src/index.ts +6 -1
  396. package/src/packageVersion.ts +1 -1
  397. package/src/shared-tree/schematizingTreeView.ts +1 -1
  398. package/src/shared-tree/sharedTree.ts +37 -4
  399. package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
  400. package/src/shared-tree/tree.ts +3 -0
  401. package/src/shared-tree/treeAlpha.ts +10 -11
  402. package/src/shared-tree/treeCheckout.ts +2 -2
  403. package/src/shared-tree-core/sharedTreeCore.ts +17 -0
  404. package/src/sharedTreeAttributes.ts +2 -2
  405. package/src/simple-tree/api/conciseTree.ts +2 -1
  406. package/src/simple-tree/api/customTree.ts +102 -32
  407. package/src/simple-tree/api/getJsonSchema.ts +7 -2
  408. package/src/simple-tree/api/index.ts +3 -0
  409. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -1
  410. package/src/simple-tree/api/schemaFactory.ts +21 -14
  411. package/src/simple-tree/api/schemaFactoryAlpha.ts +29 -30
  412. package/src/simple-tree/api/schemaFactoryBeta.ts +28 -0
  413. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -3
  414. package/src/simple-tree/api/transactionTypes.ts +1 -0
  415. package/src/simple-tree/api/tree.ts +75 -81
  416. package/src/simple-tree/api/verboseTree.ts +42 -39
  417. package/src/simple-tree/core/simpleNodeSchemaBase.ts +6 -0
  418. package/src/simple-tree/fieldSchema.ts +3 -4
  419. package/src/simple-tree/index.ts +3 -0
  420. package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
  421. package/src/simple-tree/simpleSchema.ts +12 -0
  422. package/src/simple-tree/toStoredSchema.ts +0 -3
  423. package/src/tableSchema.ts +261 -243
  424. package/src/treeFactory.ts +1 -2
@@ -1 +1 @@
1
- {"version":3,"file":"fieldSchema.js","sourceRoot":"","sources":["../../src/simple-tree/fieldSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAItE,OAAO,EAEN,KAAK,EAEL,WAAW,GAIX,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,8BAA8B,EAC9B,8BAA8B,GAC9B,MAAM,iBAAiB,CAAC;AAMzB;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,SAqBX;AArBD,WAAY,SAAS;IACpB;;;;OAIG;IACH,iDAAQ,CAAA;IACR;;;;OAIG;IACH,iDAAQ,CAAA;IACR;;;;;;OAMG;IACH,qDAAU,CAAA;AACX,CAAC,EArBW,SAAS,KAAT,SAAS,QAqBpB;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC3B,WAAmB,E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YAAY,CAAC;AACtC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { FieldKey } from \"../core/index.js\";\nimport type { FlexTreeHydratedContextMinimal } from \"../feature-libraries/index.js\";\nimport {\n\ttype MakeNominal,\n\tbrand,\n\ttype UnionToIntersection,\n\tcompareSets,\n\ttype requireTrue,\n\ttype areOnlyKeys,\n\ttype JsonCompatibleReadOnlyObject,\n} from \"../util/index.js\";\n\nimport type {\n\tTreeNodeSchema,\n\tTreeNode,\n\tUnhydratedFlexTreeNode,\n\tNormalizedAnnotatedAllowedTypes,\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tUnannotateImplicitAllowedTypes,\n\tAllowedTypesMetadata,\n\tTreeNodeFromImplicitAllowedTypes,\n\tTreeLeafValue,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n} from \"./core/index.js\";\nimport {\n\tisAnnotatedAllowedTypes,\n\tnormalizeAllowedTypes,\n\tnormalizeAnnotatedAllowedTypes,\n\tunannotateImplicitAllowedTypes,\n} from \"./core/index.js\";\n\nimport type { SimpleFieldSchema } from \"./simpleSchema.js\";\nimport type { UnsafeUnknownSchema } from \"./unsafeUnknownSchema.js\";\nimport type { InsertableContent } from \"./unhydratedFlexTreeFromInsertable.js\";\n\n/**\n * Kind of a field on an {@link TreeObjectNode}.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * See {@link FieldSchema} for where these are used, and {@link SchemaFactory} for how to create schema which use them.\n * @public\n */\nexport enum FieldKind {\n\t/**\n\t * A field which can be empty or filled.\n\t * @remarks\n\t * Allows 0 or one child.\n\t */\n\tOptional,\n\t/**\n\t * A field which must always be filled.\n\t * @remarks\n\t * Only allows exactly one child.\n\t */\n\tRequired,\n\t/**\n\t * A special readonly field used for node identifier strings.\n\t * @remarks\n\t * Only allows exactly one child.\n\t *\n\t * See {@link SchemaFactory.identifier} for more details.\n\t */\n\tIdentifier,\n}\n\n/**\n * Maps from a property key to its corresponding {@link FieldProps.key | stored key} for the provided\n * {@link ImplicitFieldSchema | field schema}.\n *\n * @remarks\n * If an explicit stored key was specified in the schema, it will be used.\n * Otherwise, the stored key is the same as the property key.\n */\nexport function getStoredKey(\n\tpropertyKey: string,\n\tfieldSchema: ImplicitAnnotatedFieldSchema,\n): FieldKey {\n\treturn brand(getExplicitStoredKey(fieldSchema) ?? propertyKey);\n}\n\n/**\n * Gets the {@link FieldProps.key | stored key} specified by the schema, if one was explicitly specified.\n * Otherwise, returns undefined.\n */\nexport function getExplicitStoredKey(\n\tfieldSchema: ImplicitAnnotatedFieldSchema,\n): string | undefined {\n\treturn fieldSchema instanceof FieldSchema ? fieldSchema.props?.key : undefined;\n}\n\n/**\n * Additional information to provide to a {@link FieldSchema}.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @public\n */\nexport interface FieldProps<TCustomMetadata = unknown> {\n\t/**\n\t * The unique identifier of a field, used in the persisted form of the tree.\n\t *\n\t * @remarks\n\t * If not explicitly set via the schema, this is the same as the schema's property key.\n\t *\n\t * Specifying a stored key that differs from the property key is particularly useful in refactoring scenarios.\n\t * To update the developer-facing API, while maintaining backwards compatibility with existing SharedTree data,\n\t * you can change the property key and specify the previous property key as the stored key.\n\t *\n\t * Notes:\n\t *\n\t * - Stored keys have no impact on standard JavaScript behavior, on tree nodes. For example, `Object.keys`\n\t * will always return the property keys specified in the schema, ignoring any stored keys that differ from\n\t * the property keys.\n\t *\n\t * - When specifying stored keys in an object schema, you must ensure that the final set of stored keys\n\t * (accounting for those implicitly derived from property keys) contains no duplicates.\n\t * This is validated at runtime.\n\t *\n\t * @example Refactoring code without breaking compatibility with existing data\n\t *\n\t * Consider some existing object schema:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \txPosition: schemaFactory.number,\n\t * \tyPosition: schemaFactory.number,\n\t * \tzPosition: schemaFactory.optional(schemaFactory.number),\n\t * });\n\t * ```\n\t *\n\t * Developers using nodes of this type would access the the `xPosition` property as `point.xPosition`.\n\t *\n\t * We would like to refactor the schema to omit \"Position\" from the property keys, but application data has\n\t * already been persisted using the original property keys. To maintain compatibility with existing data,\n\t * we can refactor the schema as follows:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \tx: schemaFactory.required(schemaFactory.number, { key: \"xPosition\" }),\n\t * \ty: schemaFactory.required(schemaFactory.number, { key: \"yPosition\" }),\n\t * \tz: schemaFactory.optional(schemaFactory.number, { key: \"zPosition\" }),\n\t * });\n\t * ```\n\t *\n\t * Now, developers can access the `x` property as `point.x`, while existing data can still be collaborated on.\n\t *\n\t * @defaultValue If not specified, the key that is persisted is the property key that was specified in the schema.\n\t */\n\treadonly key?: string;\n\n\t/**\n\t * A default provider used for fields which were not provided any values.\n\t * @privateRemarks\n\t * We are using an erased type here, as we want to expose this API but `InsertableContent` and `NodeKeyManager` are not public.\n\t */\n\treadonly defaultProvider?: DefaultProvider;\n\n\t/**\n\t * Optional metadata to associate with the field.\n\t *\n\t * @remarks\n\t * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.\n\t * Different clients in the same collaborative session may see different metadata for the same field.\n\t */\n\treadonly metadata?: FieldSchemaMetadata<TCustomMetadata>;\n}\n\n/**\n * {@link FieldProps} extended with additional `alpha` options.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @alpha @input\n */\nexport interface FieldPropsAlpha<TCustomMetadata = unknown>\n\textends FieldProps<TCustomMetadata> {\n\t/**\n\t * The persisted metadata for this schema element.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * A {@link FieldProvider} which requires additional context in order to produce its content\n */\nexport type ContextualFieldProvider = (\n\tcontext: FlexTreeHydratedContextMinimal | \"UseGlobalContext\",\n) => UnhydratedFlexTreeNode[];\n/**\n * A {@link FieldProvider} which can produce its content in a vacuum.\n */\nexport type ConstantFieldProvider = () => UnhydratedFlexTreeNode[];\n/**\n * A function which produces content for a field every time that it is called.\n */\nexport type FieldProvider = ContextualFieldProvider | ConstantFieldProvider;\n/**\n * Returns true if the given {@link FieldProvider} is a {@link ConstantFieldProvider}\n */\nexport function isConstant(\n\tfieldProvider: FieldProvider,\n): fieldProvider is ConstantFieldProvider {\n\treturn fieldProvider.length === 0;\n}\n\n/**\n * Provides a default value for a field.\n * @remarks\n * If present in a `FieldSchema`, when constructing new tree content that field can be omitted, and a default will be provided.\n * @system @sealed @public\n */\nexport interface DefaultProvider extends ErasedType<\"@fluidframework/tree.FieldProvider\"> {}\n\nexport function extractFieldProvider(input: DefaultProvider): FieldProvider {\n\treturn input as unknown as FieldProvider;\n}\n\nexport function getDefaultProvider(input: FieldProvider): DefaultProvider {\n\treturn input as unknown as DefaultProvider;\n}\n\n/**\n * Metadata associated with a {@link FieldSchema}.\n *\n * @remarks Specified via {@link FieldProps.metadata}.\n *\n * @sealed\n * @public\n */\nexport interface FieldSchemaMetadata<TCustomMetadata = unknown> {\n\t/**\n\t * User-defined metadata.\n\t */\n\treadonly custom?: TCustomMetadata;\n\n\t/**\n\t * The description of the field.\n\t *\n\t * @remarks\n\t *\n\t * If provided, will be used by the system in scenarios where a description of the field is useful.\n\t * E.g., when converting a field schema to {@link https://json-schema.org/ | JSON Schema}, this description will be\n\t * used as the `description` field.\n\t */\n\treadonly description?: string | undefined;\n}\n\n/**\n * Metadata associated with a {@link FieldSchema}. Includes fields used by alpha features.\n *\n * @remarks Specified via {@link FieldProps.metadata}.\n *\n * @sealed\n * @alpha\n */\nexport interface FieldSchemaMetadataAlpha<TCustomMetadata = unknown>\n\textends FieldSchemaMetadata<TCustomMetadata> {\n\t/**\n\t * The persisted metadata for this schema element.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * Package internal construction API.\n */\nexport function createFieldSchema<\n\tKind extends FieldKind,\n\tTypes extends ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlpha<Kind, Types, TCustomMetadata>;\n\n/**\n * Package internal construction API that supports annotations for allowed types.\n */\nexport function createFieldSchema<\n\tKind extends FieldKind,\n\tTypes extends ImplicitAnnotatedAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;\n\nexport function createFieldSchema<\n\tKind extends FieldKind,\n\tTypes extends ImplicitAnnotatedAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata> {\n\treturn createFieldSchemaPrivate(kind, annotatedTypes, props);\n}\n\n/**\n * Implementation for {@link createFieldSchema}\n */\nlet createFieldSchemaPrivate: <\n\tKind extends FieldKind,\n\tTypes extends ImplicitAnnotatedAllowedTypes,\n\tTCustomMetadata,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n) => FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;\n\n/**\n * All policy for a specific field,\n * including functionality that does not have to be kept consistent across versions or deterministic.\n *\n * This can include policy for how to use this schema for \"view\" purposes, and well as how to expose editing APIs.\n * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link SchemaStatics.optional}.\n * @privateRemarks\n * Public access to the constructor is removed to prevent creating expressible but unsupported (or not stable) configurations.\n * {@link createFieldSchema} can be used internally to create instances.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @remarks\n * All implementations of this are actually {@link FieldSchemaAlpha} which exposes some additional alpha APIs.\n *\n * @sealed @public\n */\nexport class FieldSchema<\n\tout Kind extends FieldKind = FieldKind,\n\tout Types extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * This class is used with instanceof, and therefore should have nominal typing.\n\t * This field enforces that.\n\t */\n\tprotected _typeCheck!: MakeNominal;\n\n\tprivate readonly lazyTypes: Lazy<ReadonlySet<TreeNodeSchema>>;\n\n\t/**\n\t * What types of tree nodes are allowed in this field.\n\t * @remarks Counterpart to {@link FieldSchema.allowedTypes}, with any lazy definitions evaluated.\n\t */\n\tpublic get allowedTypeSet(): ReadonlySet<TreeNodeSchema> {\n\t\treturn this.lazyTypes.value;\n\t}\n\n\t/**\n\t * True if and only if, when constructing a node with this field, a value must be provided for it.\n\t */\n\tpublic readonly requiresValue: boolean;\n\n\t/**\n\t * {@inheritDoc FieldProps.metadata}\n\t */\n\tpublic get metadata(): FieldSchemaMetadata<TCustomMetadata> {\n\t\treturn this.props?.metadata ?? {};\n\t}\n\n\t/**\n\t * This class is `@sealed`: protected members like this constructor are for internal use only.\n\t * Use {@link SchemaFactory} to create the FieldSchema instances.\n\t */\n\tprotected constructor(\n\t\t/**\n\t\t * The {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind } of this field.\n\t\t * Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.\n\t\t */\n\t\tpublic readonly kind: Kind,\n\t\t/**\n\t\t * What types of tree nodes are allowed in this field.\n\t\t */\n\t\tpublic readonly allowedTypes: Types,\n\t\t/**\n\t\t * Optional properties associated with the field.\n\t\t */\n\t\tpublic readonly props?: FieldProps<TCustomMetadata>,\n\t) {\n\t\tif (!(this instanceof FieldSchemaAlpha)) {\n\t\t\tthrow new UsageError(\"FieldSchema is @sealed: sub-classing is not allowed.\");\n\t\t}\n\n\t\tthis.lazyTypes = new Lazy(() => normalizeAllowedTypes(this.allowedTypes));\n\t\t// TODO: optional fields should (by default) get a default provider that returns undefined, removing the need to special case them here:\n\t\tthis.requiresValue =\n\t\t\tthis.props?.defaultProvider === undefined && this.kind !== FieldKind.Optional;\n\t}\n}\n\n/**\n * {@link FieldSchema} including alpha APIs (currently {@link SimpleFieldSchema}).\n * @remarks\n * This class will go away once the alpha APIs are stable and implemented by {@link FieldSchema}.\n * @sealed @alpha\n */\nexport class FieldSchemaAlpha<\n\t\tKind extends FieldKind = FieldKind,\n\t\tTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchema<Kind, Types, TCustomMetadata>\n\timplements SimpleFieldSchema\n{\n\tprivate readonly lazyIdentifiers: Lazy<ReadonlySet<string>>;\n\tprivate readonly lazyAnnotatedTypes: Lazy<NormalizedAnnotatedAllowedTypes>;\n\tprivate readonly propsAlpha: FieldPropsAlpha<TCustomMetadata> | undefined;\n\n\t/**\n\t * Metadata on the types of tree nodes allowed on this field.\n\t */\n\tpublic readonly allowedTypesMetadata: AllowedTypesMetadata;\n\n\t/**\n\t * Persisted metadata for this field schema.\n\t */\n\tpublic get persistedMetadata(): JsonCompatibleReadOnlyObject | undefined {\n\t\treturn this.propsAlpha?.persistedMetadata;\n\t}\n\n\tstatic {\n\t\tcreateFieldSchemaPrivate = <\n\t\t\tKind2 extends FieldKind,\n\t\t\tTypes2 extends ImplicitAnnotatedAllowedTypes,\n\t\t\tTCustomMetadata2,\n\t\t>(\n\t\t\tkind: Kind2,\n\t\t\tannotatedAllowedTypes: Types2,\n\t\t\tprops?: FieldPropsAlpha<TCustomMetadata2>,\n\t\t) =>\n\t\t\tnew FieldSchemaAlpha(\n\t\t\t\tkind,\n\t\t\t\tunannotateImplicitAllowedTypes(annotatedAllowedTypes),\n\t\t\t\tannotatedAllowedTypes,\n\t\t\t\tprops,\n\t\t\t);\n\t}\n\n\tprotected constructor(\n\t\tkind: Kind,\n\t\ttypes: Types,\n\t\tpublic readonly annotatedAllowedTypes: ImplicitAnnotatedAllowedTypes,\n\t\tprops?: FieldPropsAlpha<TCustomMetadata>,\n\t) {\n\t\tsuper(kind, types, props);\n\n\t\tthis.allowedTypesMetadata = isAnnotatedAllowedTypes(annotatedAllowedTypes)\n\t\t\t? annotatedAllowedTypes.metadata\n\t\t\t: {};\n\t\tthis.lazyAnnotatedTypes = new Lazy(() =>\n\t\t\tnormalizeAnnotatedAllowedTypes(annotatedAllowedTypes),\n\t\t);\n\t\tthis.lazyIdentifiers = new Lazy(\n\t\t\t() =>\n\t\t\t\tnew Set(this.annotatedAllowedTypesNormalized.types.map(({ type }) => type.identifier)),\n\t\t);\n\t\tthis.propsAlpha = props;\n\t}\n\n\tpublic get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\treturn this.lazyIdentifiers.value;\n\t}\n\n\t/**\n\t * What types of tree nodes are allowed in this field and their annotations.\n\t * @remarks Counterpart to {@link FieldSchemaAlpha.annotatedAllowedTypes}, with any lazy definitions evaluated.\n\t */\n\tpublic get annotatedAllowedTypesNormalized(): NormalizedAnnotatedAllowedTypes {\n\t\treturn this.lazyAnnotatedTypes.value;\n\t}\n}\n\n/**\n * Normalizes a {@link ImplicitFieldSchema} or {@link ImplicitAnnotatedFieldSchema} to a {@link FieldSchema}.\n * @internal\n */\nexport function normalizeFieldSchema(\n\tschema: ImplicitFieldSchema | ImplicitAnnotatedFieldSchema,\n): FieldSchemaAlpha {\n\treturn schema instanceof FieldSchema\n\t\t? (schema as FieldSchemaAlpha)\n\t\t: createFieldSchema(FieldKind.Required, schema);\n}\n\n/**\n * Returns true if the given {@link ImplicitFieldSchema} are equivalent, otherwise false.\n * @remarks Two ImplicitFieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be (respectively) reference equal.\n *\n * For example, comparing an ImplicitFieldSchema that is a {@link TreeNodeSchema} to an ImplicitFieldSchema that is a {@link FieldSchema}\n * will return true if they are the same kind, the FieldSchema has exactly one allowed type (the TreeNodeSchema), and they have equivalent FieldProps.\n */\nexport function areImplicitFieldSchemaEqual(\n\ta: ImplicitFieldSchema,\n\tb: ImplicitFieldSchema,\n): boolean {\n\treturn areFieldSchemaEqual(normalizeFieldSchema(a), normalizeFieldSchema(b));\n}\n\n/**\n * Returns true if the given {@link FieldSchema} are equivalent, otherwise false.\n * @remarks Two FieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be reference equal.\n */\nexport function areFieldSchemaEqual(a: FieldSchema, b: FieldSchema): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.kind !== b.kind) {\n\t\treturn false;\n\t}\n\n\tif (!areFieldPropsEqual(a.props, b.props)) {\n\t\treturn false;\n\t}\n\n\treturn compareSets({ a: a.allowedTypeSet, b: b.allowedTypeSet });\n}\n\n/**\n * Returns true if the given {@link FieldProps} are equivalent, otherwise false.\n * @remarks FieldProps are considered equivalent if their keys and default providers are reference equal, and their metadata are {@link areMetadataEqual | equivalent}.\n */\nfunction areFieldPropsEqual(a: FieldProps | undefined, b: FieldProps | undefined): boolean {\n\t// If any new fields are added to FieldProps, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<areOnlyKeys<FieldProps, \"key\" | \"defaultProvider\" | \"metadata\">>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a?.key !== b?.key || a?.defaultProvider !== b?.defaultProvider) {\n\t\treturn false;\n\t}\n\n\tif (!areMetadataEqual(a?.metadata, b?.metadata)) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns true if the given {@link FieldSchemaMetadata} are equivalent, otherwise false.\n * @remarks FieldSchemaMetadata are considered equivalent if their custom data and descriptions are (respectively) reference equal.\n */\nfunction areMetadataEqual(\n\ta: FieldSchemaMetadataAlpha | undefined,\n\tb: FieldSchemaMetadataAlpha | undefined,\n): boolean {\n\t// If any new fields are added to FieldSchemaMetadata, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<\n\t\tareOnlyKeys<FieldSchemaMetadataAlpha, \"custom\" | \"description\" | \"persistedMetadata\">\n\t>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\treturn (\n\t\tObject.is(a?.custom, b?.custom) &&\n\t\ta?.description === b?.description &&\n\t\tarePersistedMetadataEqual(a?.persistedMetadata, b?.persistedMetadata)\n\t);\n}\n\n/**\n * Returns true if the given persisted metadata fields are equivalent, otherwise false.\n * @remarks\n * Currently only handles shallow equality in the case where the keys are in the same order. This is acceptable for current use cases.\n */\nfunction arePersistedMetadataEqual(\n\ta: JsonCompatibleReadOnlyObject | undefined,\n\tb: JsonCompatibleReadOnlyObject | undefined,\n): boolean {\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\tif (a === undefined || b === undefined) {\n\t\treturn false;\n\t}\n\n\t// Note that the key order matters. If `a` and `b` have the same content but the keys are in a different order,\n\t// this method will return false.\n\tconst aStringified = JSON.stringify(a);\n\tconst bStringified = JSON.stringify(b);\n\n\treturn aStringified === bStringified;\n}\n\n/**\n * Schema for a field of a tree node.\n * @remarks\n * Implicitly treats {@link ImplicitAllowedTypes} as a Required field of that type.\n * @public\n */\nexport type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;\n\n/**\n * {@link ImplicitFieldSchema} which supports {@link AnnotatedAllowedTypes | annotations} on the allowed types.\n * @alpha\n * @input\n */\nexport type ImplicitAnnotatedFieldSchema = FieldSchema | ImplicitAnnotatedAllowedTypes;\n\n/**\n * Removes annotations from an annotated field schema.\n * @system @alpha\n */\nexport type UnannotateImplicitFieldSchema<T extends ImplicitAnnotatedFieldSchema> =\n\tT extends ImplicitAnnotatedAllowedTypes ? UnannotateImplicitAllowedTypes<T> : T;\n\n/**\n * Converts an `ImplicitFieldSchema` to a property type suitable for reading a field with this that schema.\n *\n * @typeparam TSchema - When non-exact schema are provided this errors on the side of returning too general of a type (a conservative union of all possibilities).\n * This is ideal for \"output APIs\" - i.e. it converts the schema type to the runtime type that a user will _read_ from the tree.\n * Examples of such \"non-exact\" schema include `ImplicitFieldSchema`, `ImplicitAllowedTypes`, and TypeScript unions of schema types.\n * @public\n */\nexport type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> =\n\tTSchema extends FieldSchema<infer Kind, infer Types>\n\t\t? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind>\n\t\t: TSchema extends ImplicitAllowedTypes\n\t\t\t? TreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined;\n\n/**\n * Type of content that can be inserted into the tree for a field of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchemaInput - Schema to process.\n * @typeparam TSchema - Do not specify: default value used as implementation detail.\n * @public\n */\nexport type InsertableTreeFieldFromImplicitField<\n\tTSchemaInput extends ImplicitFieldSchema,\n\tTSchema = UnionToIntersection<TSchemaInput>,\n> = [TSchema] extends [FieldSchema<infer Kind, infer Types>]\n\t? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true>\n\t: [TSchema] extends [ImplicitAllowedTypes]\n\t\t? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t: never;\n\n/**\n * Content which could be inserted into a field within a tree.\n *\n * @see {@link Input}\n * @remarks\n * Extended version of {@link InsertableTreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * @alpha\n */\nexport type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? InsertableTreeFieldFromImplicitField<TSchema>\n\t: [TSchema] extends [UnsafeUnknownSchema]\n\t\t? InsertableContent | undefined\n\t\t: never;\n\n/**\n * Content which could be read from a field within a tree.\n *\n * @remarks\n * Extended version of {@link TreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * Since reading from fields with non-exact schema is still safe, this is only useful (compared to {@link TreeFieldFromImplicitField}) when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}\n * for use\n * @system @alpha\n */\nexport type ReadableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =\n\tTreeFieldFromImplicitField<ReadSchema<TSchema>>;\n\n/**\n * Adapter to remove {@link (UnsafeUnknownSchema:type)} from a schema type so it can be used with types for generating APIs for reading data.\n *\n * @remarks\n * Since reading with non-exact schema is still safe, this is mainly useful when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}.\n * @system @alpha\n */\nexport type ReadSchema<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? TSchema\n\t: ImplicitFieldSchema;\n\n/**\n * Suitable for output.\n * For input must error on side of excluding undefined instead.\n * @system @public\n */\nexport type ApplyKind<T, Kind extends FieldKind> = {\n\t[FieldKind.Required]: T;\n\t[FieldKind.Optional]: T | undefined;\n\t[FieldKind.Identifier]: T;\n}[Kind];\n\n/**\n * Suitable for input.\n *\n * @see {@link Input}\n * @system @public\n */\nexport type ApplyKindInput<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = [\n\tKind,\n] extends [FieldKind.Required]\n\t? T\n\t: [Kind] extends [FieldKind.Optional]\n\t\t? T | undefined\n\t\t: [Kind] extends [FieldKind.Identifier]\n\t\t\t? DefaultsAreOptional extends true\n\t\t\t\t? T | undefined\n\t\t\t\t: T\n\t\t\t: never;\n"]}
1
+ {"version":3,"file":"fieldSchema.js","sourceRoot":"","sources":["../../src/simple-tree/fieldS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WAAW;QACjC,yBAAyB,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,CAAC,CACrE,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,yBAAyB,CACjC,CAA2C,EAC3C,CAA2C;IAE3C,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,+GAA+G;IAC/G,iCAAiC;IACjC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEvC,OAAO,YAAY,KAAK,YAAY,CAAC;AACtC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { FieldKey } from \"../core/index.js\";\nimport type { FlexTreeHydratedContextMinimal } from \"../feature-libraries/index.js\";\nimport {\n\ttype MakeNominal,\n\tbrand,\n\ttype UnionToIntersection,\n\tcompareSets,\n\ttype requireTrue,\n\ttype areOnlyKeys,\n\ttype JsonCompatibleReadOnlyObject,\n} from \"../util/index.js\";\n\nimport type {\n\tTreeNodeSchema,\n\tTreeNode,\n\tUnhydratedFlexTreeNode,\n\tNormalizedAnnotatedAllowedTypes,\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tUnannotateImplicitAllowedTypes,\n\tAllowedTypesMetadata,\n\tTreeNodeFromImplicitAllowedTypes,\n\tTreeLeafValue,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n} from \"./core/index.js\";\nimport {\n\tisAnnotatedAllowedTypes,\n\tnormalizeAllowedTypes,\n\tnormalizeAnnotatedAllowedTypes,\n\tunannotateImplicitAllowedTypes,\n} from \"./core/index.js\";\n\nimport type { SimpleFieldSchema } from \"./simpleSchema.js\";\nimport type { UnsafeUnknownSchema } from \"./unsafeUnknownSchema.js\";\nimport type { InsertableContent } from \"./unhydratedFlexTreeFromInsertable.js\";\n\n/**\n * Kind of a field on an {@link TreeObjectNode}.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * See {@link FieldSchema} for where these are used, and {@link SchemaFactory} for how to create schema which use them.\n * @public\n */\nexport enum FieldKind {\n\t/**\n\t * A field which can be empty or filled.\n\t * @remarks\n\t * Allows 0 or one child.\n\t */\n\tOptional,\n\t/**\n\t * A field which must always be filled.\n\t * @remarks\n\t * Only allows exactly one child.\n\t */\n\tRequired,\n\t/**\n\t * A special readonly field used for node identifier strings.\n\t * @remarks\n\t * Only allows exactly one child.\n\t *\n\t * See {@link SchemaFactory.identifier} for more details.\n\t */\n\tIdentifier,\n}\n\n/**\n * Maps from a property key to its corresponding {@link FieldProps.key | stored key} for the provided\n * {@link ImplicitFieldSchema | field schema}.\n *\n * @remarks\n * If an explicit stored key was specified in the schema, it will be used.\n * Otherwise, the stored key is the same as the property key.\n */\nexport function getStoredKey(\n\tpropertyKey: string,\n\tfieldSchema: ImplicitAnnotatedFieldSchema,\n): FieldKey {\n\treturn brand(getExplicitStoredKey(fieldSchema) ?? propertyKey);\n}\n\n/**\n * Gets the {@link FieldProps.key | stored key} specified by the schema, if one was explicitly specified.\n * Otherwise, returns undefined.\n */\nexport function getExplicitStoredKey(\n\tfieldSchema: ImplicitAnnotatedFieldSchema,\n): string | undefined {\n\treturn fieldSchema instanceof FieldSchema ? fieldSchema.props?.key : undefined;\n}\n\n/**\n * Additional information to provide to a {@link FieldSchema}.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @public\n */\nexport interface FieldProps<TCustomMetadata = unknown> {\n\t/**\n\t * The unique identifier of a field, used in the persisted form of the tree.\n\t *\n\t * @remarks\n\t * If not explicitly set via the schema, this is the same as the schema's property key.\n\t *\n\t * Specifying a stored key that differs from the property key is particularly useful in refactoring scenarios.\n\t * To update the developer-facing API, while maintaining backwards compatibility with existing SharedTree data,\n\t * you can change the property key and specify the previous property key as the stored key.\n\t *\n\t * Notes:\n\t *\n\t * - Stored keys have no impact on standard JavaScript behavior, on tree nodes. For example, `Object.keys`\n\t * will always return the property keys specified in the schema, ignoring any stored keys that differ from\n\t * the property keys.\n\t *\n\t * - When specifying stored keys in an object schema, you must ensure that the final set of stored keys\n\t * (accounting for those implicitly derived from property keys) contains no duplicates.\n\t * This is validated at runtime.\n\t *\n\t * @example Refactoring code without breaking compatibility with existing data\n\t *\n\t * Consider some existing object schema:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \txPosition: schemaFactory.number,\n\t * \tyPosition: schemaFactory.number,\n\t * \tzPosition: schemaFactory.optional(schemaFactory.number),\n\t * });\n\t * ```\n\t *\n\t * Developers using nodes of this type would access the the `xPosition` property as `point.xPosition`.\n\t *\n\t * We would like to refactor the schema to omit \"Position\" from the property keys, but application data has\n\t * already been persisted using the original property keys. To maintain compatibility with existing data,\n\t * we can refactor the schema as follows:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \tx: schemaFactory.required(schemaFactory.number, { key: \"xPosition\" }),\n\t * \ty: schemaFactory.required(schemaFactory.number, { key: \"yPosition\" }),\n\t * \tz: schemaFactory.optional(schemaFactory.number, { key: \"zPosition\" }),\n\t * });\n\t * ```\n\t *\n\t * Now, developers can access the `x` property as `point.x`, while existing data can still be collaborated on.\n\t *\n\t * @defaultValue If not specified, the key that is persisted is the property key that was specified in the schema.\n\t */\n\treadonly key?: string;\n\n\t/**\n\t * A default provider used for fields which were not provided any values.\n\t * @privateRemarks\n\t * We are using an erased type here, as we want to expose this API but `InsertableContent` and `NodeKeyManager` are not public.\n\t */\n\treadonly defaultProvider?: DefaultProvider;\n\n\t/**\n\t * Optional metadata to associate with the field.\n\t *\n\t * @remarks\n\t * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.\n\t * Different clients in the same collaborative session may see different metadata for the same field.\n\t */\n\treadonly metadata?: FieldSchemaMetadata<TCustomMetadata>;\n}\n\n/**\n * {@link FieldProps} extended with additional `alpha` options.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @alpha @input\n */\nexport interface FieldPropsAlpha<TCustomMetadata = unknown>\n\textends FieldProps<TCustomMetadata> {\n\t/**\n\t * The persisted metadata for a field schema.\n\t * @remarks\n\t * Sets {@link SimpleFieldSchema.persistedMetadata}.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * A {@link FieldProvider} which requires additional context in order to produce its content\n */\nexport type ContextualFieldProvider = (\n\tcontext: FlexTreeHydratedContextMinimal | \"UseGlobalContext\",\n) => UnhydratedFlexTreeNode[];\n/**\n * A {@link FieldProvider} which can produce its content in a vacuum.\n */\nexport type ConstantFieldProvider = () => UnhydratedFlexTreeNode[];\n/**\n * A function which produces content for a field every time that it is called.\n */\nexport type FieldProvider = ContextualFieldProvider | ConstantFieldProvider;\n/**\n * Returns true if the given {@link FieldProvider} is a {@link ConstantFieldProvider}\n */\nexport function isConstant(\n\tfieldProvider: FieldProvider,\n): fieldProvider is ConstantFieldProvider {\n\treturn fieldProvider.length === 0;\n}\n\n/**\n * Provides a default value for a field.\n * @remarks\n * If present in a `FieldSchema`, when constructing new tree content that field can be omitted, and a default will be provided.\n * @system @sealed @public\n */\nexport interface DefaultProvider extends ErasedType<\"@fluidframework/tree.FieldProvider\"> {}\n\nexport function extractFieldProvider(input: DefaultProvider): FieldProvider {\n\treturn input as unknown as FieldProvider;\n}\n\nexport function getDefaultProvider(input: FieldProvider): DefaultProvider {\n\treturn input as unknown as DefaultProvider;\n}\n\n/**\n * Metadata associated with a {@link FieldSchema}.\n *\n * @remarks Specified via {@link FieldProps.metadata}.\n *\n * @sealed\n * @public\n */\nexport interface FieldSchemaMetadata<TCustomMetadata = unknown> {\n\t/**\n\t * User-defined metadata.\n\t */\n\treadonly custom?: TCustomMetadata;\n\n\t/**\n\t * The description of the field.\n\t *\n\t * @remarks\n\t *\n\t * If provided, will be used by the system in scenarios where a description of the field is useful.\n\t * E.g., when converting a field schema to {@link https://json-schema.org/ | JSON Schema}, this description will be\n\t * used as the `description` field.\n\t */\n\treadonly description?: string | undefined;\n}\n\n/**\n * Metadata associated with a {@link FieldSchema}. Includes fields used by alpha features.\n *\n * @remarks Specified via {@link FieldProps.metadata}.\n *\n * @sealed\n * @alpha\n */\nexport interface FieldSchemaMetadataAlpha<TCustomMetadata = unknown>\n\textends FieldSchemaMetadata<TCustomMetadata> {\n\t/**\n\t * The persisted metadata for this schema element.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * Package internal construction API.\n */\nexport function createFieldSchema<\n\tKind extends FieldKind,\n\tTypes extends ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlpha<Kind, Types, TCustomMetadata>;\n\n/**\n * Package internal construction API that supports annotations for allowed types.\n */\nexport function createFieldSchema<\n\tKind extends FieldKind,\n\tTypes extends ImplicitAnnotatedAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;\n\nexport function createFieldSchema<\n\tKind extends FieldKind,\n\tTypes extends ImplicitAnnotatedAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata> {\n\treturn createFieldSchemaPrivate(kind, annotatedTypes, props);\n}\n\n/**\n * Implementation for {@link createFieldSchema}\n */\nlet createFieldSchemaPrivate: <\n\tKind extends FieldKind,\n\tTypes extends ImplicitAnnotatedAllowedTypes,\n\tTCustomMetadata,\n>(\n\tkind: Kind,\n\tannotatedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n) => FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;\n\n/**\n * All policy for a specific field,\n * including functionality that does not have to be kept consistent across versions or deterministic.\n *\n * This can include policy for how to use this schema for \"view\" purposes, and well as how to expose editing APIs.\n * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link SchemaStatics.optional}.\n * @privateRemarks\n * Public access to the constructor is removed to prevent creating expressible but unsupported (or not stable) configurations.\n * {@link createFieldSchema} can be used internally to create instances.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @remarks\n * All implementations of this are actually {@link FieldSchemaAlpha} which exposes some additional alpha APIs.\n *\n * @sealed @public\n */\nexport class FieldSchema<\n\tout Kind extends FieldKind = FieldKind,\n\tout Types extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * This class is used with instanceof, and therefore should have nominal typing.\n\t * This field enforces that.\n\t */\n\tprotected _typeCheck!: MakeNominal;\n\n\tprivate readonly lazyTypes: Lazy<ReadonlySet<TreeNodeSchema>>;\n\n\t/**\n\t * What types of tree nodes are allowed in this field.\n\t * @remarks Counterpart to {@link FieldSchema.allowedTypes}, with any lazy definitions evaluated.\n\t */\n\tpublic get allowedTypeSet(): ReadonlySet<TreeNodeSchema> {\n\t\treturn this.lazyTypes.value;\n\t}\n\n\t/**\n\t * True if and only if, when constructing a node with this field, a value must be provided for it.\n\t */\n\tpublic readonly requiresValue: boolean;\n\n\t/**\n\t * {@inheritDoc FieldProps.metadata}\n\t */\n\tpublic get metadata(): FieldSchemaMetadata<TCustomMetadata> {\n\t\treturn this.props?.metadata ?? {};\n\t}\n\n\t/**\n\t * This class is `@sealed`: protected members like this constructor are for internal use only.\n\t * Use {@link SchemaFactory} to create the FieldSchema instances.\n\t */\n\tprotected constructor(\n\t\t/**\n\t\t * The {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind } of this field.\n\t\t * Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.\n\t\t */\n\t\tpublic readonly kind: Kind,\n\t\t/**\n\t\t * What types of tree nodes are allowed in this field.\n\t\t */\n\t\tpublic readonly allowedTypes: Types,\n\t\t/**\n\t\t * Optional properties associated with the field.\n\t\t */\n\t\tpublic readonly props?: FieldProps<TCustomMetadata>,\n\t) {\n\t\tif (!(this instanceof FieldSchemaAlpha)) {\n\t\t\tthrow new UsageError(\"FieldSchema is @sealed: sub-classing is not allowed.\");\n\t\t}\n\n\t\tthis.lazyTypes = new Lazy(() => normalizeAllowedTypes(this.allowedTypes));\n\t\t// TODO: optional fields should (by default) get a default provider that returns undefined, removing the need to special case them here:\n\t\tthis.requiresValue =\n\t\t\tthis.props?.defaultProvider === undefined && this.kind !== FieldKind.Optional;\n\t}\n}\n\n/**\n * {@link FieldSchema} including alpha APIs (currently {@link SimpleFieldSchema}).\n * @remarks\n * This class will go away once the alpha APIs are stable and implemented by {@link FieldSchema}.\n * @sealed @alpha\n */\nexport class FieldSchemaAlpha<\n\t\tKind extends FieldKind = FieldKind,\n\t\tTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchema<Kind, Types, TCustomMetadata>\n\timplements SimpleFieldSchema\n{\n\tprivate readonly lazyIdentifiers: Lazy<ReadonlySet<string>>;\n\tprivate readonly lazyAnnotatedTypes: Lazy<NormalizedAnnotatedAllowedTypes>;\n\tprivate readonly propsAlpha: FieldPropsAlpha<TCustomMetadata> | undefined;\n\n\t/**\n\t * Metadata on the types of tree nodes allowed on this field.\n\t */\n\tpublic readonly allowedTypesMetadata: AllowedTypesMetadata;\n\n\tpublic get persistedMetadata(): JsonCompatibleReadOnlyObject | undefined {\n\t\treturn this.propsAlpha?.persistedMetadata;\n\t}\n\n\tstatic {\n\t\tcreateFieldSchemaPrivate = <\n\t\t\tKind2 extends FieldKind,\n\t\t\tTypes2 extends ImplicitAnnotatedAllowedTypes,\n\t\t\tTCustomMetadata2,\n\t\t>(\n\t\t\tkind: Kind2,\n\t\t\tannotatedAllowedTypes: Types2,\n\t\t\tprops?: FieldPropsAlpha<TCustomMetadata2>,\n\t\t) =>\n\t\t\tnew FieldSchemaAlpha(\n\t\t\t\tkind,\n\t\t\t\tunannotateImplicitAllowedTypes(annotatedAllowedTypes),\n\t\t\t\tannotatedAllowedTypes,\n\t\t\t\tprops,\n\t\t\t);\n\t}\n\n\tprotected constructor(\n\t\tkind: Kind,\n\t\ttypes: Types,\n\t\tpublic readonly annotatedAllowedTypes: ImplicitAnnotatedAllowedTypes,\n\t\tprops?: FieldPropsAlpha<TCustomMetadata>,\n\t) {\n\t\tsuper(kind, types, props);\n\n\t\tthis.allowedTypesMetadata = isAnnotatedAllowedTypes(annotatedAllowedTypes)\n\t\t\t? annotatedAllowedTypes.metadata\n\t\t\t: {};\n\t\tthis.lazyAnnotatedTypes = new Lazy(() =>\n\t\t\tnormalizeAnnotatedAllowedTypes(annotatedAllowedTypes),\n\t\t);\n\t\tthis.lazyIdentifiers = new Lazy(\n\t\t\t() =>\n\t\t\t\tnew Set(this.annotatedAllowedTypesNormalized.types.map(({ type }) => type.identifier)),\n\t\t);\n\t\tthis.propsAlpha = props;\n\t}\n\n\tpublic get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\treturn this.lazyIdentifiers.value;\n\t}\n\n\t/**\n\t * What types of tree nodes are allowed in this field and their annotations.\n\t * @remarks Counterpart to {@link FieldSchemaAlpha.annotatedAllowedTypes}, with any lazy definitions evaluated.\n\t */\n\tpublic get annotatedAllowedTypesNormalized(): NormalizedAnnotatedAllowedTypes {\n\t\treturn this.lazyAnnotatedTypes.value;\n\t}\n}\n\n/**\n * Normalizes a {@link ImplicitFieldSchema} or {@link ImplicitAnnotatedFieldSchema} to a {@link FieldSchema}.\n * @internal\n */\nexport function normalizeFieldSchema(\n\tschema: ImplicitFieldSchema | ImplicitAnnotatedFieldSchema,\n): FieldSchemaAlpha {\n\treturn schema instanceof FieldSchema\n\t\t? (schema as FieldSchemaAlpha)\n\t\t: createFieldSchema(FieldKind.Required, schema);\n}\n\n/**\n * Returns true if the given {@link ImplicitFieldSchema} are equivalent, otherwise false.\n * @remarks Two ImplicitFieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be (respectively) reference equal.\n *\n * For example, comparing an ImplicitFieldSchema that is a {@link TreeNodeSchema} to an ImplicitFieldSchema that is a {@link FieldSchema}\n * will return true if they are the same kind, the FieldSchema has exactly one allowed type (the TreeNodeSchema), and they have equivalent FieldProps.\n */\nexport function areImplicitFieldSchemaEqual(\n\ta: ImplicitFieldSchema,\n\tb: ImplicitFieldSchema,\n): boolean {\n\treturn areFieldSchemaEqual(normalizeFieldSchema(a), normalizeFieldSchema(b));\n}\n\n/**\n * Returns true if the given {@link FieldSchema} are equivalent, otherwise false.\n * @remarks Two FieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be reference equal.\n */\nexport function areFieldSchemaEqual(a: FieldSchema, b: FieldSchema): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.kind !== b.kind) {\n\t\treturn false;\n\t}\n\n\tif (!areFieldPropsEqual(a.props, b.props)) {\n\t\treturn false;\n\t}\n\n\treturn compareSets({ a: a.allowedTypeSet, b: b.allowedTypeSet });\n}\n\n/**\n * Returns true if the given {@link FieldProps} are equivalent, otherwise false.\n * @remarks FieldProps are considered equivalent if their keys and default providers are reference equal, and their metadata are {@link areMetadataEqual | equivalent}.\n */\nfunction areFieldPropsEqual(a: FieldProps | undefined, b: FieldProps | undefined): boolean {\n\t// If any new fields are added to FieldProps, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<areOnlyKeys<FieldProps, \"key\" | \"defaultProvider\" | \"metadata\">>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a?.key !== b?.key || a?.defaultProvider !== b?.defaultProvider) {\n\t\treturn false;\n\t}\n\n\tif (!areMetadataEqual(a?.metadata, b?.metadata)) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns true if the given {@link FieldSchemaMetadata} are equivalent, otherwise false.\n * @remarks FieldSchemaMetadata are considered equivalent if their custom data and descriptions are (respectively) reference equal.\n */\nfunction areMetadataEqual(\n\ta: FieldSchemaMetadataAlpha | undefined,\n\tb: FieldSchemaMetadataAlpha | undefined,\n): boolean {\n\t// If any new fields are added to FieldSchemaMetadata, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<\n\t\tareOnlyKeys<FieldSchemaMetadataAlpha, \"custom\" | \"description\" | \"persistedMetadata\">\n\t>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\treturn (\n\t\tObject.is(a?.custom, b?.custom) &&\n\t\ta?.description === b?.description &&\n\t\tarePersistedMetadataEqual(a?.persistedMetadata, b?.persistedMetadata)\n\t);\n}\n\n/**\n * Returns true if the given persisted metadata fields are equivalent, otherwise false.\n * @remarks\n * Currently only handles shallow equality in the case where the keys are in the same order. This is acceptable for current use cases.\n */\nfunction arePersistedMetadataEqual(\n\ta: JsonCompatibleReadOnlyObject | undefined,\n\tb: JsonCompatibleReadOnlyObject | undefined,\n): boolean {\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\n\tif (a === undefined || b === undefined) {\n\t\treturn false;\n\t}\n\n\t// Note that the key order matters. If `a` and `b` have the same content but the keys are in a different order,\n\t// this method will return false.\n\tconst aStringified = JSON.stringify(a);\n\tconst bStringified = JSON.stringify(b);\n\n\treturn aStringified === bStringified;\n}\n\n/**\n * Schema for a field of a tree node.\n * @remarks\n * Implicitly treats {@link ImplicitAllowedTypes} as a Required field of that type.\n * @public\n */\nexport type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;\n\n/**\n * {@link ImplicitFieldSchema} which supports {@link AnnotatedAllowedTypes | annotations} on the allowed types.\n * @alpha\n * @input\n */\nexport type ImplicitAnnotatedFieldSchema = FieldSchema | ImplicitAnnotatedAllowedTypes;\n\n/**\n * Removes annotations from an annotated field schema.\n * @system @alpha\n */\nexport type UnannotateImplicitFieldSchema<T extends ImplicitAnnotatedFieldSchema> =\n\tT extends ImplicitAnnotatedAllowedTypes ? UnannotateImplicitAllowedTypes<T> : T;\n\n/**\n * Converts an `ImplicitFieldSchema` to a property type suitable for reading a field with this that schema.\n *\n * @typeparam TSchema - When non-exact schema are provided this errors on the side of returning too general of a type (a conservative union of all possibilities).\n * This is ideal for \"output APIs\" - i.e. it converts the schema type to the runtime type that a user will _read_ from the tree.\n * Examples of such \"non-exact\" schema include `ImplicitFieldSchema`, `ImplicitAllowedTypes`, and TypeScript unions of schema types.\n * @public\n */\nexport type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> =\n\tTSchema extends FieldSchema<infer Kind, infer Types>\n\t\t? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind>\n\t\t: TSchema extends ImplicitAllowedTypes\n\t\t\t? TreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined;\n\n/**\n * Type of content that can be inserted into the tree for a field of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchemaInput - Schema to process.\n * @typeparam TSchema - Do not specify: default value used as implementation detail.\n * @public\n */\nexport type InsertableTreeFieldFromImplicitField<\n\tTSchemaInput extends ImplicitFieldSchema,\n\tTSchema = UnionToIntersection<TSchemaInput>,\n> = [TSchema] extends [FieldSchema<infer Kind, infer Types>]\n\t? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true>\n\t: [TSchema] extends [ImplicitAllowedTypes]\n\t\t? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t: never;\n\n/**\n * Content which could be inserted into a field within a tree.\n *\n * @see {@link Input}\n * @remarks\n * Extended version of {@link InsertableTreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * @alpha\n */\nexport type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? InsertableTreeFieldFromImplicitField<TSchema>\n\t: [TSchema] extends [UnsafeUnknownSchema]\n\t\t? InsertableContent | undefined\n\t\t: never;\n\n/**\n * Content which could be read from a field within a tree.\n *\n * @remarks\n * Extended version of {@link TreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * Since reading from fields with non-exact schema is still safe, this is only useful (compared to {@link TreeFieldFromImplicitField}) when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}\n * for use\n * @system @alpha\n */\nexport type ReadableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =\n\tTreeFieldFromImplicitField<ReadSchema<TSchema>>;\n\n/**\n * Adapter to remove {@link (UnsafeUnknownSchema:type)} from a schema type so it can be used with types for generating APIs for reading data.\n *\n * @remarks\n * Since reading with non-exact schema is still safe, this is mainly useful when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}.\n * @system @alpha\n */\nexport type ReadSchema<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? TSchema\n\t: ImplicitFieldSchema;\n\n/**\n * Suitable for output.\n * For input must error on side of excluding undefined instead.\n * @system @public\n */\nexport type ApplyKind<T, Kind extends FieldKind> = {\n\t[FieldKind.Required]: T;\n\t[FieldKind.Optional]: T | undefined;\n\t[FieldKind.Identifier]: T;\n}[Kind];\n\n/**\n * Suitable for input.\n *\n * @see {@link Input}\n * @system @public\n */\nexport type ApplyKindInput<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = [\n\tKind,\n] extends [FieldKind.Required]\n\t? T\n\t: [Kind] extends [FieldKind.Optional]\n\t\t? T | undefined\n\t\t: [Kind] extends [FieldKind.Identifier]\n\t\t\t? DefaultsAreOptional extends true\n\t\t\t\t? T | undefined\n\t\t\t\t: T\n\t\t\t: never;\n"]}
@@ -5,7 +5,7 @@
5
5
  export { typeNameSymbol, typeSchemaSymbol, type WithType, type TreeNodeSchema, type AnnotatedAllowedType, type NormalizedAnnotatedAllowedTypes, NodeKind, type TreeNodeSchemaClass, type TreeNodeSchemaNonClass, type TreeNodeSchemaCore, TreeNode, type Unhydrated, type InternalTreeNode, isTreeNode, tryDisposeTreeNode, HydratedContext, SimpleContextSlot, getOrCreateInnerNode, getOrCreateNodeFromInnerNode, getOrCreateNodeFromInnerUnboxedNode, getKernel, type NodeFromSchema, isTreeNodeSchemaClass, type TreeNodeFromImplicitAllowedTypes, type InsertableTreeNodeFromImplicitAllowedTypes, type TreeLeafValue, type AllowedTypes, type InsertableTreeNodeFromAllowedTypes, type InsertableTypedNode, type NodeBuilderData, type Input, normalizeAllowedTypes, type NodeSchemaMetadata, type ImplicitAllowedTypes, type ImplicitAnnotatedAllowedTypes, type UnannotateImplicitAllowedTypes, type AllowedTypesMetadata, evaluateLazySchema, type UnannotateAllowedTypes, type UnannotateAllowedType, type UnannotateAllowedTypesList, type AllowedTypeMetadata, type AnnotatedAllowedTypes, type SchemaUpgrade, type LazyItem, type FlexList, type FlexListToUnion, type ExtractItemType, walkNodeSchema, walkAllowedTypes, type SchemaVisitor, type SimpleNodeSchemaBase, } from "./core/index.js";
6
6
  export { walkFieldSchema } from "./walkFieldSchema.js";
7
7
  export type { UnsafeUnknownSchema, Insertable } from "./unsafeUnknownSchema.js";
8
- export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, TreeViewConfigurationAlpha, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, SchemaFactory, SchemaFactoryAlpha, type SchemaFactoryObjectOptions, type ScopedSchemaName, type ValidateRecursiveSchema, type FixRecursiveArraySchema, adaptEnum, enumFromStrings, singletonSchema, treeNodeApi, type TreeNodeApi, type NodeChangedData, TreeBeta, type TreeChangeEventsBeta, type SimpleTreeIndex, type IdentifierIndex, createSimpleTreeIndex, createIdentifierIndex, type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, type JsonRecordNodeSchema, type JsonStringKeyPatternProperties, type TreeSchemaEncodingOptions, getJsonSchema, getSimpleSchema, type VerboseTreeNode, type TreeEncodingOptions, type VerboseTree, extractPersistedSchema, comparePersistedSchema, type ConciseTree, SchemaCompatibilityTester, type Unenforced, type System_Unsafe, type ArrayNodeCustomizableSchemaUnsafe, type MapNodeCustomizableSchemaUnsafe, type TreeRecordNodeUnsafe, type TreeViewAlpha, type TreeBranch, type TreeBranchEvents, getPropertyKeyFromStoredKey, getStoredKey, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, customFromCursorStored, type CustomTreeNode, type CustomTreeValue, tryStoredSchemaAsArray, type SchemaStatics, type ITreeAlpha, type TransactionConstraint, type NodeInDocumentConstraint, type RunTransactionParams, type VoidTransactionCallbackStatus, type TransactionCallbackStatus, type TransactionResult, type TransactionResultExt, type TransactionResultSuccess, type TransactionResultFailed, rollback, generateSchemaFromSimpleSchema, replaceConciseTreeHandles, replaceHandles, replaceVerboseTreeHandles, type HandleConverter, allowUnused, type FieldSchemaAlphaUnsafe, getIdentifierFromNode, type TreeSchema, type ValidateRecursiveSchemaTemplate, type FixRecursiveRecursionLimit, schemaStatics, type TreeChangeEvents, type NodeSchemaOptions, type NodeSchemaOptionsAlpha, type SchemaStaticsAlpha, } from "./api/index.js";
8
+ export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, TreeViewConfigurationAlpha, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, SchemaFactory, SchemaFactoryBeta, SchemaFactoryAlpha, type SchemaFactoryObjectOptions, type ScopedSchemaName, type ValidateRecursiveSchema, type FixRecursiveArraySchema, adaptEnum, enumFromStrings, singletonSchema, treeNodeApi, type TreeNodeApi, type NodeChangedData, TreeBeta, type TreeChangeEventsBeta, type SimpleTreeIndex, type IdentifierIndex, createSimpleTreeIndex, createIdentifierIndex, type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, type JsonRecordNodeSchema, type JsonStringKeyPatternProperties, type TreeSchemaEncodingOptions, getJsonSchema, getSimpleSchema, type VerboseTreeNode, type TreeEncodingOptions, type VerboseTree, extractPersistedSchema, comparePersistedSchema, type ConciseTree, SchemaCompatibilityTester, type Unenforced, type System_Unsafe, type ArrayNodeCustomizableSchemaUnsafe, type MapNodeCustomizableSchemaUnsafe, type TreeRecordNodeUnsafe, type TreeViewAlpha, type TreeBranch, type TreeBranchEvents, getPropertyKeyFromStoredKey, getStoredKey, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, customFromCursorStored, type CustomTreeNode, type CustomTreeValue, tryStoredSchemaAsArray, type SchemaStatics, type ITreeAlpha, type TransactionConstraint, type NodeInDocumentConstraint, type RunTransactionParams, type VoidTransactionCallbackStatus, type TransactionCallbackStatus, type TransactionResult, type TransactionResultExt, type TransactionResultSuccess, type TransactionResultFailed, rollback, generateSchemaFromSimpleSchema, replaceConciseTreeHandles, replaceHandles, replaceVerboseTreeHandles, type HandleConverter, allowUnused, type FieldSchemaAlphaUnsafe, getIdentifierFromNode, type TreeSchema, type ValidateRecursiveSchemaTemplate, type FixRecursiveRecursionLimit, schemaStatics, type TreeChangeEvents, type NodeSchemaOptions, type NodeSchemaOptionsAlpha, type SchemaStaticsAlpha, KeyEncodingOptions, type TreeParsingOptions, } from "./api/index.js";
9
9
  export type { SimpleTreeSchema, SimpleNodeSchema, SimpleFieldSchema, SimpleLeafNodeSchema, SimpleMapNodeSchema, SimpleArrayNodeSchema, SimpleObjectNodeSchema, SimpleNodeSchemaBaseAlpha, SimpleObjectFieldSchema, SimpleRecordNodeSchema, } from "./simpleSchema.js";
10
10
  export { type ImplicitFieldSchema, type ImplicitAnnotatedFieldSchema, type TreeFieldFromImplicitField, type UnannotateImplicitFieldSchema, FieldKind, FieldSchema, FieldSchemaAlpha, type InsertableTreeFieldFromImplicitField, type DefaultProvider, type FieldProps, type FieldPropsAlpha, normalizeFieldSchema, areFieldSchemaEqual, areImplicitFieldSchemaEqual, type ApplyKind, type FieldSchemaMetadata, type InsertableField, type ApplyKindInput, type ReadableField, type ReadSchema, } from "./fieldSchema.js";
11
11
  export { tryGetTreeNodeForField } from "./getTreeNodeForField.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,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AC3B,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,kBAAkB,EAClB,KAAK,yCAAyC,EAC9C,KAAK,cAAc,EACnB,QAAQ,EACR,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,sBAAsB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,gCAAgC,EAChC,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,mBAAmB,EACnB,8BAA8B,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,wCAAwC,EACxC,uCAAuC,GACvC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,GACV,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,+BAA+B,EACpC,QAAQ,EACR,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,mCAAmC,EACnC,SAAS,EACT,KAAK,cAAc,EACnB,qBAAqB,EACrB,KAAK,gCAAgC,EACrC,K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N,gCAAgC,EAChC,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,mBAAmB,EACnB,8BAA8B,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,wCAAwC,EACxC,uCAAuC,GACvC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,GACV,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export { typeNameSymbol, typeSchemaSymbol, NodeKind, TreeNode, isTreeNode, tryDisposeTreeNode, HydratedContext, SimpleContextSlot, getOrCreateInnerNode, getOrCreateNodeFromInnerNode, getOrCreateNodeFromInnerUnboxedNode, getKernel, isTreeNodeSchemaClass, normalizeAllowedTypes, evaluateLazySchema, walkNodeSchema, walkAllowedTypes, } from "./core/index.js";
6
6
  export { walkFieldSchema } from "./walkFieldSchema.js";
7
- export { TreeViewConfiguration, TreeViewConfigurationAlpha, SchemaFactory, SchemaFactoryAlpha, adaptEnum, enumFromStrings, singletonSchema, treeNodeApi, TreeBeta, createSimpleTreeIndex, createIdentifierIndex, getJsonSchema, getSimpleSchema, extractPersistedSchema, comparePersistedSchema, SchemaCompatibilityTester, getPropertyKeyFromStoredKey, getStoredKey, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, customFromCursorStored, tryStoredSchemaAsArray, rollback, generateSchemaFromSimpleSchema, replaceConciseTreeHandles, replaceHandles, replaceVerboseTreeHandles, allowUnused, getIdentifierFromNode, schemaStatics, } from "./api/index.js";
7
+ export { TreeViewConfiguration, TreeViewConfigurationAlpha, SchemaFactory, SchemaFactoryBeta, SchemaFactoryAlpha, adaptEnum, enumFromStrings, singletonSchema, treeNodeApi, TreeBeta, createSimpleTreeIndex, createIdentifierIndex, getJsonSchema, getSimpleSchema, extractPersistedSchema, comparePersistedSchema, SchemaCompatibilityTester, getPropertyKeyFromStoredKey, getStoredKey, tryGetSchema, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, conciseFromCursor, createFromCursor, asTreeViewAlpha, customFromCursorStored, tryStoredSchemaAsArray, rollback, generateSchemaFromSimpleSchema, replaceConciseTreeHandles, replaceHandles, replaceVerboseTreeHandles, allowUnused, getIdentifierFromNode, schemaStatics, KeyEncodingOptions, } from "./api/index.js";
8
8
  export { FieldKind, FieldSchema, FieldSchemaAlpha, normalizeFieldSchema, areFieldSchemaEqual, areImplicitFieldSchemaEqual, } from "./fieldSchema.js";
9
9
  export { tryGetTreeNodeForField } from "./getTreeNodeForField.js";
10
10
  export { ArrayNodeSchema, asIndex, isArrayNodeSchema, IterableTreeArrayContent, TreeArrayNode, MapNodeSchema, isMapNodeSchema, ObjectNodeSchema, isObjectNodeSchema, setField, isRecordNodeSchema, RecordNodeSchema, } from "./node-kinds/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAKhB,QAAQ,EAIR,QAAQ,EAGR,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,mCAAmC,EACnC,SAAS,EAET,qBAAqB,EASrB,qBAAqB,EAMrB,kBAAkB,EAWlB,cAAc,EACd,gBAAgB,GAGhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAKN,qBAAqB,EACrB,0BAA0B,EAI1B,aAAa,EACb,kBAAkB,EAK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ights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\ttype AnnotatedAllowedType,\n\ttype NormalizedAnnotatedAllowedTypes,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\tTreeNode,\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n\tisTreeNode,\n\ttryDisposeTreeNode,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tgetOrCreateInnerNode,\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n\tgetKernel,\n\ttype NodeFromSchema,\n\tisTreeNodeSchemaClass,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttype AllowedTypes,\n\ttype InsertableTreeNodeFromAllowedTypes,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype Input,\n\tnormalizeAllowedTypes,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitAnnotatedAllowedTypes,\n\ttype UnannotateImplicitAllowedTypes,\n\ttype AllowedTypesMetadata,\n\tevaluateLazySchema,\n\ttype UnannotateAllowedTypes,\n\ttype UnannotateAllowedType,\n\ttype UnannotateAllowedTypesList,\n\ttype AllowedTypeMetadata,\n\ttype AnnotatedAllowedTypes,\n\ttype SchemaUpgrade,\n\ttype LazyItem,\n\ttype FlexList,\n\ttype FlexListToUnion,\n\ttype ExtractItemType,\n\twalkNodeSchema,\n\twalkAllowedTypes,\n\ttype SchemaVisitor,\n\ttype SimpleNodeSchemaBase,\n} from \"./core/index.js\";\nexport { walkFieldSchema } from \"./walkFieldSchema.js\";\nexport type { UnsafeUnknownSchema, Insertable } from \"./unsafeUnknownSchema.js\";\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\tSchemaFactory,\n\tSchemaFactoryAlpha,\n\ttype SchemaFactoryObjectOptions,\n\ttype ScopedSchemaName,\n\ttype ValidateRecursiveSchema,\n\ttype FixRecursiveArraySchema,\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n\ttype SimpleTreeIndex,\n\ttype IdentifierIndex,\n\tcreateSimpleTreeIndex,\n\tcreateIdentifierIndex,\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\ttype JsonRecordNodeSchema,\n\ttype JsonStringKeyPatternProperties,\n\ttype TreeSchemaEncodingOptions,\n\tgetJsonSchema,\n\tgetSimpleSchema,\n\ttype VerboseTreeNode,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n\ttype ConciseTree,\n\tSchemaCompatibilityTester,\n\ttype Unenforced,\n\ttype System_Unsafe,\n\ttype ArrayNodeCustomizableSchemaUnsafe,\n\ttype MapNodeCustomizableSchemaUnsafe,\n\ttype TreeRecordNodeUnsafe,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\tgetPropertyKeyFromStoredKey,\n\tgetStoredKey,\n\ttryGetSchema,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\tconciseFromCursor,\n\tcreateFromCursor,\n\tasTreeViewAlpha,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\ttype SchemaStatics,\n\ttype ITreeAlpha,\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n\tgenerateSchemaFromSimpleSchema,\n\treplaceConciseTreeHandles,\n\treplaceHandles,\n\treplaceVerboseTreeHandles,\n\ttype HandleConverter,\n\tallowUnused,\n\ttype FieldSchemaAlphaUnsafe,\n\tgetIdentifierFromNode,\n\ttype TreeSchema,\n\ttype ValidateRecursiveSchemaTemplate,\n\ttype FixRecursiveRecursionLimit,\n\tschemaStatics,\n\ttype TreeChangeEvents,\n\ttype NodeSchemaOptions,\n\ttype NodeSchemaOptionsAlpha,\n\ttype SchemaStaticsAlpha,\n} from \"./api/index.js\";\nexport type {\n\tSimpleTreeSchema,\n\tSimpleNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleArrayNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleNodeSchemaBaseAlpha,\n\tSimpleObjectFieldSchema,\n\tSimpleRecordNodeSchema,\n} from \"./simpleSchema.js\";\nexport {\n\ttype ImplicitFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype UnannotateImplicitFieldSchema,\n\tFieldKind,\n\tFieldSchema,\n\tFieldSchemaAlpha,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\ttype FieldPropsAlpha,\n\tnormalizeFieldSchema,\n\tareFieldSchemaEqual,\n\tareImplicitFieldSchemaEqual,\n\ttype ApplyKind,\n\ttype FieldSchemaMetadata,\n\ttype InsertableField,\n\ttype ApplyKindInput,\n\ttype ReadableField,\n\ttype ReadSchema,\n} from \"./fieldSchema.js\";\nexport { tryGetTreeNodeForField } from \"./getTreeNodeForField.js\";\nexport {\n\ttype ArrayNodeCustomizableSchema,\n\ttype ArrayNodePojoEmulationSchema,\n\tArrayNodeSchema,\n\tasIndex,\n\tisArrayNodeSchema,\n\tIterableTreeArrayContent,\n\ttype ReadonlyArrayNode,\n\tTreeArrayNode,\n\ttype MapNodeCustomizableSchema,\n\ttype MapNodePojoEmulationSchema,\n\tMapNodeSchema,\n\tisMapNodeSchema,\n\ttype TreeMapNode,\n\ttype MapNodeInsertableData,\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\tObjectNodeSchema,\n\ttype ObjectNodeSchemaPrivate,\n\tisObjectNodeSchema,\n\ttype InsertableObjectFromAnnotatedSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n\tisRecordNodeSchema,\n\ttype RecordNodeCustomizableSchema,\n\ttype RecordNodeInsertableData,\n\ttype RecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\ttype TreeRecordNode,\n\ttype UnannotateSchemaRecord,\n} from \"./node-kinds/index.js\";\nexport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n} from \"./unhydratedFlexTreeFromInsertable.js\";\nexport {\n\tprepareForInsertion,\n\tprepareForInsertionContextless,\n} from \"./prepareForInsertion.js\";\nexport {\n\ttoStoredSchema,\n\tgetStoredSchema,\n\tconvertFieldKind,\n\ttoUpgradeSchema,\n\ttoInitialSchema,\n\tconvertField,\n\ttoUnhydratedSchema,\n\trestrictiveStoredSchemaGenerationOptions,\n\tpermissiveStoredSchemaGenerationOptions,\n} from \"./toStoredSchema.js\";\nexport {\n\tnumberSchema,\n\tstringSchema,\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n} from \"./leafNodeSchema.js\";\nexport type { LeafSchema } from \"./leafNodeSchema.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,cAAc,EACd,gBAAgB,EAKhB,QAAQ,EAIR,QAAQ,EAGR,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,mCAAmC,EACnC,SAAS,EAET,qBAAqB,EASrB,qBAAqB,EAMrB,kBAAkB,EAWlB,cAAc,EACd,gBAAgB,GAGhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAKN,qBAAqB,EACrB,0BAA0B,EAI1B,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAKlB,SAAS,EACT,eAAe,EACf,eAAe,EACf,WAAW,EAGX,QAAQ,EAIR,qBAAqB,EACrB,qBAAqB,EAiBrB,aAAa,EACb,eAAe,EAIf,sBAAsB,EACtB,sBAAsB,EAEtB,yBAAyB,EASzB,2BAA2B,EAC3B,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EAGtB,sBAAsB,EAYtB,QAAQ,EACR,8BAA8B,EAC9B,yBAAyB,EACzB,cAAc,EACd,yBAAyB,EAEzB,WAAW,EAEX,qBAAqB,EAIrB,aAAa,EAKb,kBAAkB,GAElB,MAAM,gBAAgB,CAAC;AAaxB,OAAO,EAKN,SAAS,EACT,WAAW,EACX,gBAAgB,EAKhB,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,GAO3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAGN,eAAe,EACf,OAAO,EACP,iBAAiB,EACjB,wBAAwB,EAExB,aAAa,EAGb,aAAa,EACb,eAAe,EAMf,gBAAgB,EAEhB,kBAAkB,EAGlB,QAAQ,EACR,kBAAkB,EAIlB,gBAAgB,GAGhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,gCAAgC,GAIhC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,mBAAmB,EACnB,8BAA8B,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,wCAAwC,EACxC,uCAAuC,GACvC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,UAAU,GACV,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype WithType,\n\ttype TreeNodeSchema,\n\ttype AnnotatedAllowedType,\n\ttype NormalizedAnnotatedAllowedTypes,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\tTreeNode,\n\ttype Unhydrated,\n\ttype InternalTreeNode,\n\tisTreeNode,\n\ttryDisposeTreeNode,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tgetOrCreateInnerNode,\n\tgetOrCreateNodeFromInnerNode,\n\tgetOrCreateNodeFromInnerUnboxedNode,\n\tgetKernel,\n\ttype NodeFromSchema,\n\tisTreeNodeSchemaClass,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttype AllowedTypes,\n\ttype InsertableTreeNodeFromAllowedTypes,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype Input,\n\tnormalizeAllowedTypes,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitAnnotatedAllowedTypes,\n\ttype UnannotateImplicitAllowedTypes,\n\ttype AllowedTypesMetadata,\n\tevaluateLazySchema,\n\ttype UnannotateAllowedTypes,\n\ttype UnannotateAllowedType,\n\ttype UnannotateAllowedTypesList,\n\ttype AllowedTypeMetadata,\n\ttype AnnotatedAllowedTypes,\n\ttype SchemaUpgrade,\n\ttype LazyItem,\n\ttype FlexList,\n\ttype FlexListToUnion,\n\ttype ExtractItemType,\n\twalkNodeSchema,\n\twalkAllowedTypes,\n\ttype SchemaVisitor,\n\ttype SimpleNodeSchemaBase,\n} from \"./core/index.js\";\nexport { walkFieldSchema } from \"./walkFieldSchema.js\";\nexport type { UnsafeUnknownSchema, Insertable } from \"./unsafeUnknownSchema.js\";\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\tSchemaFactory,\n\tSchemaFactoryBeta,\n\tSchemaFactoryAlpha,\n\ttype SchemaFactoryObjectOptions,\n\ttype ScopedSchemaName,\n\ttype ValidateRecursiveSchema,\n\ttype FixRecursiveArraySchema,\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttreeNodeApi,\n\ttype TreeNodeApi,\n\ttype NodeChangedData,\n\tTreeBeta,\n\ttype TreeChangeEventsBeta,\n\ttype SimpleTreeIndex,\n\ttype IdentifierIndex,\n\tcreateSimpleTreeIndex,\n\tcreateIdentifierIndex,\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n\ttype JsonRecordNodeSchema,\n\ttype JsonStringKeyPatternProperties,\n\ttype TreeSchemaEncodingOptions,\n\tgetJsonSchema,\n\tgetSimpleSchema,\n\ttype VerboseTreeNode,\n\ttype TreeEncodingOptions,\n\ttype VerboseTree,\n\textractPersistedSchema,\n\tcomparePersistedSchema,\n\ttype ConciseTree,\n\tSchemaCompatibilityTester,\n\ttype Unenforced,\n\ttype System_Unsafe,\n\ttype ArrayNodeCustomizableSchemaUnsafe,\n\ttype MapNodeCustomizableSchemaUnsafe,\n\ttype TreeRecordNodeUnsafe,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\tgetPropertyKeyFromStoredKey,\n\tgetStoredKey,\n\ttryGetSchema,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\tconciseFromCursor,\n\tcreateFromCursor,\n\tasTreeViewAlpha,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\ttype SchemaStatics,\n\ttype ITreeAlpha,\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n\tgenerateSchemaFromSimpleSchema,\n\treplaceConciseTreeHandles,\n\treplaceHandles,\n\treplaceVerboseTreeHandles,\n\ttype HandleConverter,\n\tallowUnused,\n\ttype FieldSchemaAlphaUnsafe,\n\tgetIdentifierFromNode,\n\ttype TreeSchema,\n\ttype ValidateRecursiveSchemaTemplate,\n\ttype FixRecursiveRecursionLimit,\n\tschemaStatics,\n\ttype TreeChangeEvents,\n\ttype NodeSchemaOptions,\n\ttype NodeSchemaOptionsAlpha,\n\ttype SchemaStaticsAlpha,\n\tKeyEncodingOptions,\n\ttype TreeParsingOptions,\n} from \"./api/index.js\";\nexport type {\n\tSimpleTreeSchema,\n\tSimpleNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleArrayNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleNodeSchemaBaseAlpha,\n\tSimpleObjectFieldSchema,\n\tSimpleRecordNodeSchema,\n} from \"./simpleSchema.js\";\nexport {\n\ttype ImplicitFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype UnannotateImplicitFieldSchema,\n\tFieldKind,\n\tFieldSchema,\n\tFieldSchemaAlpha,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\ttype FieldPropsAlpha,\n\tnormalizeFieldSchema,\n\tareFieldSchemaEqual,\n\tareImplicitFieldSchemaEqual,\n\ttype ApplyKind,\n\ttype FieldSchemaMetadata,\n\ttype InsertableField,\n\ttype ApplyKindInput,\n\ttype ReadableField,\n\ttype ReadSchema,\n} from \"./fieldSchema.js\";\nexport { tryGetTreeNodeForField } from \"./getTreeNodeForField.js\";\nexport {\n\ttype ArrayNodeCustomizableSchema,\n\ttype ArrayNodePojoEmulationSchema,\n\tArrayNodeSchema,\n\tasIndex,\n\tisArrayNodeSchema,\n\tIterableTreeArrayContent,\n\ttype ReadonlyArrayNode,\n\tTreeArrayNode,\n\ttype MapNodeCustomizableSchema,\n\ttype MapNodePojoEmulationSchema,\n\tMapNodeSchema,\n\tisMapNodeSchema,\n\ttype TreeMapNode,\n\ttype MapNodeInsertableData,\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\tObjectNodeSchema,\n\ttype ObjectNodeSchemaPrivate,\n\tisObjectNodeSchema,\n\ttype InsertableObjectFromAnnotatedSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n\tisRecordNodeSchema,\n\ttype RecordNodeCustomizableSchema,\n\ttype RecordNodeInsertableData,\n\ttype RecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\ttype TreeRecordNode,\n\ttype UnannotateSchemaRecord,\n} from \"./node-kinds/index.js\";\nexport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n} from \"./unhydratedFlexTreeFromInsertable.js\";\nexport {\n\tprepareForInsertion,\n\tprepareForInsertionContextless,\n} from \"./prepareForInsertion.js\";\nexport {\n\ttoStoredSchema,\n\tgetStoredSchema,\n\tconvertFieldKind,\n\ttoUpgradeSchema,\n\ttoInitialSchema,\n\tconvertField,\n\ttoUnhydratedSchema,\n\trestrictiveStoredSchemaGenerationOptions,\n\tpermissiveStoredSchemaGenerationOptions,\n} from \"./toStoredSchema.js\";\nexport {\n\tnumberSchema,\n\tstringSchema,\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n} from \"./leafNodeSchema.js\";\nexport type { LeafSchema } from \"./leafNodeSchema.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"recordNode.d.ts","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,4BAA4B,EAAS,MAAM,wBAAwB,CAAC;AAElF,OAAO,EAEN,QAAQ,EAQR,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EASlC,KAAK,yBAAyB,EAO9B,MAAM,qBAAqB,CAAC;AAS7B,OAAO,KAAK,EACX,4BAA4B,EAE5B,6BAA6B,EAG7B,MAAM,sBAAsB,CAAC;AA6J9B;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CACnC,KAAK,SAAS,MAAM,EACpB,aAAa,SAAS,6BAA6B,EACnD,wBAAwB,SA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;IAE3B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAE7B,QAAQ,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;IAE3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAExD;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;CACtE;AAED;;;;;GAKG;AAEH,wBAAgB,YAAY,CAC3B,KAAK,SAAS,MAAM,EACpB,KAAK,CAAC,aAAa,SAAS,6BAA6B,EACzD,KAAK,CAAC,wBAAwB,SAAS,OAAO,EAC9C,KAAK,CAAC,eAAe,GAAG,OAAO,EAE/B,OAAO,EAAE,mBAAmB,CAC3B,KAAK,EACL,aAAa,EACb,wBAAwB,EACxB,eAAe,CACf,kRA2KD"}
@@ -116,10 +116,9 @@ function createRecordNodeProxy(proxyTarget, customizable, schema) {
116
116
  }
117
117
  const innerNode = getOrCreateInnerNode(proxy);
118
118
  const field = innerNode.tryGetField(brand(key));
119
- if (field === undefined) {
120
- return false;
119
+ if (field !== undefined) {
120
+ field.editor.set(undefined, field.length === 0);
121
121
  }
122
- field.editor.set(undefined, field.length === 0);
123
122
  return true;
124
123
  },
125
124
  });
@@ -1 +1 @@
1
- {"version":3,"file":"recordNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAqC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElF,OAAO,EAEN,QAAQ;AACR,gDAAgD;AAChD,cAAc,EACd,gBAAgB,EAEhB,oBAAoB,EACpB,SAAS,EAMT,qBAAq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AM,cAAc,GAAmD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F,OAAO,2BAA2B,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type JsonCompatibleReadOnlyObject, brand } from \"../../../util/index.js\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\t// eslint-disable-next-line import/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype UnhydratedFlexTreeNode,\n\tgetOrCreateInnerNode,\n\tgetKernel,\n\ttype InternalTreeNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAnnotatedAllowedTypes,\n\ttype UnannotateImplicitAllowedTypes,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\tunannotateImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\ttype TreeNodeSchemaCorePrivate,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\tCompatibilityLevel,\n\ttype TreeNodeSchemaPrivateData,\n\tconvertAllowedTypes,\n} from \"../../core/index.js\";\nimport { getTreeNodeSchemaInitializedData } from \"../../createContext.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { createFieldSchema, FieldKind } from \"../../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype FactoryContent,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport type {\n\tRecordNodeCustomizableSchema,\n\tRecordNodeInsertableData,\n\tRecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\tTreeRecordNode,\n} from \"./recordNodeTypes.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n} from \"../../../feature-libraries/index.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport { recordLikeDataToFlexContent } from \"../common.js\";\nimport { MapNodeStoredSchema } from \"../../../core/index.js\";\n\n/**\n * Create a proxy which implements the {@link TreeRecordNode} API.\n * @param proxyTarget - Target object of the proxy.\n * @param customizable - See {@link RecordNodeSchemaOptions.customizable}.\n * @param schema - The schema of the record node.\n */\nfunction createRecordNodeProxy(\n\tproxyTarget: object,\n\tcustomizable: boolean,\n\tschema: RecordNodeSchema,\n): TreeRecordNode {\n\tconst proxy: TreeRecordNode = new Proxy<TreeRecordNode>(proxyTarget as TreeRecordNode, {\n\t\tget: (target, key, receiver): unknown => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\tswitch (key) {\n\t\t\t\t\t// POJO mode records don't have TreeNode's build in members on their targets, so special case them:\n\t\t\t\t\tcase typeSchemaSymbol: {\n\t\t\t\t\t\treturn schema;\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\tcase typeNameSymbol: {\n\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.iterator: {\n\t\t\t\t\t\treturn () => recordIterator(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toPrimitive: {\n\t\t\t\t\t\t// Handle string interpolation and coercion to string\n\t\t\t\t\t\treturn () => Object.prototype.toString.call(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toStringTag: {\n\t\t\t\t\t\t// In order to satisfy deep equality checks in POJO (non-customizable) mode,\n\t\t\t\t\t\t// we cannot override the behavior of this.\n\t\t\t\t\t\tif (customizable) {\n\t\t\t\t\t\t\t// Generates nicer toString behavior for customizable records.\n\t\t\t\t\t\t\t// E.g. `[object My.Record]` instead of `[object Object]`.\n\t\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\t// No-op\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof key === \"string\") {\n\t\t\t\tconst innerNode = getOrCreateInnerNode(receiver);\n\t\t\t\tconst field = innerNode.tryGetField(brand(key));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tset: (target, key, value: InsertableContent | undefined, receiver): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(receiver);\n\t\t\tconst field = innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;\n\t\t\tconst kernel = getKernel(receiver);\n\t\t\tconst innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));\n\t\t\tassert(\n\t\t\t\tinnerSchema instanceof MapNodeStoredSchema,\n\t\t\t\t0xc1a /* Expected MapNodeStoredSchema */,\n\t\t\t);\n\n\t\t\tconst mapTree = prepareForInsertion(\n\t\t\t\tvalue,\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),\n\t\t\t\tinnerNode.context,\n\t\t\t\tinnerSchema.mapFields,\n\t\t\t);\n\n\t\t\tfield.editor.set(mapTree, field.length === 0);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, key): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\tconst childField = innerNode.tryGetField(brand(key));\n\n\t\t\treturn childField !== undefined;\n\t\t},\n\t\townKeys: (target) => {\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\treturn [...innerNode.keys()];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, key) => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key));\n\n\t\t\tif (field === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tvalue: tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\t\t},\n\t\tdefineProperty(target, key, attributes) {\n\t\t\tthrow new UsageError(\"Shadowing properties of record nodes is not permitted.\");\n\t\t},\n\t\tdeleteProperty(target, key) {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key)) as FlexTreeOptionalField | undefined;\n\t\t\tif (field === undefined) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tfield.editor.set(undefined, field.length === 0);\n\t\t\treturn true;\n\t\t},\n\t});\n\treturn proxy;\n}\n\nabstract class CustomRecordNodeBase<\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n> extends TreeNodeValid<RecordNodeInsertableData<TAllowedTypes>> {\n\tpublic static readonly kind = NodeKind.Record;\n\n\tpublic constructor(\n\t\tinput?: InternalTreeNode | RecordNodeInsertableData<TAllowedTypes> | undefined,\n\t) {\n\t\tsuper(input ?? {});\n\t}\n}\n\n/**\n * {@link recordSchema} options.\n * @input\n */\nexport interface RecordSchemaOptions<\n\tTName extends string,\n\tTAllowedTypes extends ImplicitAnnotatedAllowedTypes,\n\tTImplicitlyConstructable extends boolean,\n\tTCustomMetadata = unknown,\n> {\n\t/**\n\t * Unique identifier for this schema within this factory's scope.\n\t */\n\treadonly identifier: TName;\n\n\treadonly customizable: boolean;\n\n\t/**\n\t * The kinds of nodes that are allowed as children of this record.\n\t */\n\treadonly info: TAllowedTypes;\n\n\treadonly implicitlyConstructable: TImplicitlyConstructable;\n\n\t/**\n\t * Optional ephemeral metadata for the object node schema.\n\t */\n\treadonly metadata?: NodeSchemaMetadata<TCustomMetadata>;\n\n\t/**\n\t * Optional persisted metadata for the object node schema.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeRecordNode}.\n *\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata -\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function recordSchema<\n\tTName extends string,\n\tconst TAllowedTypes extends ImplicitAnnotatedAllowedTypes,\n\tconst TImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\toptions: RecordSchemaOptions<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t>,\n) {\n\ttype TUnannotatedAllowedTypes = UnannotateImplicitAllowedTypes<TAllowedTypes>;\n\n\tconst {\n\t\tidentifier,\n\t\tinfo,\n\t\tcustomizable,\n\t\timplicitlyConstructable,\n\t\tmetadata,\n\t\tpersistedMetadata,\n\t} = options;\n\n\tconst lazyChildTypes = new Lazy(() =>\n\t\tnormalizeAllowedTypes(unannotateImplicitAllowedTypes(info)),\n\t);\n\tconst lazyAllowedTypesIdentifiers = new Lazy(\n\t\t() => new Set([...lazyChildTypes.value].map((type) => type.identifier)),\n\t);\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tclass Schema\n\t\textends CustomRecordNodeBase<TUnannotatedAllowedTypes>\n\t\timplements TreeRecordNode<TUnannotatedAllowedTypes>\n\t{\n\t\t/**\n\t\t * Record-like index signature for the node.\n\t\t */\n\t\t[key: string]: TreeNodeFromImplicitAllowedTypes<TUnannotatedAllowedTypes>;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.record(\"Foo\", schemaFactory.number);\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Record)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.record(\"Foo\", schemaFactory.number) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\treturn createRecordNodeProxy(\n\t\t\t\tproxyTarget,\n\t\t\t\tcustomizable,\n\t\t\t\tthis as unknown as RecordNodeSchema,\n\t\t\t) as unknown as Schema;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as typeof Schema);\n\t\t}\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== Schema.prototype) {\n\t\t\t\t\tfor (const key of Object.getOwnPropertyNames(prototype)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which could shadow a legal entry. Since child fields are exposed as own properties, shadowing properties of record nodes is not permitted.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomRecordNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomRecordNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst schema = this as RecordNodeSchema;\n\t\t\treturn getTreeNodeSchemaInitializedData(this, {\n\t\t\t\tshallowCompatibilityTest,\n\t\t\t\ttoFlexContent: (data: FactoryContent): FlexContent =>\n\t\t\t\t\trecordToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\t\treturn lazyAllowedTypesIdentifiers.value;\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: TImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> = metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tpersistedMetadata;\n\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn Schema.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic [Symbol.iterator](): IterableIterator<\n\t\t\t[string, TreeNodeFromImplicitAllowedTypes<TUnannotatedAllowedTypes>]\n\t\t> {\n\t\t\treturn recordIterator(this);\n\t\t}\n\t\tpublic get [Symbol.toStringTag](): string {\n\t\t\treturn identifier;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\t[info],\n\t\t\t\t(storedOptions) =>\n\t\t\t\t\tnew MapNodeStoredSchema(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\t\t\ttypes: convertAllowedTypes(info, storedOptions),\n\t\t\t\t\t\t\tpersistedMetadata,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpersistedMetadata,\n\t\t\t\t\t),\n\t\t\t));\n\t\t}\n\t}\n\n\ttype Output = RecordNodeCustomizableSchema<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t> &\n\t\tRecordNodePojoEmulationSchema<\n\t\t\tTName,\n\t\t\tTAllowedTypes,\n\t\t\tTImplicitlyConstructable,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\tTreeNodeSchemaCorePrivate;\n\n\tconst output: Output = Schema;\n\treturn output;\n}\n\nfunction* recordIterator<TAllowedTypes extends ImplicitAllowedTypes>(\n\trecord: TreeRecordNode<TAllowedTypes>,\n): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]> {\n\tfor (const [key, value] of Object.entries(record)) {\n\t\tyield [key, value];\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Record nodes.\n */\nfunction shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for Record nodes.\n *\n * Transforms data under a Record schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction recordToFlexContent(data: FactoryContent, schema: RecordNodeSchema): FlexContent {\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Record schema: ${data}`);\n\t}\n\n\tconst fieldsIterator: Iterable<readonly [string, InsertableContent]> = Object.entries(data);\n\treturn recordLikeDataToFlexContent(fieldsIterator, schema);\n}\n"]}
1
+ {"version":3,"file":"recordNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAqC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElF,OAAO,EAEN,QAAQ;AACR,gDAAgD;AAChD,cAAc,EACd,gBAAgB,EAEhB,oBAAoB,EACpB,SAAS,EAMT,qBAAqB,EACrB,8BAA8B,EAE9B,aAAa,EAIb,iBAAiB,EACjB,+BAA+B,EAE/B,kBAAkB,EAElB,mBAAmB,GACnB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AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type JsonCompatibleReadOnlyObject, brand } from \"../../../util/index.js\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\t// eslint-disable-next-line import/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype UnhydratedFlexTreeNode,\n\tgetOrCreateInnerNode,\n\tgetKernel,\n\ttype InternalTreeNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAnnotatedAllowedTypes,\n\ttype UnannotateImplicitAllowedTypes,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\tunannotateImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\ttype TreeNodeSchemaCorePrivate,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\tCompatibilityLevel,\n\ttype TreeNodeSchemaPrivateData,\n\tconvertAllowedTypes,\n} from \"../../core/index.js\";\nimport { getTreeNodeSchemaInitializedData } from \"../../createContext.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { createFieldSchema, FieldKind } from \"../../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype FactoryContent,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport type {\n\tRecordNodeCustomizableSchema,\n\tRecordNodeInsertableData,\n\tRecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\tTreeRecordNode,\n} from \"./recordNodeTypes.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n} from \"../../../feature-libraries/index.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport { recordLikeDataToFlexContent } from \"../common.js\";\nimport { MapNodeStoredSchema } from \"../../../core/index.js\";\n\n/**\n * Create a proxy which implements the {@link TreeRecordNode} API.\n * @param proxyTarget - Target object of the proxy.\n * @param customizable - See {@link RecordNodeSchemaOptions.customizable}.\n * @param schema - The schema of the record node.\n */\nfunction createRecordNodeProxy(\n\tproxyTarget: object,\n\tcustomizable: boolean,\n\tschema: RecordNodeSchema,\n): TreeRecordNode {\n\tconst proxy: TreeRecordNode = new Proxy<TreeRecordNode>(proxyTarget as TreeRecordNode, {\n\t\tget: (target, key, receiver): unknown => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\tswitch (key) {\n\t\t\t\t\t// POJO mode records don't have TreeNode's build in members on their targets, so special case them:\n\t\t\t\t\tcase typeSchemaSymbol: {\n\t\t\t\t\t\treturn schema;\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\tcase typeNameSymbol: {\n\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.iterator: {\n\t\t\t\t\t\treturn () => recordIterator(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toPrimitive: {\n\t\t\t\t\t\t// Handle string interpolation and coercion to string\n\t\t\t\t\t\treturn () => Object.prototype.toString.call(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toStringTag: {\n\t\t\t\t\t\t// In order to satisfy deep equality checks in POJO (non-customizable) mode,\n\t\t\t\t\t\t// we cannot override the behavior of this.\n\t\t\t\t\t\tif (customizable) {\n\t\t\t\t\t\t\t// Generates nicer toString behavior for customizable records.\n\t\t\t\t\t\t\t// E.g. `[object My.Record]` instead of `[object Object]`.\n\t\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\t// No-op\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof key === \"string\") {\n\t\t\t\tconst innerNode = getOrCreateInnerNode(receiver);\n\t\t\t\tconst field = innerNode.tryGetField(brand(key));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tset: (target, key, value: InsertableContent | undefined, receiver): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(receiver);\n\t\t\tconst field = innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;\n\t\t\tconst kernel = getKernel(receiver);\n\t\t\tconst innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));\n\t\t\tassert(\n\t\t\t\tinnerSchema instanceof MapNodeStoredSchema,\n\t\t\t\t0xc1a /* Expected MapNodeStoredSchema */,\n\t\t\t);\n\n\t\t\tconst mapTree = prepareForInsertion(\n\t\t\t\tvalue,\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),\n\t\t\t\tinnerNode.context,\n\t\t\t\tinnerSchema.mapFields,\n\t\t\t);\n\n\t\t\tfield.editor.set(mapTree, field.length === 0);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, key): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\tconst childField = innerNode.tryGetField(brand(key));\n\n\t\t\treturn childField !== undefined;\n\t\t},\n\t\townKeys: (target) => {\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\treturn [...innerNode.keys()];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, key) => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key));\n\n\t\t\tif (field === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tvalue: tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\t\t},\n\t\tdefineProperty(target, key, attributes) {\n\t\t\tthrow new UsageError(\"Shadowing properties of record nodes is not permitted.\");\n\t\t},\n\t\tdeleteProperty(target, key) {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getOrCreateInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key)) as FlexTreeOptionalField | undefined;\n\t\t\tif (field !== undefined) {\n\t\t\t\tfield.editor.set(undefined, field.length === 0);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n\treturn proxy;\n}\n\nabstract class CustomRecordNodeBase<\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n> extends TreeNodeValid<RecordNodeInsertableData<TAllowedTypes>> {\n\tpublic static readonly kind = NodeKind.Record;\n\n\tpublic constructor(\n\t\tinput?: InternalTreeNode | RecordNodeInsertableData<TAllowedTypes> | undefined,\n\t) {\n\t\tsuper(input ?? {});\n\t}\n}\n\n/**\n * {@link recordSchema} options.\n * @input\n */\nexport interface RecordSchemaOptions<\n\tTName extends string,\n\tTAllowedTypes extends ImplicitAnnotatedAllowedTypes,\n\tTImplicitlyConstructable extends boolean,\n\tTCustomMetadata = unknown,\n> {\n\t/**\n\t * Unique identifier for this schema within this factory's scope.\n\t */\n\treadonly identifier: TName;\n\n\treadonly customizable: boolean;\n\n\t/**\n\t * The kinds of nodes that are allowed as children of this record.\n\t */\n\treadonly info: TAllowedTypes;\n\n\treadonly implicitlyConstructable: TImplicitlyConstructable;\n\n\t/**\n\t * Optional ephemeral metadata for the object node schema.\n\t */\n\treadonly metadata?: NodeSchemaMetadata<TCustomMetadata>;\n\n\t/**\n\t * Optional persisted metadata for the object node schema.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeRecordNode}.\n *\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata -\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function recordSchema<\n\tTName extends string,\n\tconst TAllowedTypes extends ImplicitAnnotatedAllowedTypes,\n\tconst TImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\toptions: RecordSchemaOptions<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t>,\n) {\n\ttype TUnannotatedAllowedTypes = UnannotateImplicitAllowedTypes<TAllowedTypes>;\n\n\tconst {\n\t\tidentifier,\n\t\tinfo,\n\t\tcustomizable,\n\t\timplicitlyConstructable,\n\t\tmetadata,\n\t\tpersistedMetadata,\n\t} = options;\n\n\tconst lazyChildTypes = new Lazy(() =>\n\t\tnormalizeAllowedTypes(unannotateImplicitAllowedTypes(info)),\n\t);\n\tconst lazyAllowedTypesIdentifiers = new Lazy(\n\t\t() => new Set([...lazyChildTypes.value].map((type) => type.identifier)),\n\t);\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tclass Schema\n\t\textends CustomRecordNodeBase<TUnannotatedAllowedTypes>\n\t\timplements TreeRecordNode<TUnannotatedAllowedTypes>\n\t{\n\t\t/**\n\t\t * Record-like index signature for the node.\n\t\t */\n\t\t[key: string]: TreeNodeFromImplicitAllowedTypes<TUnannotatedAllowedTypes>;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.record(\"Foo\", schemaFactory.number);\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Record)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.record(\"Foo\", schemaFactory.number) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\treturn createRecordNodeProxy(\n\t\t\t\tproxyTarget,\n\t\t\t\tcustomizable,\n\t\t\t\tthis as unknown as RecordNodeSchema,\n\t\t\t) as unknown as Schema;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as typeof Schema);\n\t\t}\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== Schema.prototype) {\n\t\t\t\t\tfor (const key of Object.getOwnPropertyNames(prototype)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which could shadow a legal entry. Since child fields are exposed as own properties, shadowing properties of record nodes is not permitted.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomRecordNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomRecordNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst schema = this as RecordNodeSchema;\n\t\t\treturn getTreeNodeSchemaInitializedData(this, {\n\t\t\t\tshallowCompatibilityTest,\n\t\t\t\ttoFlexContent: (data: FactoryContent): FlexContent =>\n\t\t\t\t\trecordToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\t\treturn lazyAllowedTypesIdentifiers.value;\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: TImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> = metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tpersistedMetadata;\n\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn Schema.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic [Symbol.iterator](): IterableIterator<\n\t\t\t[string, TreeNodeFromImplicitAllowedTypes<TUnannotatedAllowedTypes>]\n\t\t> {\n\t\t\treturn recordIterator(this);\n\t\t}\n\t\tpublic get [Symbol.toStringTag](): string {\n\t\t\treturn identifier;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\t[info],\n\t\t\t\t(storedOptions) =>\n\t\t\t\t\tnew MapNodeStoredSchema(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\t\t\ttypes: convertAllowedTypes(info, storedOptions),\n\t\t\t\t\t\t\tpersistedMetadata,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpersistedMetadata,\n\t\t\t\t\t),\n\t\t\t));\n\t\t}\n\t}\n\n\ttype Output = RecordNodeCustomizableSchema<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t> &\n\t\tRecordNodePojoEmulationSchema<\n\t\t\tTName,\n\t\t\tTAllowedTypes,\n\t\t\tTImplicitlyConstructable,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\tTreeNodeSchemaCorePrivate;\n\n\tconst output: Output = Schema;\n\treturn output;\n}\n\nfunction* recordIterator<TAllowedTypes extends ImplicitAllowedTypes>(\n\trecord: TreeRecordNode<TAllowedTypes>,\n): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]> {\n\tfor (const [key, value] of Object.entries(record)) {\n\t\tyield [key, value];\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Record nodes.\n */\nfunction shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for Record nodes.\n *\n * Transforms data under a Record schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction recordToFlexContent(data: FactoryContent, schema: RecordNodeSchema): FlexContent {\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Record schema: ${data}`);\n\t}\n\n\tconst fieldsIterator: Iterable<readonly [string, InsertableContent]> = Object.entries(data);\n\treturn recordLikeDataToFlexContent(fieldsIterator, schema);\n}\n"]}
@@ -16,6 +16,15 @@ import type { FieldKind, FieldSchemaMetadata } from "./fieldSchema.js";
16
16
  export interface SimpleNodeSchemaBaseAlpha<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<TNodeKind, TCustomMetadata> {
17
17
  /**
18
18
  * Persisted metadata for this node schema.
19
+ * @remarks
20
+ * While this can be stored in the document, not all versions / configurations will do so.
21
+ * Additionally, this is not part of {@link TreeView.compatibility|schema compatibility}, so different clients
22
+ * (even within the same collaborative session) may see different `persistedMetadata` for the same node.
23
+ * Specified using {@link NodeSchemaOptionsAlpha.persistedMetadata}.
24
+ * @privateRemarks
25
+ * How/when this gets updated in documents,
26
+ * and how to read it from documents should be documented here when this feature is more mature and these questions have good answers.
27
+ * If this does end up getting reflected in some compatibility value, that should also be documented.
19
28
  */
20
29
  readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;
21
30
  }
@@ -154,6 +163,9 @@ export interface SimpleFieldSchema {
154
163
  readonly metadata: FieldSchemaMetadata;
155
164
  /**
156
165
  * Persisted metadata for this field schema.
166
+ * @remarks
167
+ * Like {@link SimpleNodeSchemaBaseAlpha.persistedMetadata} but for fields.
168
+ * Set via {@link FieldPropsAlpha.persistedMetadata}.
157
169
  */
158
170
  readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
159
171
  }
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAOvE;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB,CACzC,GAAG,CAAC,SAAS,SAAS,QAAQ,EAC9B,GAAG,CAAC,eAAe,GAAG,OAAO,CAC5B,SAAQ,oBAAoB,CAAC,SAAS,EAAE,eAAe,CAAC;IACzD;;OAEG;IACH,QAAQ,CAAC,iBAAiB,EAAE,4BAA4B,GAAG,SAAS,CAAC;CACrE;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CACpE,SAAQ,yBAAyB,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACnE;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CAC9D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IACjE;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED;;;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;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;CACtE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAEjC;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchema.js","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ValueSchema } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnlyObject } from \"../util/index.js\";\nimport type { NodeKind, SimpleNodeSchemaBase } from \"./core/index.js\";\nimport type { FieldKind, FieldSchemaMetadata } from \"./fieldSchema.js\";\n\n/*\n * TODO:\n * - Customize their JSON serialization to use these formats or provide some other serialization scheme.\n */\n\n/**\n * A {@link SimpleNodeSchema} containing fields for alpha features.\n *\n * @system\n * @alpha\n * @sealed\n */\nexport interface SimpleNodeSchemaBaseAlpha<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> extends SimpleNodeSchemaBase<TNodeKind, TCustomMetadata> {\n\t/**\n\t * Persisted metadata for this node schema.\n\t */\n\treadonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an object node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Object, TCustomMetadata> {\n\t/**\n\t * Schemas for each of the object's fields, keyed off of schema's keys.\n\t * @remarks\n\t * The keys are the property keys if known, otherwise they are the stored keys.\n\t * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.\n\t * @privateRemarks\n\t * TODO: Provide and link a way to translate from stored keys to the property keys.\n\t * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,\n\t * especially if/when TreeNodeSchema for objects provide more maps.\n\t */\n\treadonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;\n}\n\n/**\n * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.\n * @remarks\n * The only other case fields are uses in the root schema.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectFieldSchema extends SimpleFieldSchema {\n\t/**\n\t * The stored key of the field.\n\t * @remarks\n\t * See {@link FieldProps.key} for more information.\n\t */\n\treadonly storedKey: string;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an array node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleArrayNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Array, TCustomMetadata> {\n\t/**\n\t * The types allowed in the array.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a map node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleMapNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Map, TCustomMetadata> {\n\t/**\n\t * The types allowed as values in the map.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a map node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleRecordNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Record, TCustomMetadata> {\n\t/**\n\t * The types allowed as values in the record.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a leaf node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleLeafNodeSchema extends SimpleNodeSchemaBaseAlpha<NodeKind.Leaf> {\n\t/**\n\t * The kind of leaf node.\n\t */\n\treadonly leafKind: ValueSchema;\n}\n\n/**\n * A simple, shallow representation of a schema for a node.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,\n * and therefore code should not assume that switching over all these cases can be done exhaustively.\n * @privateRemarks\n * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?\n *\n * @alpha\n */\nexport type SimpleNodeSchema =\n\t| SimpleLeafNodeSchema\n\t| SimpleMapNodeSchema\n\t| SimpleArrayNodeSchema\n\t| SimpleObjectNodeSchema\n\t| SimpleRecordNodeSchema;\n\n/**\n * A simple, shallow representation of a schema for a field.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleFieldSchema {\n\t/**\n\t * The kind of tree field.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the field.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * {@inheritDoc FieldSchemaMetadata}\n\t */\n\treadonly metadata: FieldSchemaMetadata;\n\n\t/**\n\t * Persisted metadata for this field schema.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * A simplified representation of a schema for a tree.\n *\n * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,\n * which are represented inline with identifiers.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleTreeSchema {\n\t/**\n\t * The tree field representing the root of the tree.\n\t */\n\treadonly root: SimpleFieldSchema;\n\n\t/**\n\t * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.root}.\n\t *\n\t * @remarks\n\t * The keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\n\t *\n\t * Information about if a schema is {@link SchemaStaticsAlpha.staged | staged} or not is not available as the \"Simple Schema\" layer of abstraction: they are included unconditionally.\n\t * Options for filtering out staged schemas from view schema are available in {@link extractPersistedSchema}.\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema>;\n}\n"]}
1
+ {"version":3,"file":"simpleSchema.js","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ValueSchema } from \"../core/index.js\";\nimport type { JsonCompatibleReadOnlyObject } from \"../util/index.js\";\nimport type { NodeKind, SimpleNodeSchemaBase } from \"./core/index.js\";\nimport type { FieldKind, FieldSchemaMetadata } from \"./fieldSchema.js\";\n\n/*\n * TODO:\n * - Customize their JSON serialization to use these formats or provide some other serialization scheme.\n */\n\n/**\n * A {@link SimpleNodeSchema} containing fields for alpha features.\n *\n * @system\n * @alpha\n * @sealed\n */\nexport interface SimpleNodeSchemaBaseAlpha<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> extends SimpleNodeSchemaBase<TNodeKind, TCustomMetadata> {\n\t/**\n\t * Persisted metadata for this node schema.\n\t * @remarks\n\t * While this can be stored in the document, not all versions / configurations will do so.\n\t * Additionally, this is not part of {@link TreeView.compatibility|schema compatibility}, so different clients\n\t * (even within the same collaborative session) may see different `persistedMetadata` for the same node.\n\t * Specified using {@link NodeSchemaOptionsAlpha.persistedMetadata}.\n\t * @privateRemarks\n\t * How/when this gets updated in documents,\n\t * and how to read it from documents should be documented here when this feature is more mature and these questions have good answers.\n\t * If this does end up getting reflected in some compatibility value, that should also be documented.\n\t */\n\treadonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an object node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Object, TCustomMetadata> {\n\t/**\n\t * Schemas for each of the object's fields, keyed off of schema's keys.\n\t * @remarks\n\t * The keys are the property keys if known, otherwise they are the stored keys.\n\t * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.\n\t * @privateRemarks\n\t * TODO: Provide and link a way to translate from stored keys to the property keys.\n\t * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,\n\t * especially if/when TreeNodeSchema for objects provide more maps.\n\t */\n\treadonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;\n}\n\n/**\n * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.\n * @remarks\n * The only other case fields are uses in the root schema.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectFieldSchema extends SimpleFieldSchema {\n\t/**\n\t * The stored key of the field.\n\t * @remarks\n\t * See {@link FieldProps.key} for more information.\n\t */\n\treadonly storedKey: string;\n}\n\n/**\n * A {@link SimpleNodeSchema} for an array node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleArrayNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Array, TCustomMetadata> {\n\t/**\n\t * The types allowed in the array.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a map node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleMapNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Map, TCustomMetadata> {\n\t/**\n\t * The types allowed as values in the map.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a map node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleRecordNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBaseAlpha<NodeKind.Record, TCustomMetadata> {\n\t/**\n\t * The types allowed as values in the record.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n}\n\n/**\n * A {@link SimpleNodeSchema} for a leaf node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleLeafNodeSchema extends SimpleNodeSchemaBaseAlpha<NodeKind.Leaf> {\n\t/**\n\t * The kind of leaf node.\n\t */\n\treadonly leafKind: ValueSchema;\n}\n\n/**\n * A simple, shallow representation of a schema for a node.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,\n * and therefore code should not assume that switching over all these cases can be done exhaustively.\n * @privateRemarks\n * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?\n *\n * @alpha\n */\nexport type SimpleNodeSchema =\n\t| SimpleLeafNodeSchema\n\t| SimpleMapNodeSchema\n\t| SimpleArrayNodeSchema\n\t| SimpleObjectNodeSchema\n\t| SimpleRecordNodeSchema;\n\n/**\n * A simple, shallow representation of a schema for a field.\n *\n * @remarks This definition is incomplete, and references child types by identifiers.\n * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which\n * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleFieldSchema {\n\t/**\n\t * The kind of tree field.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the field.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * {@inheritDoc FieldSchemaMetadata}\n\t */\n\treadonly metadata: FieldSchemaMetadata;\n\n\t/**\n\t * Persisted metadata for this field schema.\n\t * @remarks\n\t * Like {@link SimpleNodeSchemaBaseAlpha.persistedMetadata} but for fields.\n\t * Set via {@link FieldPropsAlpha.persistedMetadata}.\n\t */\n\treadonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;\n}\n\n/**\n * A simplified representation of a schema for a tree.\n *\n * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,\n * which are represented inline with identifiers.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleTreeSchema {\n\t/**\n\t * The tree field representing the root of the tree.\n\t */\n\treadonly root: SimpleFieldSchema;\n\n\t/**\n\t * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.root}.\n\t *\n\t * @remarks\n\t * The keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\n\t *\n\t * Information about if a schema is {@link SchemaStaticsAlpha.staged | staged} or not is not available as the \"Simple Schema\" layer of abstraction: they are included unconditionally.\n\t * Options for filtering out staged schemas from view schema are available in {@link extractPersistedSchema}.\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema>;\n}\n"]}
@@ -51,9 +51,6 @@ export declare const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind>;
51
51
  * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.
52
52
  * @privateRemarks
53
53
  * TODO: Persist node metadata once schema FormatV2 is supported.
54
- *
55
- * TODO: AB#43548: Using a stored schema for unhydrated flex trees does not handle schema evolution features like "allowUnknownOptionalFields".
56
- * Usage of this and the conversion which wrap it should be audited and reduced.
57
54
  */
58
55
  export declare function getStoredSchema(schema: SimpleNodeSchema, options: StoredSchemaGenerationOptions): TreeNodeStoredSchema;
59
56
  export declare function arrayNodeStoredSchema(types: TreeTypeSet, persistedMetadata: JsonCompatibleReadOnlyObject | undefined): ObjectNodeStoredSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAIN,sBAAsB,EAGtB,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAsB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAON,KAAK,6BAA6B,EAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,SAAS,EACT,gBAAgB,EAEhB,KAAK,4BAA4B,EAEjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ7E,eAAO,MAAM,wCAAwC,EAAE,6BAEtD,CAAC;AAEF,eAAO,MAAM,uCAAuC,EAAE,6BAErD,CAA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KAAK,4BAA4B,EAEjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ7E,eAAO,MAAM,wCAAwC,EAAE,6BAEtD,CAAC;AAEF,eAAO,MAAM,uCAAuC,EAAE,6BAErD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,4BAA4B,GAAG,gBAAgB,CAEpF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,4BAA4B,GAAG,gBAAgB,CAEpF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,+BAA0C,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,4BAA4B,EAClC,OAAO,EAAE,6BAA6B,GACpC,gBAAgB,CAgClB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,iBAAiB,GAAG,gBAAgB,EAC5C,OAAO,EAAE,6BAA6B,GACpC,qBAAqB,CAWvB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,SAAS,EAAE,aAAa,CAOjE,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,6BAA6B,GACpC,oBAAoB,CAqCtB;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,WAAW,EAClB,iBAAiB,EAAE,4BAA4B,GAAG,SAAS,GACzD,sBAAsB,CAQxB"}
@@ -98,9 +98,6 @@ export const convertFieldKind = new Map([
98
98
  * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.
99
99
  * @privateRemarks
100
100
  * TODO: Persist node metadata once schema FormatV2 is supported.
101
- *
102
- * TODO: AB#43548: Using a stored schema for unhydrated flex trees does not handle schema evolution features like "allowUnknownOptionalFields".
103
- * Usage of this and the conversion which wrap it should be audited and reduced.
104
101
  */
105
102
  export function getStoredSchema(schema, options) {
106
103
  if (isClassBasedSchema(schema)) {
@@ -1 +1 @@
1
- {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GAQtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAsB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqC,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,QAAQ,GAGR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GAGpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAGlC,CAAC;AAEJ,MAAM,CAAC,MAAM,wCAAwC,GAAkC;IACtF,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,uCAAuC,GAAkC;IACrF,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAkC;IACjE,OAAO,cAAc,CAAC,IAAI,EAAE,wCAAwC,CAAC,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAkC;IACjE,OAAO,cAAc,CAAC,IAAI,EAAE,wCAAwC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;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*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, getOrCreate, type JsonCompatibleReadOnlyObject } from \"../util/index.js\";\n\nimport {\n\tallowedTypeFilter,\n\tconvertAllowedTypes,\n\tgetTreeNodeSchemaPrivateData,\n\tisClassBasedSchema,\n\tNodeKind,\n\ttype SimpleNodeSchemaBase,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\ttype ImplicitFieldSchema,\n} from \"./fieldSchema.js\";\nimport type { SimpleFieldSchema, SimpleNodeSchema } from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<\n\tStoredSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\nexport const restrictiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => false,\n};\n\nexport const permissiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitAnnotatedFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitAnnotatedFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitAnnotatedFieldSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst normalized = normalizeFieldSchema(root);\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(normalized, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(\n\t\t\t\t\tbrand(schema.identifier),\n\t\t\t\t\tgetStoredSchema(\n\t\t\t\t\t\tschema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t\tallowedTypeFilter: (allowedType) => allowedTypeFilter(allowedType, options),\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized, options),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema | FieldSchemaAlpha,\n\toptions: StoredSchemaGenerationOptions,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tlet types: TreeTypeSet;\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (schema instanceof FieldSchemaAlpha) {\n\t\ttypes = convertAllowedTypes(schema.annotatedAllowedTypesNormalized, options);\n\t} else {\n\t\ttypes = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t}\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n *\n * TODO: AB#43548: Using a stored schema for unhydrated flex trees does not handle schema evolution features like \"allowUnknownOptionalFields\".\n * Usage of this and the conversion which wrap it should be audited and reduced.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeNodeStoredSchema {\n\tif (isClassBasedSchema(schema)) {\n\t\treturn getTreeNodeSchemaPrivateData(schema).toStored(options);\n\t}\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\treturn arrayNodeStoredSchema(types, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema, options));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nexport function arrayNodeStoredSchema(\n\ttypes: TreeTypeSet,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes,\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);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,UAAU;gBACpC,KAAK;gBACL,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;aAC3C;YACD,0FAA0F;YAC1F,MAAM,CAAC,iBAAiB,CACxB,CAAC;QACH,CAAC;QACD,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACrB,MAAM,KAAK,GAAG,MAAM,CAAC,uBAAsC,CAAC;YAC5D,OAAO,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC/D,CAAC;QACD,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YACtB,MAAM,MAAM,GAAyC,IAAI,GAAG,EAAE,CAAC;YAC/D,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;gBAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAC9E,CAAC;YACD,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,KAAkB,EAClB,iBAA2D;IAE3D,MAAM,KAAK,GAAG;QACb,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU;QACpC,KAAK;QACL,iBAAiB;KACjB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, getOrCreate, type JsonCompatibleReadOnlyObject } from \"../util/index.js\";\n\nimport {\n\tallowedTypeFilter,\n\tconvertAllowedTypes,\n\tgetTreeNodeSchemaPrivateData,\n\tisClassBasedSchema,\n\tNodeKind,\n\ttype SimpleNodeSchemaBase,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport {\n\tFieldKind,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\ttype ImplicitAnnotatedFieldSchema,\n\ttype ImplicitFieldSchema,\n} from \"./fieldSchema.js\";\nimport type { SimpleFieldSchema, SimpleNodeSchema } from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<\n\tStoredSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\nexport const restrictiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => false,\n};\n\nexport const permissiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitAnnotatedFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitAnnotatedFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitAnnotatedFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitAnnotatedFieldSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst normalized = normalizeFieldSchema(root);\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(normalized, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(\n\t\t\t\t\tbrand(schema.identifier),\n\t\t\t\t\tgetStoredSchema(\n\t\t\t\t\t\tschema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t\tallowedTypeFilter: (allowedType) => allowedTypeFilter(allowedType, options),\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized, options),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema | FieldSchemaAlpha,\n\toptions: StoredSchemaGenerationOptions,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tlet types: TreeTypeSet;\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (schema instanceof FieldSchemaAlpha) {\n\t\ttypes = convertAllowedTypes(schema.annotatedAllowedTypesNormalized, options);\n\t} else {\n\t\ttypes = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t}\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeNodeStoredSchema {\n\tif (isClassBasedSchema(schema)) {\n\t\treturn getTreeNodeSchemaPrivateData(schema).toStored(options);\n\t}\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\tconst types = schema.allowedTypesIdentifiers as TreeTypeSet;\n\t\t\treturn arrayNodeStoredSchema(types, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema, options));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nexport function arrayNodeStoredSchema(\n\ttypes: TreeTypeSet,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes,\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n"]}