@fluidframework/tree 2.43.0 → 2.50.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 (415) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/api-report/tree.alpha.api.md +73 -16
  3. package/api-report/tree.beta.api.md +9 -3
  4. package/api-report/tree.legacy.alpha.api.md +8 -2
  5. package/api-report/tree.legacy.public.api.md +8 -2
  6. package/api-report/tree.public.api.md +8 -2
  7. package/dist/alpha.d.ts +9 -0
  8. package/dist/core/forest/editableForest.d.ts +0 -2
  9. package/dist/core/forest/editableForest.d.ts.map +1 -1
  10. package/dist/core/forest/editableForest.js.map +1 -1
  11. package/dist/core/forest/forest.d.ts +0 -4
  12. package/dist/core/forest/forest.d.ts.map +1 -1
  13. package/dist/core/forest/forest.js +0 -4
  14. package/dist/core/forest/forest.js.map +1 -1
  15. package/dist/core/rebase/changeRebaser.d.ts +0 -6
  16. package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
  17. package/dist/core/rebase/changeRebaser.js.map +1 -1
  18. package/dist/core/rebase/types.d.ts +0 -2
  19. package/dist/core/rebase/types.d.ts.map +1 -1
  20. package/dist/core/rebase/types.js.map +1 -1
  21. package/dist/core/schema-stored/schema.d.ts +0 -8
  22. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  23. package/dist/core/schema-stored/schema.js +0 -8
  24. package/dist/core/schema-stored/schema.js.map +1 -1
  25. package/dist/core/schema-view/view.d.ts +0 -2
  26. package/dist/core/schema-view/view.d.ts.map +1 -1
  27. package/dist/core/schema-view/view.js.map +1 -1
  28. package/dist/core/tree/cursor.d.ts +0 -2
  29. package/dist/core/tree/cursor.d.ts.map +1 -1
  30. package/dist/core/tree/cursor.js +0 -2
  31. package/dist/core/tree/cursor.js.map +1 -1
  32. package/dist/core/tree/delta.d.ts +0 -2
  33. package/dist/core/tree/delta.d.ts.map +1 -1
  34. package/dist/core/tree/delta.js.map +1 -1
  35. package/dist/core/tree/types.d.ts +0 -4
  36. package/dist/core/tree/types.d.ts.map +1 -1
  37. package/dist/core/tree/types.js +0 -2
  38. package/dist/core/tree/types.js.map +1 -1
  39. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +0 -4
  40. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  41. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  42. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -10
  43. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  44. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  45. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -2
  46. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  47. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
  48. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  49. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  50. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  51. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +0 -2
  52. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  53. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -10
  54. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  55. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +0 -2
  56. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  57. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -6
  58. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  59. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  60. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -12
  61. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  62. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  63. package/dist/feature-libraries/sequence-field/types.d.ts +0 -2
  64. package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
  65. package/dist/feature-libraries/sequence-field/types.js.map +1 -1
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +3 -2
  69. package/dist/index.js.map +1 -1
  70. package/dist/jsonDomainSchema.d.ts +2 -6
  71. package/dist/jsonDomainSchema.d.ts.map +1 -1
  72. package/dist/jsonDomainSchema.js +2 -2
  73. package/dist/jsonDomainSchema.js.map +1 -1
  74. package/dist/packageVersion.d.ts +1 -1
  75. package/dist/packageVersion.js +1 -1
  76. package/dist/packageVersion.js.map +1 -1
  77. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  78. package/dist/shared-tree/treeAlpha.js +3 -1
  79. package/dist/shared-tree/treeAlpha.js.map +1 -1
  80. package/dist/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
  81. package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  82. package/dist/shared-tree-core/defaultResubmitMachine.js +54 -46
  83. package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  84. package/dist/shared-tree-core/resubmitMachine.d.ts +6 -0
  85. package/dist/shared-tree-core/resubmitMachine.d.ts.map +1 -1
  86. package/dist/shared-tree-core/resubmitMachine.js.map +1 -1
  87. package/dist/shared-tree-core/sharedTreeCore.d.ts +1 -0
  88. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  89. package/dist/shared-tree-core/sharedTreeCore.js +16 -3
  90. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  91. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  92. package/dist/simple-tree/api/configuration.js +49 -17
  93. package/dist/simple-tree/api/configuration.js.map +1 -1
  94. package/dist/simple-tree/api/customTree.d.ts +1 -1
  95. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  96. package/dist/simple-tree/api/customTree.js +3 -4
  97. package/dist/simple-tree/api/customTree.js.map +1 -1
  98. package/dist/simple-tree/api/index.d.ts +2 -2
  99. package/dist/simple-tree/api/index.d.ts.map +1 -1
  100. package/dist/simple-tree/api/index.js.map +1 -1
  101. package/dist/simple-tree/api/jsonSchema.d.ts +32 -8
  102. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
  103. package/dist/simple-tree/api/jsonSchema.js.map +1 -1
  104. package/dist/simple-tree/api/schemaFactory.d.ts +2 -2
  105. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  106. package/dist/simple-tree/api/schemaFactory.js +1 -1
  107. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  108. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +97 -3
  109. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  110. package/dist/simple-tree/api/schemaFactoryAlpha.js +75 -0
  111. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  112. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +5 -1
  113. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  114. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  115. package/dist/simple-tree/api/schemaFromSimple.js +2 -0
  116. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  117. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  118. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +4 -4
  119. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  120. package/dist/simple-tree/api/treeBeta.d.ts +1 -1
  121. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  122. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  123. package/dist/simple-tree/api/treeNodeApi.js +1 -1
  124. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  125. package/dist/simple-tree/api/typesUnsafe.d.ts +12 -0
  126. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  127. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  128. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  129. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +5 -3
  130. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  131. package/dist/simple-tree/core/index.d.ts +1 -1
  132. package/dist/simple-tree/core/index.d.ts.map +1 -1
  133. package/dist/simple-tree/core/index.js +2 -1
  134. package/dist/simple-tree/core/index.js.map +1 -1
  135. package/dist/simple-tree/core/treeNodeSchema.d.ts +5 -1
  136. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  137. package/dist/simple-tree/core/treeNodeSchema.js +4 -0
  138. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  139. package/dist/simple-tree/index.d.ts +3 -3
  140. package/dist/simple-tree/index.d.ts.map +1 -1
  141. package/dist/simple-tree/index.js +3 -1
  142. package/dist/simple-tree/index.js.map +1 -1
  143. package/dist/simple-tree/node-kinds/index.d.ts +2 -1
  144. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  145. package/dist/simple-tree/node-kinds/index.js +5 -1
  146. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  147. package/dist/simple-tree/node-kinds/object/index.d.ts +1 -1
  148. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  149. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  150. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  151. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  152. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +5 -1
  153. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  154. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  155. package/dist/simple-tree/node-kinds/record/index.d.ts +7 -0
  156. package/dist/simple-tree/node-kinds/record/index.d.ts.map +1 -0
  157. package/dist/simple-tree/node-kinds/record/index.js +13 -0
  158. package/dist/simple-tree/node-kinds/record/index.js.map +1 -0
  159. package/dist/simple-tree/node-kinds/record/recordNode.d.ts +39 -0
  160. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -0
  161. package/dist/simple-tree/node-kinds/record/recordNode.js +234 -0
  162. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -0
  163. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +70 -0
  164. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -0
  165. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js +30 -0
  166. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -0
  167. package/dist/simple-tree/simpleSchema.d.ts +16 -1
  168. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  169. package/dist/simple-tree/simpleSchema.js.map +1 -1
  170. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  171. package/dist/simple-tree/toStoredSchema.js +4 -2
  172. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  173. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
  174. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  175. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +56 -32
  176. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  177. package/dist/tableSchema.d.ts +7 -2
  178. package/dist/tableSchema.d.ts.map +1 -1
  179. package/dist/tableSchema.js +21 -7
  180. package/dist/tableSchema.js.map +1 -1
  181. package/dist/util/brandedMap.d.ts +0 -2
  182. package/dist/util/brandedMap.d.ts.map +1 -1
  183. package/dist/util/brandedMap.js.map +1 -1
  184. package/docs/main/compatibility.md +15 -1
  185. package/lib/alpha.d.ts +9 -0
  186. package/lib/core/forest/editableForest.d.ts +0 -2
  187. package/lib/core/forest/editableForest.d.ts.map +1 -1
  188. package/lib/core/forest/editableForest.js.map +1 -1
  189. package/lib/core/forest/forest.d.ts +0 -4
  190. package/lib/core/forest/forest.d.ts.map +1 -1
  191. package/lib/core/forest/forest.js +0 -4
  192. package/lib/core/forest/forest.js.map +1 -1
  193. package/lib/core/rebase/changeRebaser.d.ts +0 -6
  194. package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
  195. package/lib/core/rebase/changeRebaser.js.map +1 -1
  196. package/lib/core/rebase/types.d.ts +0 -2
  197. package/lib/core/rebase/types.d.ts.map +1 -1
  198. package/lib/core/rebase/types.js.map +1 -1
  199. package/lib/core/schema-stored/schema.d.ts +0 -8
  200. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  201. package/lib/core/schema-stored/schema.js +0 -8
  202. package/lib/core/schema-stored/schema.js.map +1 -1
  203. package/lib/core/schema-view/view.d.ts +0 -2
  204. package/lib/core/schema-view/view.d.ts.map +1 -1
  205. package/lib/core/schema-view/view.js.map +1 -1
  206. package/lib/core/tree/cursor.d.ts +0 -2
  207. package/lib/core/tree/cursor.d.ts.map +1 -1
  208. package/lib/core/tree/cursor.js +0 -2
  209. package/lib/core/tree/cursor.js.map +1 -1
  210. package/lib/core/tree/delta.d.ts +0 -2
  211. package/lib/core/tree/delta.d.ts.map +1 -1
  212. package/lib/core/tree/delta.js.map +1 -1
  213. package/lib/core/tree/types.d.ts +0 -4
  214. package/lib/core/tree/types.d.ts.map +1 -1
  215. package/lib/core/tree/types.js +0 -2
  216. package/lib/core/tree/types.js.map +1 -1
  217. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +0 -4
  218. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  219. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  220. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +0 -10
  221. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  222. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  223. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +0 -2
  224. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  225. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +0 -2
  226. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  227. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +0 -2
  228. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  229. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +0 -2
  230. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  231. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +0 -10
  232. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  233. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +0 -2
  234. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  235. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +0 -6
  236. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  237. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  238. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +0 -12
  239. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  240. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  241. package/lib/feature-libraries/sequence-field/types.d.ts +0 -2
  242. package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
  243. package/lib/feature-libraries/sequence-field/types.js.map +1 -1
  244. package/lib/index.d.ts +1 -1
  245. package/lib/index.d.ts.map +1 -1
  246. package/lib/index.js +1 -1
  247. package/lib/index.js.map +1 -1
  248. package/lib/jsonDomainSchema.d.ts +2 -6
  249. package/lib/jsonDomainSchema.d.ts.map +1 -1
  250. package/lib/jsonDomainSchema.js +3 -3
  251. package/lib/jsonDomainSchema.js.map +1 -1
  252. package/lib/packageVersion.d.ts +1 -1
  253. package/lib/packageVersion.js +1 -1
  254. package/lib/packageVersion.js.map +1 -1
  255. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  256. package/lib/shared-tree/treeAlpha.js +3 -1
  257. package/lib/shared-tree/treeAlpha.js.map +1 -1
  258. package/lib/shared-tree-core/defaultResubmitMachine.d.ts +8 -12
  259. package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
  260. package/lib/shared-tree-core/defaultResubmitMachine.js +55 -47
  261. package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
  262. package/lib/shared-tree-core/resubmitMachine.d.ts +6 -0
  263. package/lib/shared-tree-core/resubmitMachine.d.ts.map +1 -1
  264. package/lib/shared-tree-core/resubmitMachine.js.map +1 -1
  265. package/lib/shared-tree-core/sharedTreeCore.d.ts +1 -0
  266. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  267. package/lib/shared-tree-core/sharedTreeCore.js +16 -3
  268. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  269. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  270. package/lib/simple-tree/api/configuration.js +51 -19
  271. package/lib/simple-tree/api/configuration.js.map +1 -1
  272. package/lib/simple-tree/api/customTree.d.ts +1 -1
  273. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  274. package/lib/simple-tree/api/customTree.js +2 -3
  275. package/lib/simple-tree/api/customTree.js.map +1 -1
  276. package/lib/simple-tree/api/index.d.ts +2 -2
  277. package/lib/simple-tree/api/index.d.ts.map +1 -1
  278. package/lib/simple-tree/api/index.js.map +1 -1
  279. package/lib/simple-tree/api/jsonSchema.d.ts +32 -8
  280. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
  281. package/lib/simple-tree/api/jsonSchema.js.map +1 -1
  282. package/lib/simple-tree/api/schemaFactory.d.ts +2 -2
  283. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  284. package/lib/simple-tree/api/schemaFactory.js +1 -1
  285. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  286. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +97 -3
  287. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  288. package/lib/simple-tree/api/schemaFactoryAlpha.js +77 -2
  289. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  290. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +5 -1
  291. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  292. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  293. package/lib/simple-tree/api/schemaFromSimple.js +2 -0
  294. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  295. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  296. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +5 -5
  297. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  298. package/lib/simple-tree/api/treeBeta.d.ts +1 -1
  299. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  300. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  301. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  302. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  303. package/lib/simple-tree/api/typesUnsafe.d.ts +12 -0
  304. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  305. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  306. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  307. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +6 -4
  308. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  309. package/lib/simple-tree/core/index.d.ts +1 -1
  310. package/lib/simple-tree/core/index.d.ts.map +1 -1
  311. package/lib/simple-tree/core/index.js +1 -1
  312. package/lib/simple-tree/core/index.js.map +1 -1
  313. package/lib/simple-tree/core/treeNodeSchema.d.ts +5 -1
  314. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  315. package/lib/simple-tree/core/treeNodeSchema.js +4 -0
  316. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  317. package/lib/simple-tree/index.d.ts +3 -3
  318. package/lib/simple-tree/index.d.ts.map +1 -1
  319. package/lib/simple-tree/index.js +1 -1
  320. package/lib/simple-tree/index.js.map +1 -1
  321. package/lib/simple-tree/node-kinds/index.d.ts +2 -1
  322. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  323. package/lib/simple-tree/node-kinds/index.js +1 -0
  324. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  325. package/lib/simple-tree/node-kinds/object/index.d.ts +1 -1
  326. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  327. package/lib/simple-tree/node-kinds/object/index.js +1 -1
  328. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  329. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  330. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  331. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +5 -1
  332. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  333. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  334. package/lib/simple-tree/node-kinds/record/index.d.ts +7 -0
  335. package/lib/simple-tree/node-kinds/record/index.d.ts.map +1 -0
  336. package/lib/simple-tree/node-kinds/record/index.js +7 -0
  337. package/lib/simple-tree/node-kinds/record/index.js.map +1 -0
  338. package/lib/simple-tree/node-kinds/record/recordNode.d.ts +39 -0
  339. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -0
  340. package/lib/simple-tree/node-kinds/record/recordNode.js +232 -0
  341. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -0
  342. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +70 -0
  343. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -0
  344. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js +26 -0
  345. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -0
  346. package/lib/simple-tree/simpleSchema.d.ts +16 -1
  347. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  348. package/lib/simple-tree/simpleSchema.js.map +1 -1
  349. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  350. package/lib/simple-tree/toStoredSchema.js +4 -2
  351. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  352. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +1 -1
  353. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  354. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +58 -34
  355. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  356. package/lib/tableSchema.d.ts +7 -2
  357. package/lib/tableSchema.d.ts.map +1 -1
  358. package/lib/tableSchema.js +22 -8
  359. package/lib/tableSchema.js.map +1 -1
  360. package/lib/util/brandedMap.d.ts +0 -2
  361. package/lib/util/brandedMap.d.ts.map +1 -1
  362. package/lib/util/brandedMap.js.map +1 -1
  363. package/package.json +34 -22
  364. package/src/core/forest/editableForest.ts +0 -2
  365. package/src/core/forest/forest.ts +0 -4
  366. package/src/core/rebase/changeRebaser.ts +0 -6
  367. package/src/core/rebase/types.ts +0 -2
  368. package/src/core/schema-stored/schema.ts +0 -8
  369. package/src/core/schema-view/view.ts +0 -2
  370. package/src/core/tree/cursor.ts +0 -2
  371. package/src/core/tree/delta.ts +0 -2
  372. package/src/core/tree/types.ts +0 -4
  373. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +0 -4
  374. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +0 -10
  375. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +0 -2
  376. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +0 -2
  377. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +0 -10
  378. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +0 -8
  379. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +0 -12
  380. package/src/feature-libraries/sequence-field/types.ts +0 -2
  381. package/src/index.ts +9 -0
  382. package/src/jsonDomainSchema.ts +3 -3
  383. package/src/packageVersion.ts +1 -1
  384. package/src/shared-tree/treeAlpha.ts +3 -1
  385. package/src/shared-tree-core/defaultResubmitMachine.ts +99 -52
  386. package/src/shared-tree-core/resubmitMachine.ts +7 -0
  387. package/src/shared-tree-core/sharedTreeCore.ts +18 -6
  388. package/src/simple-tree/api/configuration.ts +73 -19
  389. package/src/simple-tree/api/customTree.ts +3 -3
  390. package/src/simple-tree/api/index.ts +3 -0
  391. package/src/simple-tree/api/jsonSchema.ts +35 -8
  392. package/src/simple-tree/api/schemaFactory.ts +5 -13
  393. package/src/simple-tree/api/schemaFactoryAlpha.ts +268 -1
  394. package/src/simple-tree/api/schemaFactoryRecursive.ts +5 -1
  395. package/src/simple-tree/api/schemaFromSimple.ts +6 -0
  396. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +16 -7
  397. package/src/simple-tree/api/treeBeta.ts +2 -2
  398. package/src/simple-tree/api/treeNodeApi.ts +2 -2
  399. package/src/simple-tree/api/typesUnsafe.ts +15 -0
  400. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +14 -6
  401. package/src/simple-tree/core/index.ts +1 -0
  402. package/src/simple-tree/core/treeNodeSchema.ts +8 -4
  403. package/src/simple-tree/index.ts +11 -0
  404. package/src/simple-tree/node-kinds/index.ts +11 -0
  405. package/src/simple-tree/node-kinds/object/index.ts +5 -1
  406. package/src/simple-tree/node-kinds/object/objectNode.ts +3 -2
  407. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +6 -3
  408. package/src/simple-tree/node-kinds/record/index.ts +14 -0
  409. package/src/simple-tree/node-kinds/record/recordNode.ts +410 -0
  410. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +136 -0
  411. package/src/simple-tree/simpleSchema.ts +19 -1
  412. package/src/simple-tree/toStoredSchema.ts +4 -2
  413. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +83 -40
  414. package/src/tableSchema.ts +27 -8
  415. package/src/util/brandedMap.ts +0 -2
@@ -0,0 +1,232 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Lazy } from "@fluidframework/core-utils/internal";
6
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
+ import { brand } from "../../../util/index.js";
8
+ import { NodeKind,
9
+ // eslint-disable-next-line import/no-deprecated
10
+ typeNameSymbol, typeSchemaSymbol, getOrCreateInnerNode, getKernel, } from "../../core/index.js";
11
+ import { getUnhydratedContext } from "../../createContext.js";
12
+ import { tryGetTreeNodeForField } from "../../getTreeNodeForField.js";
13
+ import { normalizeAllowedTypes, unannotateImplicitAllowedTypes, createFieldSchema, FieldKind, normalizeAnnotatedAllowedTypes, } from "../../schemaTypes.js";
14
+ import { unhydratedFlexTreeFromInsertable, } from "../../unhydratedFlexTreeFromInsertable.js";
15
+ import { TreeNodeValid } from "../../treeNodeValid.js";
16
+ import { prepareForInsertion } from "../../prepareForInsertion.js";
17
+ /**
18
+ * Create a proxy which implements the {@link TreeRecordNode} API.
19
+ * @param proxyTarget - Target object of the proxy.
20
+ * @param customizable - See {@link RecordNodeSchemaOptions.customizable}.
21
+ * @param schema - The schema of the record node.
22
+ */
23
+ function createRecordNodeProxy(proxyTarget, customizable, schema) {
24
+ const proxy = new Proxy(proxyTarget, {
25
+ get: (target, key, receiver) => {
26
+ if (typeof key === "symbol") {
27
+ switch (key) {
28
+ // POJO mode records don't have TreeNode's build in members on their targets, so special case them:
29
+ case typeSchemaSymbol: {
30
+ return schema;
31
+ }
32
+ // eslint-disable-next-line import/no-deprecated
33
+ case typeNameSymbol: {
34
+ return schema.identifier;
35
+ }
36
+ case Symbol.iterator: {
37
+ return () => recordIterator(proxy);
38
+ }
39
+ case Symbol.toPrimitive: {
40
+ // Handle string interpolation and coercion to string
41
+ return () => Object.prototype.toString.call(proxy);
42
+ }
43
+ case Symbol.toStringTag: {
44
+ // In order to satisfy deep equality checks in POJO (non-customizable) mode,
45
+ // we cannot override the behavior of this.
46
+ if (customizable) {
47
+ // Generates nicer toString behavior for customizable records.
48
+ // E.g. `[object My.Record]` instead of `[object Object]`.
49
+ return schema.identifier;
50
+ }
51
+ break;
52
+ }
53
+ default: {
54
+ // No-op
55
+ }
56
+ }
57
+ }
58
+ if (typeof key === "string") {
59
+ const innerNode = getOrCreateInnerNode(receiver);
60
+ const field = innerNode.tryGetField(brand(key));
61
+ if (field !== undefined) {
62
+ return tryGetTreeNodeForField(field);
63
+ }
64
+ }
65
+ return undefined;
66
+ },
67
+ set: (target, key, value, receiver) => {
68
+ if (typeof key === "symbol") {
69
+ return false;
70
+ }
71
+ const innerNode = getOrCreateInnerNode(receiver);
72
+ const field = innerNode.getBoxed(brand(key));
73
+ const kernel = getKernel(receiver);
74
+ const mapTree = prepareForInsertion(value, createFieldSchema(FieldKind.Optional, kernel.schema.info), innerNode.context);
75
+ field.editor.set(mapTree, field.length === 0);
76
+ return true;
77
+ },
78
+ has: (target, key) => {
79
+ if (typeof key === "symbol") {
80
+ return false;
81
+ }
82
+ const innerNode = getOrCreateInnerNode(proxy);
83
+ const childField = innerNode.tryGetField(brand(key));
84
+ return childField !== undefined;
85
+ },
86
+ ownKeys: (target) => {
87
+ const innerNode = getOrCreateInnerNode(proxy);
88
+ return [...innerNode.keys()];
89
+ },
90
+ getOwnPropertyDescriptor: (target, key) => {
91
+ if (typeof key === "symbol") {
92
+ return undefined;
93
+ }
94
+ const innerNode = getOrCreateInnerNode(proxy);
95
+ const field = innerNode.tryGetField(brand(key));
96
+ if (field === undefined) {
97
+ return undefined;
98
+ }
99
+ return {
100
+ value: tryGetTreeNodeForField(field),
101
+ writable: true,
102
+ enumerable: true,
103
+ configurable: true, // Must be 'configurable' if property is absent from proxy target.
104
+ };
105
+ },
106
+ defineProperty(target, key, attributes) {
107
+ throw new UsageError("Shadowing properties of record nodes is not permitted.");
108
+ },
109
+ deleteProperty(target, key) {
110
+ if (typeof key === "symbol") {
111
+ return false;
112
+ }
113
+ const innerNode = getOrCreateInnerNode(proxy);
114
+ const field = innerNode.tryGetField(brand(key));
115
+ if (field === undefined) {
116
+ return false;
117
+ }
118
+ field.editor.set(undefined, field.length === 0);
119
+ return true;
120
+ },
121
+ });
122
+ return proxy;
123
+ }
124
+ class CustomRecordNodeBase extends TreeNodeValid {
125
+ constructor(input) {
126
+ super(input ?? {});
127
+ }
128
+ }
129
+ CustomRecordNodeBase.kind = NodeKind.Record;
130
+ /**
131
+ * Define a {@link TreeNodeSchema} for a {@link TreeRecordNode}.
132
+ *
133
+ * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
134
+ * @param persistedMetadata -
135
+ */
136
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
137
+ export function recordSchema(options) {
138
+ const { identifier, info, customizable, implicitlyConstructable, metadata, persistedMetadata, } = options;
139
+ const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(unannotateImplicitAllowedTypes(info)));
140
+ const lazyAnnotatedTypes = new Lazy(() => [normalizeAnnotatedAllowedTypes(info)]);
141
+ const lazyAllowedTypesIdentifiers = new Lazy(() => new Set([...lazyChildTypes.value].map((type) => type.identifier)));
142
+ let unhydratedContext;
143
+ class Schema extends CustomRecordNodeBase {
144
+ static prepareInstance(instance, flexNode) {
145
+ // Differentiate between the following cases:
146
+ //
147
+ // Case 1: Direct construction (POJO emulation)
148
+ //
149
+ // const Foo = schemaFactory.record("Foo", schemaFactory.number);
150
+ //
151
+ // assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },
152
+ // "Prototype chain equivalent to POJO.");
153
+ //
154
+ // Case 2: Subclass construction (Customizable Record)
155
+ //
156
+ // class Foo extends schemaFactory.record("Foo", schemaFactory.number) {}
157
+ //
158
+ // assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },
159
+ // "Subclass prototype chain differs from POJO.");
160
+ //
161
+ // In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)
162
+ // In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)
163
+ const proxyTarget = customizable ? instance : {};
164
+ return createRecordNodeProxy(proxyTarget, customizable, this);
165
+ }
166
+ static buildRawNode(instance, input) {
167
+ return unhydratedFlexTreeFromInsertable(input, this);
168
+ }
169
+ static oneTimeSetup() {
170
+ const schema = this;
171
+ unhydratedContext = getUnhydratedContext(schema);
172
+ // First run, do extra validation.
173
+ // TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.
174
+ // Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).
175
+ {
176
+ let prototype = this.prototype;
177
+ // There isn't a clear cleaner way to author this loop.
178
+ while (prototype !== Schema.prototype) {
179
+ for (const key of Object.getOwnPropertyNames(prototype)) {
180
+ if (
181
+ // 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.
182
+ key !== "constructor" &&
183
+ Reflect.getOwnPropertyDescriptor(prototype, key) !== undefined) {
184
+ throw new UsageError(`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.`);
185
+ }
186
+ }
187
+ // Since this stops at CustomRecordNode, it should never see a null prototype, so this case is safe.
188
+ // Additionally, if the prototype chain is ever messed up such that CustomRecordNode is not in it,
189
+ // the null that would show up here does at least ensure this code throws instead of hanging.
190
+ prototype = Reflect.getPrototypeOf(prototype);
191
+ }
192
+ }
193
+ return unhydratedContext;
194
+ }
195
+ static get allowedTypesIdentifiers() {
196
+ return lazyAllowedTypesIdentifiers.value;
197
+ }
198
+ static get childTypes() {
199
+ return lazyChildTypes.value;
200
+ }
201
+ static get childAnnotatedAllowedTypes() {
202
+ return lazyAnnotatedTypes.value;
203
+ }
204
+ // eslint-disable-next-line import/no-deprecated
205
+ get [typeNameSymbol]() {
206
+ return identifier;
207
+ }
208
+ get [typeSchemaSymbol]() {
209
+ return Schema.constructorCached?.constructor;
210
+ }
211
+ [Symbol.iterator]() {
212
+ return recordIterator(this);
213
+ }
214
+ get [Symbol.toStringTag]() {
215
+ return identifier;
216
+ }
217
+ }
218
+ Schema.constructorCached = undefined;
219
+ Schema.identifier = identifier;
220
+ Schema.info = info;
221
+ Schema.implicitlyConstructable = implicitlyConstructable;
222
+ Schema.metadata = metadata ?? {};
223
+ Schema.persistedMetadata = persistedMetadata;
224
+ const output = Schema;
225
+ return output;
226
+ }
227
+ function* recordIterator(record) {
228
+ for (const [key, value] of Object.entries(record)) {
229
+ yield [key, value];
230
+ }
231
+ }
232
+ //# sourceMappingURL=recordNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC3D,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,EAGhB,oBAAoB,EACpB,SAAS,GAGT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAIN,qBAAqB,EACrB,8BAA8B,EAG9B,iBAAiB,EACjB,SAAS,EACT,8BAA8B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,gCAAgC,GAEhC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,aAAa,EAAwB,MAAM,wBAAwB,CAAC;AAS7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE;;;;;GAK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KAAK,CAAC;QACjC,CAAC;QAKD,gDAAgD;QAChD,IAAW,CAAC,cAAc,CAAC;YAC1B,OAAO,UAAU,CAAC;QACnB,CAAC;QACD,IAAW,CAAC,gBAAgB,CAAC;YAC5B,OAAO,MAAM,CAAC,iBAAiB,EAAE,WAAgC,CAAC;QACnE,CAAC;QAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;YAGvB,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,IAAW,CAAC,MAAM,CAAC,WAAW,CAAC;YAC9B,OAAO,UAAU,CAAC;QACnB,CAAC;;IA/ByB,wBAAiB,GAAgC,SAAS,CAAC;IAE9D,iBAAU,GAAG,UAAU,CAAC;IACxB,WAAI,GAAG,IAAI,CAAC;IACZ,8BAAuB,GAC7C,uBAAuB,CAAC;IAOF,eAAQ,GAAwC,QAAQ,IAAI,EAAE,CAAC;IAC/D,wBAAiB,GACvC,iBAAiB,CAAC;IAiCpB,MAAM,MAAM,GAAW,MAAM,CAAC;IAC9B,OAAO,MAAM,CAAC;AACf,CAAC;AAED,QAAQ,CAAC,CAAC,cAAc,CACvB,MAAqC;IAErC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { 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 Context,\n\ttype UnhydratedFlexTreeNode,\n\tgetOrCreateInnerNode,\n\tgetKernel,\n\ttype InternalTreeNode,\n\ttype NormalizedAnnotatedAllowedTypes,\n} from \"../../core/index.js\";\nimport { getUnhydratedContext } from \"../../createContext.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport {\n\ttype NodeSchemaMetadata,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\tunannotateImplicitAllowedTypes,\n\ttype ImplicitAnnotatedAllowedTypes,\n\ttype UnannotateImplicitAllowedTypes,\n\tcreateFieldSchema,\n\tFieldKind,\n\tnormalizeAnnotatedAllowedTypes,\n} from \"../../schemaTypes.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport { TreeNodeValid, type MostDerivedData } from \"../../treeNodeValid.js\";\nimport type {\n\tRecordNodeCustomizableSchema,\n\tRecordNodeInsertableData,\n\tRecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\tTreeRecordNode,\n} from \"./recordNodeTypes.js\";\nimport type { FlexTreeNode, FlexTreeOptionalField } from \"../../../feature-libraries/index.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.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\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);\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 lazyAnnotatedTypes = new Lazy(() => [normalizeAnnotatedAllowedTypes(info)]);\n\tconst lazyAllowedTypesIdentifiers = new Lazy(\n\t\t() => new Set([...lazyChildTypes.value].map((type) => type.identifier)),\n\t);\n\n\tlet unhydratedContext: Context;\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<T2>(this: typeof TreeNodeValid<T2>): Context {\n\t\t\tconst schema = this as unknown as RecordNodeSchema;\n\t\t\tunhydratedContext = getUnhydratedContext(schema);\n\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\treturn unhydratedContext;\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 get childAnnotatedAllowedTypes(): readonly NormalizedAnnotatedAllowedTypes[] {\n\t\t\treturn lazyAnnotatedTypes.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\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\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"]}
@@ -0,0 +1,70 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { ImplicitAllowedTypes, ImplicitAnnotatedAllowedTypes, InsertableTreeNodeFromImplicitAllowedTypes, TreeNodeFromImplicitAllowedTypes, UnannotateImplicitAllowedTypes } from "../../schemaTypes.js";
6
+ import { NodeKind, type TreeNodeSchemaClass, type TreeNodeSchema, type TreeNodeSchemaNonClass, type WithType, type TreeNode } from "../../core/index.js";
7
+ import type { SimpleRecordNodeSchema } from "../../simpleSchema.js";
8
+ import type { RestrictiveStringRecord } from "../../../util/index.js";
9
+ /**
10
+ * A {@link TreeNode} which models a TypeScript {@link https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type | record}.
11
+ *
12
+ * @remarks
13
+ * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.
14
+ * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,
15
+ * or using some other method like {@link (TreeAlpha:interface).create}.
16
+ *
17
+ * @alpha
18
+ */
19
+ export interface TreeRecordNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeNode, Record<string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {
20
+ /**
21
+ * Allows the record's entries to be iterated over, including in contexts like `for...of` loops.
22
+ */
23
+ [Symbol.iterator](): IterableIterator<[
24
+ string,
25
+ TreeNodeFromImplicitAllowedTypes<TAllowedTypes>
26
+ ]>;
27
+ }
28
+ /**
29
+ * Content which can be used to construct a Record node, explicitly or implicitly.
30
+ * @system @alpha
31
+ */
32
+ export type RecordNodeInsertableData<T extends ImplicitAllowedTypes> = RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypes<T>>;
33
+ /**
34
+ * A schema for customizable {@link (TreeMapNode:interface)}s.
35
+ * @system @sealed @alpha
36
+ */
37
+ export interface RecordNodeCustomizableSchema<out TName extends string = string, in out T extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaClass<TName, NodeKind.Record, TreeRecordNode<UnannotateImplicitAllowedTypes<T>> & WithType<TName, NodeKind.Record, T>, RecordNodeInsertableData<UnannotateImplicitAllowedTypes<T>>, ImplicitlyConstructable, T, never, TCustomMetadata>, SimpleRecordNodeSchema<TCustomMetadata> {
38
+ }
39
+ /**
40
+ * A schema for POJO emulation mode {@link (TreeMapNode:interface)}s.
41
+ * @system @sealed @alpha
42
+ */
43
+ export interface RecordNodePojoEmulationSchema<out TName extends string = string, in out T extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes, out ImplicitlyConstructable extends boolean = true, out TCustomMetadata = unknown> extends TreeNodeSchemaNonClass<TName, NodeKind.Record, TreeRecordNode<UnannotateImplicitAllowedTypes<T>> & WithType<TName, NodeKind.Record, T>, RecordNodeInsertableData<UnannotateImplicitAllowedTypes<T>>, ImplicitlyConstructable, T, never, TCustomMetadata>, SimpleRecordNodeSchema<TCustomMetadata> {
44
+ }
45
+ /**
46
+ * A schema for {@link (TreeRecordNode:interface)}s.
47
+ * @privateRemarks
48
+ * This could have generic arguments added and forwarded.
49
+ * The expected use-cases for this don't need them however, and if they did want an argument it would probably be the allowed types;
50
+ * perhaps if moving to an order independent way to pass generic arguments, adding support for them here would make sense.
51
+ * @alpha
52
+ */
53
+ export type RecordNodeSchema<TName extends string = string, T extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes, ImplicitlyConstructable extends boolean = true, TCustomMetadata = unknown> = RecordNodeCustomizableSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> | RecordNodePojoEmulationSchema<TName, T, ImplicitlyConstructable, TCustomMetadata>;
54
+ /**
55
+ * @alpha
56
+ */
57
+ export declare const RecordNodeSchema: {
58
+ /**
59
+ * `instanceof`-based narrowing support for {@link (RecordNodeSchema:type)} in JavaScript and TypeScript 5.3 or newer.
60
+ */
61
+ readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is RecordNodeSchema<string, ImplicitAnnotatedAllowedTypes, true, unknown>;
62
+ };
63
+ /**
64
+ * Narrows a {@link (TreeNodeSchema:interface)} to an {@link (RecordNodeSchema:interface)}.
65
+ * @privateRemarks
66
+ * If at some point we want to have internal only APIs for RecordNodeSchema (like done for objects),
67
+ * this can include those since its not the public-facing API.
68
+ */
69
+ export declare function isRecordNodeSchema(schema: TreeNodeSchema): schema is RecordNodeSchema;
70
+ //# sourceMappingURL=recordNodeTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordNodeTypes.d.ts","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNodeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,oBAAoB,EACpB,6BAA6B,EAC7B,0CAA0C,EAC1C,gCAAgC,EAChC,8BAA8B,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,QAAQ,EACR,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc,CAC9B,aAAa,SAAS,oBAAoB,GAAG,oBAAoB,CAChE,SAAQ,QAAQ,EAChB,MAAM,CAAC,MAAM,EAAE,gCAAg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,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,EAClB,wBAAwB,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,EAC/C,uBAAuB,EAC1C,CAAC,EACY,KAAK,EACP,eAAe,CACrC,EACD,sBAAsB,CAAC,eAAe,CAAC;CAAG;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,CAC3B,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,CAAC,SAAS,6BAA6B,GAAG,6BAA6B,EACvE,uBAAuB,SAAS,OAAO,GAAG,IAAI,EAC9C,eAAe,GAAG,OAAO,IAEvB,4BAA4B,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,EAAE,eAAe,CAAC,GAChF,6BAA6B,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,EAAE,eAAe,CAAC,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC5B;;OAEG;2CACyB,cAAc;CAGjC,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,gBAAgB,CAErF"}
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { NodeKind, } from "../../core/index.js";
6
+ /**
7
+ * @alpha
8
+ */
9
+ export const RecordNodeSchema = {
10
+ /**
11
+ * `instanceof`-based narrowing support for {@link (RecordNodeSchema:type)} in JavaScript and TypeScript 5.3 or newer.
12
+ */
13
+ [Symbol.hasInstance](value) {
14
+ return isRecordNodeSchema(value);
15
+ },
16
+ };
17
+ /**
18
+ * Narrows a {@link (TreeNodeSchema:interface)} to an {@link (RecordNodeSchema:interface)}.
19
+ * @privateRemarks
20
+ * If at some point we want to have internal only APIs for RecordNodeSchema (like done for objects),
21
+ * this can include those since its not the public-facing API.
22
+ */
23
+ export function isRecordNodeSchema(schema) {
24
+ return schema.kind === NodeKind.Record;
25
+ }
26
+ //# sourceMappingURL=recordNodeTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordNodeTypes.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNodeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EACN,QAAQ,GAMR,MAAM,qBAAqB,CAAC;AAgG7B;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B;;OAEG;IACH,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAqB;QACzC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACQ,CAAC;AAEX;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACxD,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM,CAAC;AACxC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tImplicitAllowedTypes,\n\tImplicitAnnotatedAllowedTypes,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tTreeNodeFromImplicitAllowedTypes,\n\tUnannotateImplicitAllowedTypes,\n} from \"../../schemaTypes.js\";\nimport {\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaNonClass,\n\ttype WithType,\n\ttype TreeNode,\n} from \"../../core/index.js\";\n\nimport type { SimpleRecordNodeSchema } from \"../../simpleSchema.js\";\nimport type { RestrictiveStringRecord } from \"../../../util/index.js\";\n\n/**\n * A {@link TreeNode} which models a TypeScript {@link https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type | record}.\n *\n * @remarks\n * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.\n * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,\n * or using some other method like {@link (TreeAlpha:interface).create}.\n *\n * @alpha\n */\nexport interface TreeRecordNode<\n\tTAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n> extends TreeNode,\n\t\tRecord<string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>> {\n\t/**\n\t * Allows the record's entries to be iterated over, including in contexts like `for...of` loops.\n\t */\n\t[Symbol.iterator](): IterableIterator<\n\t\t[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]\n\t>;\n}\n\n/**\n * Content which can be used to construct a Record node, explicitly or implicitly.\n * @system @alpha\n */\nexport type RecordNodeInsertableData<T extends ImplicitAllowedTypes> = RestrictiveStringRecord<\n\tInsertableTreeNodeFromImplicitAllowedTypes<T>\n>;\n\n/**\n * A schema for customizable {@link (TreeMapNode:interface)}s.\n * @system @sealed @alpha\n */\nexport interface RecordNodeCustomizableSchema<\n\tout TName extends string = string,\n\tin out T extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes,\n\tout ImplicitlyConstructable extends boolean = true,\n\tout TCustomMetadata = unknown,\n> extends TreeNodeSchemaClass<\n\t\t\t/* Name */ TName,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<UnannotateImplicitAllowedTypes<T>> &\n\t\t\t\tWithType<TName, NodeKind.Record, T>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<UnannotateImplicitAllowedTypes<T>>,\n\t\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ never,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>,\n\t\tSimpleRecordNodeSchema<TCustomMetadata> {}\n\n/**\n * A schema for POJO emulation mode {@link (TreeMapNode:interface)}s.\n * @system @sealed @alpha\n */\nexport interface RecordNodePojoEmulationSchema<\n\tout TName extends string = string,\n\tin out T extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes,\n\tout ImplicitlyConstructable extends boolean = true,\n\tout TCustomMetadata = unknown,\n> extends TreeNodeSchemaNonClass<\n\t\t\t/* Name */ TName,\n\t\t\t/* Kind */ NodeKind.Record,\n\t\t\t/* TNode */ TreeRecordNode<UnannotateImplicitAllowedTypes<T>> &\n\t\t\t\tWithType<TName, NodeKind.Record, T>,\n\t\t\t/* TInsertable */ RecordNodeInsertableData<UnannotateImplicitAllowedTypes<T>>,\n\t\t\t/* ImplicitlyConstructable */ ImplicitlyConstructable,\n\t\t\t/* Info */ T,\n\t\t\t/* TConstructorExtra */ never,\n\t\t\t/* TCustomMetadata */ TCustomMetadata\n\t\t>,\n\t\tSimpleRecordNodeSchema<TCustomMetadata> {}\n\n/**\n * A schema for {@link (TreeRecordNode:interface)}s.\n * @privateRemarks\n * This could have generic arguments added and forwarded.\n * The expected use-cases for this don't need them however, and if they did want an argument it would probably be the allowed types;\n * perhaps if moving to an order independent way to pass generic arguments, adding support for them here would make sense.\n * @alpha\n */\nexport type RecordNodeSchema<\n\tTName extends string = string,\n\tT extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes,\n\tImplicitlyConstructable extends boolean = true,\n\tTCustomMetadata = unknown,\n> =\n\t| RecordNodeCustomizableSchema<TName, T, ImplicitlyConstructable, TCustomMetadata>\n\t| RecordNodePojoEmulationSchema<TName, T, ImplicitlyConstructable, TCustomMetadata>;\n\n/**\n * @alpha\n */\nexport const RecordNodeSchema = {\n\t/**\n\t * `instanceof`-based narrowing support for {@link (RecordNodeSchema:type)} in JavaScript and TypeScript 5.3 or newer.\n\t */\n\t[Symbol.hasInstance](value: TreeNodeSchema): value is RecordNodeSchema {\n\t\treturn isRecordNodeSchema(value);\n\t},\n} as const;\n\n/**\n * Narrows a {@link (TreeNodeSchema:interface)} to an {@link (RecordNodeSchema:interface)}.\n * @privateRemarks\n * If at some point we want to have internal only APIs for RecordNodeSchema (like done for objects),\n * this can include those since its not the public-facing API.\n */\nexport function isRecordNodeSchema(schema: TreeNodeSchema): schema is RecordNodeSchema {\n\treturn schema.kind === NodeKind.Record;\n}\n"]}
@@ -103,6 +103,21 @@ export interface SimpleMapNodeSchema<out TCustomMetadata = unknown> extends Simp
103
103
  */
104
104
  readonly allowedTypesIdentifiers: ReadonlySet<string>;
105
105
  }
106
+ /**
107
+ * A {@link SimpleNodeSchema} for a map node.
108
+ *
109
+ * @alpha
110
+ * @sealed
111
+ */
112
+ export interface SimpleRecordNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBaseAlpha<NodeKind.Record, TCustomMetadata> {
113
+ /**
114
+ * The types allowed as values in the record.
115
+ *
116
+ * @remarks Refers to the types by identifier.
117
+ * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
118
+ */
119
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
120
+ }
106
121
  /**
107
122
  * A {@link SimpleNodeSchema} for a leaf node.
108
123
  *
@@ -129,7 +144,7 @@ export interface SimpleLeafNodeSchema extends SimpleNodeSchemaBaseAlpha<NodeKind
129
144
  *
130
145
  * @alpha
131
146
  */
132
- export type SimpleNodeSchema = SimpleLeafNodeSchema | SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleObjectNodeSchema;
147
+ export type SimpleNodeSchema = SimpleLeafNodeSchema | SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleObjectNodeSchema | SimpleRecordNodeSchema;
133
148
  /**
134
149
  * A simple, shallow representation of a schema for a field.
135
150
  *
@@ -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,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,E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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 } from \"./core/index.js\";\nimport type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from \"./schemaTypes.js\";\n\n/*\n * TODO:\n * - Customize their JSON serialization to use these formats or provide some other serialization scheme.\n */\n\n/**\n * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.\n * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.\n * @system\n * @public\n * @sealed\n */\nexport interface SimpleNodeSchemaBase<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * The {@link NodeKind}.\n\t *\n\t * @remarks can be used to type-switch between implementations.\n\t */\n\treadonly kind: TNodeKind;\n\n\t/**\n\t * User-provided {@link NodeSchemaMetadata} for this schema.\n\t */\n\treadonly metadata: NodeSchemaMetadata<TCustomMetadata>;\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 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\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 the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\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 } from \"./core/index.js\";\nimport type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from \"./schemaTypes.js\";\n\n/*\n * TODO:\n * - Customize their JSON serialization to use these formats or provide some other serialization scheme.\n */\n\n/**\n * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.\n * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.\n * @system\n * @public\n * @sealed\n */\nexport interface SimpleNodeSchemaBase<\n\tout TNodeKind extends NodeKind,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * The {@link NodeKind}.\n\t *\n\t * @remarks can be used to type-switch between implementations.\n\t */\n\treadonly kind: TNodeKind;\n\n\t/**\n\t * User-provided {@link NodeSchemaMetadata} for this schema.\n\t */\n\treadonly metadata: NodeSchemaMetadata<TCustomMetadata>;\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 the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAK/E,OAAO,EAAE,SAAS,EAAwB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAEhB,gBAAgB,EAChB,MAAM,mBAAmB,CAAC;AAK3B;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,CA2B1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAW7E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,qBAAqB,CAK7E;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,SAAS,EAAE,aAAa,CAOjE,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CAuC9E"}
1
+ {"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAK/E,OAAO,EAAE,SAAS,EAAwB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAEhB,gBAAgB,EAChB,MAAM,mBAAmB,CAAC;AAK3B;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,CA2B1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAW7E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,qBAAqB,CAK7E;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,SAAS,EAAE,aAAa,CAOjE,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CAyC9E"}
@@ -79,7 +79,8 @@ export function getStoredSchema(schema) {
79
79
  assert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);
80
80
  return new LeafNodeStoredSchema(schema.leafKind);
81
81
  }
82
- case NodeKind.Map: {
82
+ case NodeKind.Map:
83
+ case NodeKind.Record: {
83
84
  const types = schema.allowedTypesIdentifiers;
84
85
  return new MapNodeStoredSchema({
85
86
  kind: FieldKinds.optional.identifier,
@@ -106,8 +107,9 @@ export function getStoredSchema(schema) {
106
107
  }
107
108
  return new ObjectNodeStoredSchema(fields, schema.persistedMetadata);
108
109
  }
109
- default:
110
+ default: {
110
111
  unreachableCase(kind);
112
+ }
111
113
  }
112
114
  }
113
115
  //# sourceMappingURL=toStoredSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACpF,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,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA4B,MAAM,kBAAkB,CAAC;AAO7F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAyC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAyB;IACvD,OAAO,WAAW,CAAC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,MAAM,CAAC,uBAAsC,CAAC;YAC5D,MAAM,KAAK,GAAG;gBACb,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU;gBACpC,KAAK;gBACL,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;aAC3C,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,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,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC;QACD;YACC,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, 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 } from \"../util/index.js\";\n\nimport { NodeKind } from \"./core/index.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./schemaTypes.js\";\nimport type {\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleNodeSchemaBase,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn getOrCreate(viewToStoredCache, 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(schema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema),\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Converts a {@link SimpleTreeSchema} into a {@link TreeStoredSchema}.\n */\nexport function simpleToStoredSchema(root: SimpleTreeSchema): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\tfor (const [identifier, schema] of root.definitions) {\n\t\tnodeSchema.set(brand(identifier), getStoredSchema(schema));\n\t}\n\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema,\n\t\trootFieldSchema: convertField(root.root),\n\t};\n\treturn result;\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(schema: SimpleFieldSchema): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types: TreeTypeSet = schema.allowedTypesIdentifiers as TreeTypeSet;\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(schema: SimpleNodeSchema): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map: {\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\tconst field = {\n\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\ttypes,\n\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t};\n\t\t\tconst fields = new Map([[EmptyKey, field]]);\n\t\t\treturn new ObjectNodeStoredSchema(fields, 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));\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}\n}\n"]}
1
+ {"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACpF,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,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAA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BAAsC,CAAC;YAC5D,OAAO,IAAI,mBAAmB,CAC7B;gBACC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,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,MAAM,KAAK,GAAG;gBACb,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU;gBACpC,KAAK;gBACL,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;aAC3C,CAAC;YACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,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,CAAC,CAAC,CAAC;YACrE,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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, 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 } from \"../util/index.js\";\n\nimport { NodeKind } from \"./core/index.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./schemaTypes.js\";\nimport type {\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleNodeSchemaBase,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<ImplicitFieldSchema, TreeStoredSchema>();\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn getOrCreate(viewToStoredCache, 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(schema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema),\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Converts a {@link SimpleTreeSchema} into a {@link TreeStoredSchema}.\n */\nexport function simpleToStoredSchema(root: SimpleTreeSchema): TreeStoredSchema {\n\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\tfor (const [identifier, schema] of root.definitions) {\n\t\tnodeSchema.set(brand(identifier), getStoredSchema(schema));\n\t}\n\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema,\n\t\trootFieldSchema: convertField(root.root),\n\t};\n\treturn result;\n}\n\n/**\n * Normalizes an {@link ImplicitFieldSchema} into a {@link TreeFieldSchema}.\n */\nexport function convertField(schema: SimpleFieldSchema): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types: TreeTypeSet = schema.allowedTypesIdentifiers as TreeTypeSet;\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(schema: SimpleNodeSchema): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\tassert(schema instanceof LeafNodeSchema, 0xa4a /* invalid kind */);\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\tconst field = {\n\t\t\t\tkind: FieldKinds.sequence.identifier,\n\t\t\t\ttypes,\n\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t};\n\t\t\tconst fields = new Map([[EmptyKey, field]]);\n\t\t\treturn new ObjectNodeStoredSchema(fields, 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));\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"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import type { IFluidHandle } from "@fluidframework/core-interfaces";
5
6
  import { type ImplicitFieldSchema } from "./schemaTypes.js";
6
7
  import { type TreeNode, type TreeNodeSchema, type Unhydrated, UnhydratedFlexTreeNode } from "./core/index.js";
7
- import type { IFluidHandle } from "@fluidframework/core-interfaces";
8
8
  /**
9
9
  * Module notes:
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"unhydratedFlexTreeFromInsertable.d.ts","sourceRoot":"","sources":["../../src/simple-tree/unhydratedFlexTreeFromInsertable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,OAAO,EAIN,KAAK,mBAAmB,EAMxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIN,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,sBAAsB,EAEtB,MAAM,iBAAiB,CAAC;AAOzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAMpE;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,SAAS,iBAAiB,GAAG,SAAS,EACzF,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,mBAAmB,GAC/B,GAAG,SAAS,SAAS,GAAG,SAAS,GAAG,sBAAsB,CAiB5D;AAkVD;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,EACzC,IAAI,EAAE,cAAc,GAClB,cAAc,EAAE,CAclB;AAyHD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB,YAAY,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GAEP,IAAI,GACJ,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC9C,SAAS,iBAAiB,EAAE,GAC5B,oBAAoB,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,iBAAiB;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MA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