@fluidframework/tree 2.12.0 → 2.13.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 (329) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/api-report/tree.alpha.api.md +86 -10
  3. package/api-report/tree.beta.api.md +22 -10
  4. package/api-report/tree.legacy.alpha.api.md +22 -10
  5. package/api-report/tree.legacy.public.api.md +22 -10
  6. package/api-report/tree.public.api.md +22 -10
  7. package/dist/alpha.d.ts +11 -0
  8. package/dist/beta.d.ts +2 -0
  9. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
  10. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  11. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  12. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  13. package/dist/feature-libraries/index.d.ts +0 -1
  14. package/dist/feature-libraries/index.d.ts.map +1 -1
  15. package/dist/feature-libraries/index.js +2 -4
  16. package/dist/feature-libraries/index.js.map +1 -1
  17. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
  18. package/dist/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  19. package/dist/feature-libraries/modular-schema/crossFieldQueries.js +8 -2
  20. package/dist/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  21. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
  22. package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  23. package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  24. package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  25. package/dist/feature-libraries/modular-schema/genericFieldKind.js +2 -1
  26. package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  27. package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
  28. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  29. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  30. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
  31. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  32. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
  33. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  34. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
  35. package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  36. package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  37. package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  38. package/dist/feature-libraries/optional-field/optionalField.js +24 -4
  39. package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
  40. package/dist/feature-libraries/sequence-field/utils.d.ts +2 -2
  41. package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  42. package/dist/feature-libraries/sequence-field/utils.js +14 -5
  43. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +2 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/legacy.d.ts +2 -0
  49. package/dist/packageVersion.d.ts +1 -1
  50. package/dist/packageVersion.js +1 -1
  51. package/dist/packageVersion.js.map +1 -1
  52. package/dist/public.d.ts +2 -0
  53. package/dist/shared-tree/index.d.ts +2 -1
  54. package/dist/shared-tree/index.d.ts.map +1 -1
  55. package/dist/shared-tree/index.js +2 -1
  56. package/dist/shared-tree/index.js.map +1 -1
  57. package/dist/shared-tree/schematizingTreeView.d.ts +10 -1
  58. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  59. package/dist/shared-tree/schematizingTreeView.js +43 -0
  60. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  61. package/dist/shared-tree/sharedTree.d.ts +6 -3
  62. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  63. package/dist/shared-tree/sharedTree.js +3 -1
  64. package/dist/shared-tree/sharedTree.js.map +1 -1
  65. package/dist/shared-tree/transactionTypes.d.ts +105 -0
  66. package/dist/shared-tree/transactionTypes.d.ts.map +1 -0
  67. package/dist/shared-tree/transactionTypes.js +13 -0
  68. package/dist/shared-tree/transactionTypes.js.map +1 -0
  69. package/dist/shared-tree/treeApi.d.ts +1 -25
  70. package/dist/shared-tree/treeApi.d.ts.map +1 -1
  71. package/dist/shared-tree/treeApi.js +4 -8
  72. package/dist/shared-tree/treeApi.js.map +1 -1
  73. package/dist/shared-tree/treeCheckout.d.ts +4 -1
  74. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  75. package/dist/shared-tree/treeCheckout.js +130 -15
  76. package/dist/shared-tree/treeCheckout.js.map +1 -1
  77. package/dist/shared-tree-core/sharedTreeCore.js +1 -1
  78. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  79. package/dist/simple-tree/api/index.d.ts +1 -0
  80. package/dist/simple-tree/api/index.d.ts.map +1 -1
  81. package/dist/simple-tree/api/index.js +3 -1
  82. package/dist/simple-tree/api/index.js.map +1 -1
  83. package/dist/simple-tree/api/jsonSchema.d.ts +6 -0
  84. package/dist/simple-tree/api/jsonSchema.d.ts.map +1 -1
  85. package/dist/simple-tree/api/jsonSchema.js.map +1 -1
  86. package/dist/simple-tree/api/schemaFactory.d.ts +21 -12
  87. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  88. package/dist/simple-tree/api/schemaFactory.js +5 -2
  89. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  90. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
  91. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
  92. package/dist/simple-tree/api/schemaFactoryAlpha.js +90 -0
  93. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
  94. package/dist/simple-tree/api/simpleSchema.d.ts +5 -1
  95. package/dist/simple-tree/api/simpleSchema.d.ts.map +1 -1
  96. package/dist/simple-tree/api/simpleSchema.js.map +1 -1
  97. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +13 -10
  98. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  99. package/dist/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  100. package/dist/simple-tree/api/tree.d.ts +60 -0
  101. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  102. package/dist/simple-tree/api/tree.js.map +1 -1
  103. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  104. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +11 -11
  105. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  106. package/dist/simple-tree/arrayNode.d.ts +2 -2
  107. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  108. package/dist/simple-tree/arrayNode.js +2 -1
  109. package/dist/simple-tree/arrayNode.js.map +1 -1
  110. package/dist/simple-tree/core/treeNodeSchema.d.ts +10 -6
  111. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  112. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  113. package/dist/simple-tree/index.d.ts +2 -2
  114. package/dist/simple-tree/index.d.ts.map +1 -1
  115. package/dist/simple-tree/index.js +3 -2
  116. package/dist/simple-tree/index.js.map +1 -1
  117. package/dist/simple-tree/leafNodeSchema.d.ts +5 -5
  118. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  119. package/dist/simple-tree/mapNode.d.ts +2 -2
  120. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  121. package/dist/simple-tree/mapNode.js +2 -1
  122. package/dist/simple-tree/mapNode.js.map +1 -1
  123. package/dist/simple-tree/objectNode.d.ts +2 -2
  124. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  125. package/dist/simple-tree/objectNode.js +2 -1
  126. package/dist/simple-tree/objectNode.js.map +1 -1
  127. package/dist/simple-tree/objectNodeTypes.d.ts +2 -2
  128. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  129. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  130. package/dist/simple-tree/schemaTypes.d.ts +47 -1
  131. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  132. package/dist/simple-tree/schemaTypes.js.map +1 -1
  133. package/dist/util/index.d.ts +2 -2
  134. package/dist/util/index.d.ts.map +1 -1
  135. package/dist/util/index.js +3 -5
  136. package/dist/util/index.js.map +1 -1
  137. package/dist/util/rangeMap.d.ts +72 -42
  138. package/dist/util/rangeMap.d.ts.map +1 -1
  139. package/dist/util/rangeMap.js +161 -151
  140. package/dist/util/rangeMap.js.map +1 -1
  141. package/dist/util/utils.d.ts +22 -1
  142. package/dist/util/utils.d.ts.map +1 -1
  143. package/dist/util/utils.js +10 -1
  144. package/dist/util/utils.js.map +1 -1
  145. package/lib/alpha.d.ts +11 -0
  146. package/lib/beta.d.ts +2 -0
  147. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +10 -0
  148. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  149. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
  150. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  151. package/lib/feature-libraries/index.d.ts +0 -1
  152. package/lib/feature-libraries/index.d.ts.map +1 -1
  153. package/lib/feature-libraries/index.js +0 -1
  154. package/lib/feature-libraries/index.js.map +1 -1
  155. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts +1 -1
  156. package/lib/feature-libraries/modular-schema/crossFieldQueries.d.ts.map +1 -1
  157. package/lib/feature-libraries/modular-schema/crossFieldQueries.js +9 -3
  158. package/lib/feature-libraries/modular-schema/crossFieldQueries.js.map +1 -1
  159. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +12 -5
  160. package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
  161. package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
  162. package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
  163. package/lib/feature-libraries/modular-schema/genericFieldKind.js +2 -1
  164. package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
  165. package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
  166. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  167. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  168. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +1 -0
  169. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  170. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +89 -25
  171. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  172. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +12 -0
  173. package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
  174. package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
  175. package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
  176. package/lib/feature-libraries/optional-field/optionalField.js +24 -4
  177. package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
  178. package/lib/feature-libraries/sequence-field/utils.d.ts +2 -2
  179. package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
  180. package/lib/feature-libraries/sequence-field/utils.js +14 -5
  181. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  182. package/lib/index.d.ts +2 -2
  183. package/lib/index.d.ts.map +1 -1
  184. package/lib/index.js +1 -1
  185. package/lib/index.js.map +1 -1
  186. package/lib/legacy.d.ts +2 -0
  187. package/lib/packageVersion.d.ts +1 -1
  188. package/lib/packageVersion.js +1 -1
  189. package/lib/packageVersion.js.map +1 -1
  190. package/lib/public.d.ts +2 -0
  191. package/lib/shared-tree/index.d.ts +2 -1
  192. package/lib/shared-tree/index.d.ts.map +1 -1
  193. package/lib/shared-tree/index.js +2 -1
  194. package/lib/shared-tree/index.js.map +1 -1
  195. package/lib/shared-tree/schematizingTreeView.d.ts +10 -1
  196. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  197. package/lib/shared-tree/schematizingTreeView.js +46 -3
  198. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  199. package/lib/shared-tree/sharedTree.d.ts +6 -3
  200. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  201. package/lib/shared-tree/sharedTree.js +3 -1
  202. package/lib/shared-tree/sharedTree.js.map +1 -1
  203. package/lib/shared-tree/transactionTypes.d.ts +105 -0
  204. package/lib/shared-tree/transactionTypes.d.ts.map +1 -0
  205. package/lib/shared-tree/transactionTypes.js +10 -0
  206. package/lib/shared-tree/transactionTypes.js.map +1 -0
  207. package/lib/shared-tree/treeApi.d.ts +1 -25
  208. package/lib/shared-tree/treeApi.d.ts.map +1 -1
  209. package/lib/shared-tree/treeApi.js +1 -5
  210. package/lib/shared-tree/treeApi.js.map +1 -1
  211. package/lib/shared-tree/treeCheckout.d.ts +4 -1
  212. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  213. package/lib/shared-tree/treeCheckout.js +130 -15
  214. package/lib/shared-tree/treeCheckout.js.map +1 -1
  215. package/lib/shared-tree-core/sharedTreeCore.js +1 -1
  216. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  217. package/lib/simple-tree/api/index.d.ts +1 -0
  218. package/lib/simple-tree/api/index.d.ts.map +1 -1
  219. package/lib/simple-tree/api/index.js +1 -0
  220. package/lib/simple-tree/api/index.js.map +1 -1
  221. package/lib/simple-tree/api/jsonSchema.d.ts +6 -0
  222. package/lib/simple-tree/api/jsonSchema.d.ts.map +1 -1
  223. package/lib/simple-tree/api/jsonSchema.js.map +1 -1
  224. package/lib/simple-tree/api/schemaFactory.d.ts +21 -12
  225. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  226. package/lib/simple-tree/api/schemaFactory.js +5 -2
  227. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  228. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +83 -0
  229. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -0
  230. package/lib/simple-tree/api/schemaFactoryAlpha.js +86 -0
  231. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -0
  232. package/lib/simple-tree/api/simpleSchema.d.ts +5 -1
  233. package/lib/simple-tree/api/simpleSchema.d.ts.map +1 -1
  234. package/lib/simple-tree/api/simpleSchema.js.map +1 -1
  235. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +14 -11
  236. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  237. package/lib/simple-tree/api/testRecursiveDomain.d.ts +5 -5
  238. package/lib/simple-tree/api/tree.d.ts +60 -0
  239. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  240. package/lib/simple-tree/api/tree.js.map +1 -1
  241. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  242. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +12 -12
  243. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  244. package/lib/simple-tree/arrayNode.d.ts +2 -2
  245. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  246. package/lib/simple-tree/arrayNode.js +2 -1
  247. package/lib/simple-tree/arrayNode.js.map +1 -1
  248. package/lib/simple-tree/core/treeNodeSchema.d.ts +10 -6
  249. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  250. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  251. package/lib/simple-tree/index.d.ts +2 -2
  252. package/lib/simple-tree/index.d.ts.map +1 -1
  253. package/lib/simple-tree/index.js +1 -1
  254. package/lib/simple-tree/index.js.map +1 -1
  255. package/lib/simple-tree/leafNodeSchema.d.ts +5 -5
  256. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  257. package/lib/simple-tree/mapNode.d.ts +2 -2
  258. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  259. package/lib/simple-tree/mapNode.js +2 -1
  260. package/lib/simple-tree/mapNode.js.map +1 -1
  261. package/lib/simple-tree/objectNode.d.ts +2 -2
  262. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  263. package/lib/simple-tree/objectNode.js +2 -1
  264. package/lib/simple-tree/objectNode.js.map +1 -1
  265. package/lib/simple-tree/objectNodeTypes.d.ts +2 -2
  266. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  267. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  268. package/lib/simple-tree/schemaTypes.d.ts +47 -1
  269. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  270. package/lib/simple-tree/schemaTypes.js.map +1 -1
  271. package/lib/util/index.d.ts +2 -2
  272. package/lib/util/index.d.ts.map +1 -1
  273. package/lib/util/index.js +2 -2
  274. package/lib/util/index.js.map +1 -1
  275. package/lib/util/rangeMap.d.ts +72 -42
  276. package/lib/util/rangeMap.d.ts.map +1 -1
  277. package/lib/util/rangeMap.js +159 -146
  278. package/lib/util/rangeMap.js.map +1 -1
  279. package/lib/util/utils.d.ts +22 -1
  280. package/lib/util/utils.d.ts.map +1 -1
  281. package/lib/util/utils.js +8 -0
  282. package/lib/util/utils.js.map +1 -1
  283. package/package.json +22 -22
  284. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +14 -1
  285. package/src/feature-libraries/index.ts +0 -1
  286. package/src/feature-libraries/modular-schema/crossFieldQueries.ts +9 -9
  287. package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +13 -9
  288. package/src/feature-libraries/modular-schema/genericFieldKind.ts +4 -2
  289. package/src/feature-libraries/modular-schema/index.ts +1 -0
  290. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +124 -31
  291. package/src/feature-libraries/modular-schema/modularChangeTypes.ts +12 -0
  292. package/src/feature-libraries/optional-field/optionalField.ts +34 -5
  293. package/src/feature-libraries/sequence-field/utils.ts +18 -7
  294. package/src/index.ts +11 -0
  295. package/src/packageVersion.ts +1 -1
  296. package/src/shared-tree/index.ts +12 -2
  297. package/src/shared-tree/schematizingTreeView.ts +91 -2
  298. package/src/shared-tree/sharedTree.ts +9 -4
  299. package/src/shared-tree/transactionTypes.ts +125 -0
  300. package/src/shared-tree/treeApi.ts +1 -28
  301. package/src/shared-tree/treeCheckout.ts +147 -13
  302. package/src/shared-tree-core/sharedTreeCore.ts +1 -1
  303. package/src/simple-tree/api/index.ts +1 -0
  304. package/src/simple-tree/api/jsonSchema.ts +7 -0
  305. package/src/simple-tree/api/schemaFactory.ts +33 -6
  306. package/src/simple-tree/api/schemaFactoryAlpha.ts +253 -0
  307. package/src/simple-tree/api/simpleSchema.ts +6 -1
  308. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +22 -12
  309. package/src/simple-tree/api/tree.ts +76 -4
  310. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +19 -13
  311. package/src/simple-tree/arrayNode.ts +7 -1
  312. package/src/simple-tree/core/treeNodeSchema.ts +51 -7
  313. package/src/simple-tree/index.ts +3 -0
  314. package/src/simple-tree/mapNode.ts +7 -1
  315. package/src/simple-tree/objectNode.ts +7 -1
  316. package/src/simple-tree/objectNodeTypes.ts +4 -1
  317. package/src/simple-tree/schemaTypes.ts +50 -1
  318. package/src/util/index.ts +2 -6
  319. package/src/util/rangeMap.ts +199 -189
  320. package/src/util/utils.ts +47 -1
  321. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
  322. package/dist/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
  323. package/dist/feature-libraries/memoizedIdRangeAllocator.js +0 -74
  324. package/dist/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
  325. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts +0 -38
  326. package/lib/feature-libraries/memoizedIdRangeAllocator.d.ts.map +0 -1
  327. package/lib/feature-libraries/memoizedIdRangeAllocator.js +0 -71
  328. package/lib/feature-libraries/memoizedIdRangeAllocator.js.map +0 -1
  329. package/src/feature-libraries/memoizedIdRangeAllocator.ts +0 -112
@@ -6,7 +6,7 @@
6
6
  import { unreachableCase } from "@fluidframework/core-utils/internal";
7
7
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
8
  import { ValueSchema } from "../../core/index.js";
9
- import { getOrCreate, hasSingle, type Mutable } from "../../util/index.js";
9
+ import { copyProperty, getOrCreate, hasSingle, type Mutable } from "../../util/index.js";
10
10
  import type {
11
11
  JsonArrayNodeSchema,
12
12
  JsonFieldSchema,
@@ -100,11 +100,15 @@ function convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSch
100
100
  ? allowedTypes[0]
101
101
  : { anyOf: allowedTypes };
102
102
 
103
- return {
103
+ const output: Mutable<JsonArrayNodeSchema> = {
104
104
  type: "array",
105
105
  _treeNodeSchemaKind: NodeKind.Array,
106
106
  items,
107
107
  };
108
+
109
+ copyProperty(schema.metadata, "description", output);
110
+
111
+ return output;
108
112
  }
109
113
 
110
114
  function convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {
@@ -137,9 +141,9 @@ function convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema
137
141
  function convertObjectNodeSchema(schema: SimpleObjectNodeSchema): JsonObjectNodeSchema {
138
142
  const properties: Record<string, JsonFieldSchema> = {};
139
143
  const required: string[] = [];
140
- for (const [key, value] of Object.entries(schema.fields)) {
144
+ for (const [key, fieldSchema] of Object.entries(schema.fields)) {
141
145
  const allowedTypes: JsonSchemaRef[] = [];
142
- for (const allowedType of value.allowedTypes) {
146
+ for (const allowedType of fieldSchema.allowedTypes) {
143
147
  allowedTypes.push(createSchemaRef(allowedType));
144
148
  }
145
149
 
@@ -149,24 +153,25 @@ function convertObjectNodeSchema(schema: SimpleObjectNodeSchema): JsonObjectNode
149
153
  anyOf: allowedTypes,
150
154
  };
151
155
 
152
- // Don't include "description" property at all if it's not present in the input.
153
- if (value.metadata?.description !== undefined) {
154
- output.description = value.metadata.description;
155
- }
156
-
156
+ copyProperty(fieldSchema.metadata, "description", output);
157
157
  properties[key] = output;
158
158
 
159
- if (value.kind === FieldKind.Required) {
159
+ if (fieldSchema.kind === FieldKind.Required) {
160
160
  required.push(key);
161
161
  }
162
162
  }
163
- return {
163
+
164
+ const transformedNode: Mutable<JsonObjectNodeSchema> = {
164
165
  type: "object",
165
166
  _treeNodeSchemaKind: NodeKind.Object,
166
167
  properties,
167
168
  required,
168
169
  additionalProperties: false,
169
170
  };
171
+
172
+ copyProperty(schema.metadata, "description", transformedNode);
173
+
174
+ return transformedNode;
170
175
  }
171
176
 
172
177
  function convertMapNodeSchema(schema: SimpleMapNodeSchema): JsonMapNodeSchema {
@@ -174,7 +179,8 @@ function convertMapNodeSchema(schema: SimpleMapNodeSchema): JsonMapNodeSchema {
174
179
  schema.allowedTypes.forEach((type) => {
175
180
  allowedTypes.push(createSchemaRef(type));
176
181
  });
177
- return {
182
+
183
+ const output: Mutable<JsonMapNodeSchema> = {
178
184
  type: "object",
179
185
  _treeNodeSchemaKind: NodeKind.Map,
180
186
  patternProperties: {
@@ -185,6 +191,10 @@ function convertMapNodeSchema(schema: SimpleMapNodeSchema): JsonMapNodeSchema {
185
191
  },
186
192
  },
187
193
  };
194
+
195
+ copyProperty(schema.metadata, "description", output);
196
+
197
+ return output;
188
198
  }
189
199
 
190
200
  function createSchemaRef(schemaId: string): JsonSchemaRef {
@@ -12,9 +12,16 @@ import type {
12
12
  RevertibleFactory,
13
13
  } from "../../core/index.js";
14
14
 
15
- // This is referenced by doc comments.
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports
17
- import type { TreeAlpha } from "../../shared-tree/index.js";
15
+ import type {
16
+ RunTransactionParams,
17
+ VoidTransactionCallbackStatus,
18
+ TransactionCallbackStatus,
19
+ TransactionResult,
20
+ TransactionResultExt,
21
+ // This is referenced by doc comments.
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports
23
+ TreeAlpha,
24
+ } from "../../shared-tree/index.js";
18
25
 
19
26
  import {
20
27
  type ImplicitFieldSchema,
@@ -35,7 +42,6 @@ import { markSchemaMostDerived } from "./schemaFactory.js";
35
42
  import { fail, getOrCreate } from "../../util/index.js";
36
43
  import type { MakeNominal } from "../../util/index.js";
37
44
  import { walkFieldSchema } from "../walkFieldSchema.js";
38
-
39
45
  /**
40
46
  * A tree from which a {@link TreeView} can be created.
41
47
  *
@@ -542,6 +548,72 @@ export interface TreeViewAlpha<
542
548
 
543
549
  // Override the base branch method to return a typed view rather than merely a branch.
544
550
  fork(): ReturnType<TreeBranch["fork"]> & TreeViewAlpha<TSchema>;
551
+
552
+ /**
553
+ * Run a transaction which applies one or more edits to the tree as a single atomic unit.
554
+ * @param transaction - The function to run as the body of the transaction.
555
+ * It should return a status object of {@link TransactionCallbackStatus | TransactionCallbackStatus } type.
556
+ * It includes a "rollback" property which may be returned as true at any point during the transaction. This will
557
+ * abort the transaction and discard any changes it made so far.
558
+ * "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
559
+ * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
560
+ * @returns A result object of {@link TransactionResultExt | TransactionResultExt} type. It includes the following:
561
+ * - A "success" flag indicating whether the transaction was successful or not.
562
+ * - The success of failure value as returned by the transaction function.
563
+ * @remarks
564
+ * This API will throw an error if the constraints are not met or something unexpected happens.
565
+ * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
566
+ * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
567
+ * However, using a transaction has the following additional consequences:
568
+ * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
569
+ * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
570
+ *
571
+ * Local change events will be emitted for each change as the transaction is being applied.
572
+ * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
573
+ *
574
+ * Nested transactions:
575
+ * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
576
+ * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
577
+ * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
578
+ * for the outermost transaction which includes all inner transactions.
579
+ * - Undo will undo the outermost transaction and all inner transactions.
580
+ */
581
+ runTransaction<TSuccessValue, TFailureValue>(
582
+ transaction: () => TransactionCallbackStatus<TSuccessValue, TFailureValue>,
583
+ params?: RunTransactionParams,
584
+ ): TransactionResultExt<TSuccessValue, TFailureValue>;
585
+ /**
586
+ * Run a transaction which applies one or more edits to the tree as a single atomic unit.
587
+ * @param transaction - The function to run as the body of the transaction. It may return the following:
588
+ * - Nothing to indicate that the body of the transaction has successfully run.
589
+ * - A status object of {@link VoidTransactionCallbackStatus | VoidTransactionCallbackStatus } type. It includes a "rollback" property which
590
+ * may be returned as true at any point during the transaction. This will abort the transaction and discard any changes it made so
591
+ * far. "rollback" can be set to false or left undefined to indicate that the body of the transaction has successfully run.
592
+ * @param params - The optional parameters for the transaction. It includes the constraints that will be checked before the transaction begins.
593
+ * @returns A result object of {@link TransactionResult | TransactionResult} type. It includes a "success" flag indicating whether the
594
+ * transaction was successful or not.
595
+ * @remarks
596
+ * This API will throw an error if the constraints are not met or something unexpected happens.
597
+ * All of the changes in the transaction are applied synchronously and therefore no other changes (either from this client or from a remote client) can be interleaved with those changes.
598
+ * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
599
+ * However, using a transaction has the following additional consequences:
600
+ * - If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together.
601
+ * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
602
+ *
603
+ * Local change events will be emitted for each change as the transaction is being applied.
604
+ * If the transaction is rolled back, a corresponding change event will also be emitted for the rollback.
605
+ *
606
+ * Nested transactions:
607
+ * This API can be called from within the transaction callback of another runTransaction call. That will have slightly different behavior:
608
+ * - If the inner transaction fails, only the inner transaction will be rolled back and the outer transaction will continue.
609
+ * - Constraints will apply to the outermost transaction. Constraints are applied per commit and there will be one commit generated
610
+ * for the outermost transaction which includes all inner transactions.
611
+ * - Undo will undo the outermost transaction and all inner transactions.
612
+ */
613
+ runTransaction(
614
+ transaction: () => VoidTransactionCallbackStatus | void,
615
+ params?: RunTransactionParams,
616
+ ): TransactionResult;
545
617
  }
546
618
 
547
619
  /**
@@ -20,7 +20,7 @@ import type {
20
20
  SimpleTreeSchema,
21
21
  } from "./simpleSchema.js";
22
22
  import type { ValueSchema } from "../../core/index.js";
23
- import { getOrCreate, type Mutable } from "../../util/index.js";
23
+ import { copyProperty, getOrCreate, type Mutable } from "../../util/index.js";
24
24
  import { isObjectNodeSchema, type ObjectNodeSchema } from "../objectNodeTypes.js";
25
25
  import { NodeKind, type TreeNodeSchema } from "../core/index.js";
26
26
 
@@ -41,11 +41,7 @@ export function toSimpleTreeSchema(schema: ImplicitFieldSchema): SimpleTreeSchem
41
41
  definitions,
42
42
  };
43
43
 
44
- // Include the "description" property only if it's present on the input.
45
- if (normalizedSchema.metadata !== undefined) {
46
- output.metadata = normalizedSchema.metadata;
47
- }
48
-
44
+ copyProperty(normalizedSchema, "metadata", output);
49
45
  return output;
50
46
  }
51
47
 
@@ -95,20 +91,28 @@ function leafSchemaToSimpleSchema(schema: TreeNodeSchema): SimpleLeafNodeSchema
95
91
  function arraySchemaToSimpleSchema(schema: TreeNodeSchema): SimpleArrayNodeSchema {
96
92
  const fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);
97
93
  const allowedTypes = allowedTypesFromFieldSchema(fieldSchema);
98
- return {
94
+ const output: Mutable<SimpleArrayNodeSchema> = {
99
95
  kind: NodeKind.Array,
100
96
  allowedTypes,
101
97
  };
98
+
99
+ copyProperty(schema, "metadata", output);
100
+
101
+ return output;
102
102
  }
103
103
 
104
104
  // TODO: Use a stronger type for map schemas once one is available (see object schema handler for an example).
105
105
  function mapSchemaToSimpleSchema(schema: TreeNodeSchema): SimpleMapNodeSchema {
106
106
  const fieldSchema = normalizeFieldSchema(schema.info as ImplicitAllowedTypes);
107
107
  const allowedTypes = allowedTypesFromFieldSchema(fieldSchema);
108
- return {
108
+ const output: Mutable<SimpleMapNodeSchema> = {
109
109
  kind: NodeKind.Map,
110
110
  allowedTypes,
111
111
  };
112
+
113
+ copyProperty(schema, "metadata", output);
114
+
115
+ return output;
112
116
  }
113
117
 
114
118
  function objectSchemaToSimpleSchema(schema: ObjectNodeSchema): SimpleObjectNodeSchema {
@@ -116,10 +120,15 @@ function objectSchemaToSimpleSchema(schema: ObjectNodeSchema): SimpleObjectNodeS
116
120
  for (const [key, field] of schema.fields) {
117
121
  fields[key] = fieldSchemaToSimpleSchema(field);
118
122
  }
119
- return {
123
+
124
+ const output: Mutable<SimpleObjectNodeSchema> = {
120
125
  kind: NodeKind.Object,
121
126
  fields,
122
127
  };
128
+
129
+ copyProperty(schema, "metadata", output);
130
+
131
+ return output;
123
132
  }
124
133
 
125
134
  /**
@@ -140,10 +149,7 @@ function fieldSchemaToSimpleSchema(schema: FieldSchema): SimpleFieldSchema {
140
149
  allowedTypes,
141
150
  };
142
151
 
143
- // Don't include "metadata" property at all if it's not present.
144
- if (schema.metadata !== undefined) {
145
- result.metadata = schema.metadata;
146
- }
152
+ copyProperty(schema, "metadata", result);
147
153
 
148
154
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
149
155
  (schema as any)[simpleFieldSchemaCacheSymbol] = result;
@@ -18,6 +18,7 @@ import {
18
18
  normalizeAllowedTypes,
19
19
  type ImplicitAllowedTypes,
20
20
  type InsertableTreeNodeFromImplicitAllowedTypes,
21
+ type NodeSchemaMetadata,
21
22
  type TreeLeafValue,
22
23
  type TreeNodeFromImplicitAllowedTypes,
23
24
  } from "./schemaTypes.js";
@@ -1062,11 +1063,13 @@ export function arraySchema<
1062
1063
  TName extends string,
1063
1064
  const T extends ImplicitAllowedTypes,
1064
1065
  const ImplicitlyConstructable extends boolean,
1066
+ const TCustomMetadata = unknown,
1065
1067
  >(
1066
1068
  identifier: TName,
1067
1069
  info: T,
1068
1070
  implicitlyConstructable: ImplicitlyConstructable,
1069
1071
  customizable: boolean,
1072
+ metadata?: NodeSchemaMetadata<TCustomMetadata>,
1070
1073
  ) {
1071
1074
  type Output = TreeNodeSchemaBoth<
1072
1075
  TName,
@@ -1075,7 +1078,8 @@ export function arraySchema<
1075
1078
  Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
1076
1079
  ImplicitlyConstructable,
1077
1080
  T,
1078
- undefined
1081
+ undefined,
1082
+ TCustomMetadata
1079
1083
  >;
1080
1084
 
1081
1085
  const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(info));
@@ -1157,6 +1161,8 @@ export function arraySchema<
1157
1161
  public static get childTypes(): ReadonlySet<TreeNodeSchema> {
1158
1162
  return lazyChildTypes.value;
1159
1163
  }
1164
+ public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> | undefined =
1165
+ metadata;
1160
1166
 
1161
1167
  // eslint-disable-next-line import/no-deprecated
1162
1168
  public get [typeNameSymbol](): TName {
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import type { TreeLeafValue } from "../schemaTypes.js";
6
+ import type { NodeSchemaMetadata, TreeLeafValue } from "../schemaTypes.js";
7
7
  import type { InternalTreeNode, TreeNode, Unhydrated } from "./types.js";
8
8
 
9
9
  /**
@@ -27,11 +27,30 @@ export type TreeNodeSchema<
27
27
  TBuild = never,
28
28
  ImplicitlyConstructable extends boolean = boolean,
29
29
  Info = unknown,
30
+ TCustomMetadata = unknown,
30
31
  > =
31
32
  | (TNode extends TreeNode
32
- ? TreeNodeSchemaClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>
33
+ ? TreeNodeSchemaClass<
34
+ Name,
35
+ Kind,
36
+ TNode,
37
+ TBuild,
38
+ ImplicitlyConstructable,
39
+ Info,
40
+ never,
41
+ TCustomMetadata
42
+ >
33
43
  : never)
34
- | TreeNodeSchemaNonClass<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>;
44
+ | TreeNodeSchemaNonClass<
45
+ Name,
46
+ Kind,
47
+ TNode,
48
+ TBuild,
49
+ ImplicitlyConstructable,
50
+ Info,
51
+ never,
52
+ TCustomMetadata
53
+ >;
35
54
 
36
55
  /**
37
56
  * Schema which is not a class.
@@ -49,7 +68,15 @@ export type TreeNodeSchemaNonClass<
49
68
  ImplicitlyConstructable extends boolean = boolean,
50
69
  Info = unknown,
51
70
  TConstructorExtra = never,
52
- > = TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info, TInsertable> &
71
+ TCustomMetadata = unknown,
72
+ > = TreeNodeSchemaCore<
73
+ Name,
74
+ Kind,
75
+ ImplicitlyConstructable,
76
+ Info,
77
+ TInsertable,
78
+ TCustomMetadata
79
+ > &
53
80
  (undefined extends TConstructorExtra
54
81
  ? {
55
82
  /**
@@ -119,7 +146,15 @@ export type TreeNodeSchemaClass<
119
146
  ImplicitlyConstructable extends boolean = boolean,
120
147
  Info = unknown,
121
148
  TConstructorExtra = never,
122
- > = TreeNodeSchemaCore<Name, Kind, ImplicitlyConstructable, Info, TInsertable> &
149
+ TCustomMetadata = unknown,
150
+ > = TreeNodeSchemaCore<
151
+ Name,
152
+ Kind,
153
+ ImplicitlyConstructable,
154
+ Info,
155
+ TInsertable,
156
+ TCustomMetadata
157
+ > &
123
158
  (undefined extends TConstructorExtra
124
159
  ? {
125
160
  /**
@@ -157,6 +192,7 @@ export type TreeNodeSchemaBoth<
157
192
  ImplicitlyConstructable extends boolean = boolean,
158
193
  Info = unknown,
159
194
  TConstructorExtra = never,
195
+ TCustomMetadata = unknown,
160
196
  > = TreeNodeSchemaClass<
161
197
  Name,
162
198
  Kind,
@@ -164,7 +200,8 @@ export type TreeNodeSchemaBoth<
164
200
  TInsertable,
165
201
  ImplicitlyConstructable,
166
202
  Info,
167
- TConstructorExtra
203
+ TConstructorExtra,
204
+ TCustomMetadata
168
205
  > &
169
206
  TreeNodeSchemaNonClass<
170
207
  Name,
@@ -173,7 +210,8 @@ export type TreeNodeSchemaBoth<
173
210
  TInsertable,
174
211
  ImplicitlyConstructable,
175
212
  Info,
176
- TConstructorExtra
213
+ TConstructorExtra,
214
+ TCustomMetadata
177
215
  >;
178
216
 
179
217
  /**
@@ -188,6 +226,7 @@ export interface TreeNodeSchemaCore<
188
226
  out ImplicitlyConstructable extends boolean,
189
227
  out Info = unknown,
190
228
  out TInsertable = never,
229
+ out TCustomMetadata = unknown,
191
230
  > {
192
231
  /**
193
232
  * Unique (within a document's schema) identifier used to associate nodes with their schema.
@@ -244,6 +283,11 @@ export interface TreeNodeSchemaCore<
244
283
  */
245
284
  readonly childTypes: ReadonlySet<TreeNodeSchema>;
246
285
 
286
+ /**
287
+ * User-provided {@link NodeSchemaMetadata} for this schema.
288
+ */
289
+ readonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;
290
+
247
291
  /**
248
292
  * Constructs an instance of this node type.
249
293
  * @remarks
@@ -35,6 +35,7 @@ export {
35
35
  type SchemaCompatibilityStatus,
36
36
  type ITreeConfigurationOptions,
37
37
  SchemaFactory,
38
+ SchemaFactoryAlpha,
38
39
  type SchemaFactoryObjectOptions,
39
40
  type ScopedSchemaName,
40
41
  type ValidateRecursiveSchema,
@@ -155,6 +156,8 @@ export {
155
156
  type Input,
156
157
  type ReadableField,
157
158
  type ReadSchema,
159
+ type NodeSchemaOptions,
160
+ type NodeSchemaMetadata,
158
161
  } from "./schemaTypes.js";
159
162
  export {
160
163
  getTreeNodeForField,
@@ -17,6 +17,7 @@ import {
17
17
  normalizeAllowedTypes,
18
18
  type ImplicitAllowedTypes,
19
19
  type InsertableTreeNodeFromImplicitAllowedTypes,
20
+ type NodeSchemaMetadata,
20
21
  type TreeNodeFromImplicitAllowedTypes,
21
22
  } from "./schemaTypes.js";
22
23
  import {
@@ -235,11 +236,13 @@ export function mapSchema<
235
236
  TName extends string,
236
237
  const T extends ImplicitAllowedTypes,
237
238
  const ImplicitlyConstructable extends boolean,
239
+ const TCustomMetadata = unknown,
238
240
  >(
239
241
  identifier: TName,
240
242
  info: T,
241
243
  implicitlyConstructable: ImplicitlyConstructable,
242
244
  useMapPrototype: boolean,
245
+ metadata?: NodeSchemaMetadata<TCustomMetadata>,
243
246
  ) {
244
247
  const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(info));
245
248
 
@@ -283,6 +286,8 @@ export function mapSchema<
283
286
  public static get childTypes(): ReadonlySet<TreeNodeSchema> {
284
287
  return lazyChildTypes.value;
285
288
  }
289
+ public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> | undefined =
290
+ metadata;
286
291
 
287
292
  // eslint-disable-next-line import/no-deprecated
288
293
  public get [typeNameSymbol](): TName {
@@ -299,7 +304,8 @@ export function mapSchema<
299
304
  MapNodeInsertableData<T>,
300
305
  ImplicitlyConstructable,
301
306
  T,
302
- undefined
307
+ undefined,
308
+ TCustomMetadata
303
309
  > = Schema;
304
310
  return schemaErased;
305
311
  }
@@ -26,6 +26,7 @@ import {
26
26
  normalizeFieldSchema,
27
27
  type ImplicitAllowedTypes,
28
28
  FieldKind,
29
+ type NodeSchemaMetadata,
29
30
  } from "./schemaTypes.js";
30
31
  import {
31
32
  type TreeNodeSchema,
@@ -330,12 +331,15 @@ export function objectSchema<
330
331
  TName extends string,
331
332
  const T extends RestrictiveStringRecord<ImplicitFieldSchema>,
332
333
  const ImplicitlyConstructable extends boolean,
334
+ const TCustomMetadata = unknown,
333
335
  >(
334
336
  identifier: TName,
335
337
  info: T,
336
338
  implicitlyConstructable: ImplicitlyConstructable,
337
339
  allowUnknownOptionalFields: boolean,
338
- ): ObjectNodeSchema<TName, T, ImplicitlyConstructable> & ObjectNodeSchemaInternalData {
340
+ metadata?: NodeSchemaMetadata<TCustomMetadata>,
341
+ ): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &
342
+ ObjectNodeSchemaInternalData {
339
343
  // Ensure no collisions between final set of property keys, and final set of stored keys (including those
340
344
  // implicitly derived from property keys)
341
345
  assertUniqueKeys(identifier, info);
@@ -460,6 +464,8 @@ export function objectSchema<
460
464
  public static get childTypes(): ReadonlySet<TreeNodeSchema> {
461
465
  return lazyChildTypes.value;
462
466
  }
467
+ public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> | undefined =
468
+ metadata;
463
469
 
464
470
  // eslint-disable-next-line import/no-deprecated
465
471
  public get [typeNameSymbol](): TName {
@@ -23,13 +23,16 @@ export interface ObjectNodeSchema<
23
23
  T extends
24
24
  RestrictiveStringRecord<ImplicitFieldSchema> = RestrictiveStringRecord<ImplicitFieldSchema>,
25
25
  ImplicitlyConstructable extends boolean = boolean,
26
+ TCustomMetadata = unknown,
26
27
  > extends TreeNodeSchemaClass<
27
28
  TName,
28
29
  NodeKind.Object,
29
30
  TreeObjectNode<T, TName>,
30
31
  object & InsertableObjectFromSchemaRecord<T>,
31
32
  ImplicitlyConstructable,
32
- T
33
+ T,
34
+ never,
35
+ TCustomMetadata
33
36
  > {
34
37
  /**
35
38
  * From property keys to the associated schema.
@@ -190,7 +190,10 @@ export interface FieldProps<TCustomMetadata = unknown> {
190
190
 
191
191
  /**
192
192
  * Optional metadata to associate with the field.
193
- * @remarks Note: this metadata is not persisted in the document.
193
+ *
194
+ * @remarks
195
+ * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.
196
+ * Different clients in the same collaborative session may see different metadata for the same field.
194
197
  */
195
198
  readonly metadata?: FieldSchemaMetadata<TCustomMetadata>;
196
199
  }
@@ -824,3 +827,49 @@ export type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boole
824
827
  */
825
828
  // eslint-disable-next-line @rushstack/no-new-null
826
829
  export type TreeLeafValue = number | string | boolean | IFluidHandle | null;
830
+
831
+ /**
832
+ * Additional information to provide to Node Schema creation.
833
+ *
834
+ * @typeParam TCustomMetadata - Custom metadata properties to associate with the Node Schema.
835
+ * See {@link NodeSchemaMetadata.custom}.
836
+ *
837
+ * @sealed
838
+ * @public
839
+ */
840
+ export interface NodeSchemaOptions<out TCustomMetadata = unknown> {
841
+ /**
842
+ * Optional metadata to associate with the Node Schema.
843
+ *
844
+ * @remarks
845
+ * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.
846
+ * Different clients in the same collaborative session may see different metadata for the same field.
847
+ */
848
+ readonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;
849
+ }
850
+
851
+ /**
852
+ * Metadata associated with a Node Schema.
853
+ *
854
+ * @remarks Specified via {@link NodeSchemaOptions.metadata}.
855
+ *
856
+ * @sealed
857
+ * @public
858
+ */
859
+ export interface NodeSchemaMetadata<out TCustomMetadata = unknown> {
860
+ /**
861
+ * User-defined metadata.
862
+ */
863
+ readonly custom?: TCustomMetadata | undefined;
864
+
865
+ /**
866
+ * The description of the Node Schema.
867
+ *
868
+ * @remarks
869
+ *
870
+ * If provided, will be used by the system in scenarios where a description of the kind of node is useful.
871
+ * E.g., when converting a Node Schema to {@link https://json-schema.org/ | JSON Schema}, this description will be
872
+ * used as the `description` property.
873
+ */
874
+ readonly description?: string | undefined;
875
+ }
package/src/util/index.ts CHANGED
@@ -94,6 +94,7 @@ export {
94
94
  hasSome,
95
95
  hasSingle,
96
96
  defineLazyCachedProperty,
97
+ copyPropertyIfDefined as copyProperty,
97
98
  } from "./utils.js";
98
99
  export { ReferenceCountedBase, type ReferenceCounted } from "./referenceCounting.js";
99
100
 
@@ -120,13 +121,8 @@ export {
120
121
  } from "./brandedMap.js";
121
122
 
122
123
  export {
123
- getFirstEntryFromRangeMap,
124
- getFromRangeMap,
125
- type RangeEntry,
126
- type RangeMap,
124
+ RangeMap,
127
125
  type RangeQueryResult,
128
- setInRangeMap,
129
- deleteFromRangeMap,
130
126
  } from "./rangeMap.js";
131
127
 
132
128
  export {