@fluidframework/tree 2.30.0 → 2.31.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 (660) hide show
  1. package/CHANGELOG.md +1632 -1500
  2. package/api-extractor/api-extractor.current.json +0 -3
  3. package/api-report/tree.alpha.api.md +233 -88
  4. package/api-report/tree.beta.api.md +86 -61
  5. package/api-report/tree.legacy.alpha.api.md +86 -61
  6. package/api-report/tree.legacy.public.api.md +86 -61
  7. package/api-report/tree.public.api.md +86 -61
  8. package/dist/alpha.d.ts +26 -1
  9. package/dist/beta.d.ts +5 -1
  10. package/dist/codec/codec.d.ts +1 -1
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +3 -4
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/discriminatedUnions.d.ts.map +1 -1
  15. package/dist/codec/discriminatedUnions.js +1 -1
  16. package/dist/codec/discriminatedUnions.js.map +1 -1
  17. package/dist/core/rebase/utils.js +1 -1
  18. package/dist/core/rebase/utils.js.map +1 -1
  19. package/dist/core/schema-stored/schema.d.ts +4 -1
  20. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  21. package/dist/core/schema-stored/schema.js +8 -4
  22. package/dist/core/schema-stored/schema.js.map +1 -1
  23. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  24. package/dist/core/tree/anchorSet.js +4 -4
  25. package/dist/core/tree/anchorSet.js.map +1 -1
  26. package/dist/core/tree/treeTextFormat.js +2 -2
  27. package/dist/core/tree/treeTextFormat.js.map +1 -1
  28. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  29. package/dist/feature-libraries/chunked-forest/basicChunk.js +8 -8
  30. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  31. package/dist/feature-libraries/chunked-forest/chunkTree.js +2 -2
  32. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  33. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  34. package/dist/feature-libraries/chunked-forest/chunkedForest.js +3 -3
  35. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  36. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +3 -3
  37. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  38. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  39. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  40. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  41. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  42. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  43. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +3 -4
  44. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  45. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  46. package/dist/feature-libraries/chunked-forest/emptyChunk.js +15 -15
  47. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  48. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  49. package/dist/feature-libraries/chunked-forest/uniformChunk.js +4 -4
  50. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  51. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  52. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +19 -19
  53. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  54. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  55. package/dist/feature-libraries/default-schema/schemaChecker.js +1 -2
  56. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  57. package/dist/feature-libraries/flex-tree/lazyField.js +3 -3
  58. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  59. package/dist/feature-libraries/flex-tree/lazyNode.js +4 -4
  60. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  61. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  62. package/dist/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  63. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  64. package/dist/feature-libraries/modular-schema/comparison.js +4 -4
  65. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  66. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  67. package/dist/feature-libraries/modular-schema/isNeverTree.js +2 -3
  68. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  69. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  70. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
  71. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  72. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  73. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +4 -4
  74. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  75. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
  76. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  77. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  78. package/dist/feature-libraries/object-forest/objectForest.js +1 -1
  79. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  80. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  81. package/dist/feature-libraries/schema-index/codec.js +2 -1
  82. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  83. package/dist/feature-libraries/sequence-field/compose.d.ts +1 -1
  84. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  85. package/dist/feature-libraries/sequence-field/compose.js +16 -17
  86. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  87. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  88. package/dist/feature-libraries/sequence-field/invert.js +1 -1
  89. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  90. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  91. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  92. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  93. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  94. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  95. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  96. package/dist/feature-libraries/sequence-field/utils.js +1 -1
  97. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  98. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  99. package/dist/feature-libraries/treeCursorUtils.js +4 -5
  100. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  101. package/dist/index.d.ts +4 -3
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +8 -4
  104. package/dist/index.js.map +1 -1
  105. package/dist/jsonDomainSchema.d.ts +15 -16
  106. package/dist/jsonDomainSchema.d.ts.map +1 -1
  107. package/dist/jsonDomainSchema.js +10 -5
  108. package/dist/jsonDomainSchema.js.map +1 -1
  109. package/dist/legacy.d.ts +5 -1
  110. package/dist/packageVersion.d.ts +1 -1
  111. package/dist/packageVersion.js +1 -1
  112. package/dist/packageVersion.js.map +1 -1
  113. package/dist/public.d.ts +5 -1
  114. package/dist/serializableDomainSchema.d.ts +8 -14
  115. package/dist/serializableDomainSchema.d.ts.map +1 -1
  116. package/dist/shared-tree/schematizeTree.js +1 -1
  117. package/dist/shared-tree/schematizeTree.js.map +1 -1
  118. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  119. package/dist/shared-tree/sharedTree.js +16 -12
  120. package/dist/shared-tree/sharedTree.js.map +1 -1
  121. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  122. package/dist/shared-tree/sharedTreeChangeFamily.js +1 -1
  123. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  124. package/dist/shared-tree/treeApiAlpha.d.ts +6 -2
  125. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  126. package/dist/shared-tree/treeApiAlpha.js +20 -17
  127. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  128. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  129. package/dist/shared-tree/treeCheckout.js +1 -1
  130. package/dist/shared-tree/treeCheckout.js.map +1 -1
  131. package/dist/shared-tree-core/branch.d.ts +4 -3
  132. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  133. package/dist/shared-tree-core/branch.js +2 -2
  134. package/dist/shared-tree-core/branch.js.map +1 -1
  135. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  136. package/dist/shared-tree-core/editManager.js +37 -31
  137. package/dist/shared-tree-core/editManager.js.map +1 -1
  138. package/dist/sharedTreeAttributes.d.ts +18 -0
  139. package/dist/sharedTreeAttributes.d.ts.map +1 -0
  140. package/dist/sharedTreeAttributes.js +25 -0
  141. package/dist/sharedTreeAttributes.js.map +1 -0
  142. package/dist/simple-tree/api/customTree.js +3 -3
  143. package/dist/simple-tree/api/customTree.js.map +1 -1
  144. package/dist/simple-tree/api/getJsonSchema.d.ts +10 -0
  145. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  146. package/dist/simple-tree/api/getJsonSchema.js +10 -0
  147. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  148. package/dist/simple-tree/api/getSimpleSchema.d.ts +13 -43
  149. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  150. package/dist/simple-tree/api/getSimpleSchema.js +13 -43
  151. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  152. package/dist/simple-tree/api/index.d.ts +3 -3
  153. package/dist/simple-tree/api/index.d.ts.map +1 -1
  154. package/dist/simple-tree/api/index.js +3 -1
  155. package/dist/simple-tree/api/index.js.map +1 -1
  156. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  157. package/dist/simple-tree/api/schemaCreationUtilities.js +2 -2
  158. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  159. package/dist/simple-tree/api/schemaFactory.d.ts +100 -58
  160. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  161. package/dist/simple-tree/api/schemaFactory.js +65 -133
  162. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  163. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +31 -23
  164. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  165. package/dist/simple-tree/api/schemaFactoryAlpha.js +17 -1
  166. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  167. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  168. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  169. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  170. package/dist/simple-tree/api/schemaFromSimple.d.ts +4 -4
  171. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  172. package/dist/simple-tree/api/schemaFromSimple.js +26 -15
  173. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  174. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  175. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  176. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +7 -6
  177. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  178. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  179. package/dist/simple-tree/api/simpleTreeIndex.js +4 -3
  180. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  181. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  182. package/dist/simple-tree/api/tree.d.ts +1 -1
  183. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  184. package/dist/simple-tree/api/tree.js +6 -6
  185. package/dist/simple-tree/api/tree.js.map +1 -1
  186. package/dist/simple-tree/api/treeNodeApi.js +3 -3
  187. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  188. package/dist/simple-tree/api/typesUnsafe.d.ts +87 -21
  189. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  190. package/dist/simple-tree/api/typesUnsafe.js +0 -1
  191. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  192. package/dist/simple-tree/api/verboseTree.js +4 -4
  193. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  194. package/dist/simple-tree/api/view.d.ts.map +1 -1
  195. package/dist/simple-tree/api/view.js +16 -17
  196. package/dist/simple-tree/api/view.js.map +1 -1
  197. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  198. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  199. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +70 -147
  200. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  201. package/dist/simple-tree/arrayNode.d.ts +5 -4
  202. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  203. package/dist/simple-tree/arrayNode.js +13 -9
  204. package/dist/simple-tree/arrayNode.js.map +1 -1
  205. package/dist/simple-tree/arrayNodeTypes.d.ts +46 -0
  206. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  207. package/dist/simple-tree/arrayNodeTypes.js +30 -0
  208. package/dist/simple-tree/arrayNodeTypes.js.map +1 -0
  209. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  210. package/dist/simple-tree/core/getOrCreateNode.js +1 -11
  211. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  212. package/dist/simple-tree/core/index.d.ts +1 -2
  213. package/dist/simple-tree/core/index.d.ts.map +1 -1
  214. package/dist/simple-tree/core/index.js +2 -3
  215. package/dist/simple-tree/core/index.js.map +1 -1
  216. package/dist/simple-tree/core/treeNodeKernel.d.ts +12 -5
  217. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  218. package/dist/simple-tree/core/treeNodeKernel.js +36 -20
  219. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  220. package/dist/simple-tree/core/treeNodeSchema.d.ts +14 -7
  221. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  222. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  223. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -5
  224. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  225. package/dist/simple-tree/index.d.ts +9 -2
  226. package/dist/simple-tree/index.d.ts.map +1 -1
  227. package/dist/simple-tree/index.js +9 -1
  228. package/dist/simple-tree/index.js.map +1 -1
  229. package/dist/simple-tree/leafNodeSchema.d.ts +22 -5
  230. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  231. package/dist/simple-tree/leafNodeSchema.js +2 -0
  232. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  233. package/dist/simple-tree/mapNode.d.ts +3 -2
  234. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  235. package/dist/simple-tree/mapNode.js +5 -1
  236. package/dist/simple-tree/mapNode.js.map +1 -1
  237. package/dist/simple-tree/mapNodeTypes.d.ts +46 -0
  238. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -0
  239. package/dist/simple-tree/mapNodeTypes.js +30 -0
  240. package/dist/simple-tree/mapNodeTypes.js.map +1 -0
  241. package/dist/simple-tree/objectNode.d.ts +10 -3
  242. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  243. package/dist/simple-tree/objectNode.js +10 -5
  244. package/dist/simple-tree/objectNode.js.map +1 -1
  245. package/dist/simple-tree/objectNodeTypes.d.ts +9 -5
  246. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  247. package/dist/simple-tree/objectNodeTypes.js +3 -0
  248. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  249. package/dist/simple-tree/proxies.js +2 -1
  250. package/dist/simple-tree/proxies.js.map +1 -1
  251. package/dist/simple-tree/schemaTypes.d.ts +47 -6
  252. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  253. package/dist/simple-tree/schemaTypes.js +40 -4
  254. package/dist/simple-tree/schemaTypes.js.map +1 -1
  255. package/dist/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +54 -30
  256. package/dist/simple-tree/simpleSchema.d.ts.map +1 -0
  257. package/dist/simple-tree/simpleSchema.js.map +1 -0
  258. package/dist/simple-tree/toMapTree.js +3 -3
  259. package/dist/simple-tree/toMapTree.js.map +1 -1
  260. package/dist/simple-tree/toStoredSchema.js +1 -1
  261. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  262. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  263. package/dist/simple-tree/treeNodeValid.js +4 -5
  264. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  265. package/dist/treeFactory.d.ts +0 -12
  266. package/dist/treeFactory.d.ts.map +1 -1
  267. package/dist/treeFactory.js +5 -21
  268. package/dist/treeFactory.js.map +1 -1
  269. package/dist/util/idAllocator.d.ts.map +1 -1
  270. package/dist/util/idAllocator.js +1 -2
  271. package/dist/util/idAllocator.js.map +1 -1
  272. package/dist/util/index.d.ts +1 -1
  273. package/dist/util/index.d.ts.map +1 -1
  274. package/dist/util/index.js +2 -3
  275. package/dist/util/index.js.map +1 -1
  276. package/dist/util/typeCheck.d.ts +7 -0
  277. package/dist/util/typeCheck.d.ts.map +1 -1
  278. package/dist/util/typeCheck.js.map +1 -1
  279. package/dist/util/utils.d.ts +0 -1
  280. package/dist/util/utils.d.ts.map +1 -1
  281. package/dist/util/utils.js +1 -4
  282. package/dist/util/utils.js.map +1 -1
  283. package/lib/alpha.d.ts +26 -1
  284. package/lib/beta.d.ts +5 -1
  285. package/lib/codec/codec.d.ts +1 -1
  286. package/lib/codec/codec.d.ts.map +1 -1
  287. package/lib/codec/codec.js +1 -2
  288. package/lib/codec/codec.js.map +1 -1
  289. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  290. package/lib/codec/discriminatedUnions.js +2 -2
  291. package/lib/codec/discriminatedUnions.js.map +1 -1
  292. package/lib/core/rebase/utils.js +1 -1
  293. package/lib/core/rebase/utils.js.map +1 -1
  294. package/lib/core/schema-stored/schema.d.ts +4 -1
  295. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  296. package/lib/core/schema-stored/schema.js +6 -2
  297. package/lib/core/schema-stored/schema.js.map +1 -1
  298. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  299. package/lib/core/tree/anchorSet.js +2 -2
  300. package/lib/core/tree/anchorSet.js.map +1 -1
  301. package/lib/core/tree/treeTextFormat.js +1 -1
  302. package/lib/core/tree/treeTextFormat.js.map +1 -1
  303. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  304. package/lib/feature-libraries/chunked-forest/basicChunk.js +2 -2
  305. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  306. package/lib/feature-libraries/chunked-forest/chunkTree.js +2 -2
  307. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  308. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  309. package/lib/feature-libraries/chunked-forest/chunkedForest.js +2 -2
  310. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  311. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -1
  312. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  313. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
  314. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  315. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  316. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  317. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -1
  318. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +1 -2
  319. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
  320. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  321. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -1
  322. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  323. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  324. package/lib/feature-libraries/chunked-forest/uniformChunk.js +2 -2
  325. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  326. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  327. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  328. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  329. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  330. package/lib/feature-libraries/default-schema/schemaChecker.js +1 -2
  331. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  332. package/lib/feature-libraries/flex-tree/lazyField.js +2 -2
  333. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  334. package/lib/feature-libraries/flex-tree/lazyNode.js +2 -2
  335. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  336. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  337. package/lib/feature-libraries/indexing/anchorTreeIndex.js +2 -2
  338. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  339. package/lib/feature-libraries/modular-schema/comparison.js +2 -2
  340. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  341. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  342. package/lib/feature-libraries/modular-schema/isNeverTree.js +1 -2
  343. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  344. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  345. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  346. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  347. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  348. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +2 -2
  349. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  350. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +2 -2
  351. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
  352. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  353. package/lib/feature-libraries/object-forest/objectForest.js +2 -2
  354. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  355. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  356. package/lib/feature-libraries/schema-index/codec.js +2 -1
  357. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  358. package/lib/feature-libraries/sequence-field/compose.d.ts +1 -1
  359. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  360. package/lib/feature-libraries/sequence-field/compose.js +1 -2
  361. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  362. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  363. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  364. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  365. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  366. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +2 -2
  367. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  368. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  369. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -2
  370. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  371. package/lib/feature-libraries/sequence-field/utils.js +2 -2
  372. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  373. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  374. package/lib/feature-libraries/treeCursorUtils.js +1 -2
  375. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  376. package/lib/index.d.ts +4 -3
  377. package/lib/index.d.ts.map +1 -1
  378. package/lib/index.js +4 -3
  379. package/lib/index.js.map +1 -1
  380. package/lib/jsonDomainSchema.d.ts +15 -16
  381. package/lib/jsonDomainSchema.d.ts.map +1 -1
  382. package/lib/jsonDomainSchema.js +11 -6
  383. package/lib/jsonDomainSchema.js.map +1 -1
  384. package/lib/legacy.d.ts +5 -1
  385. package/lib/packageVersion.d.ts +1 -1
  386. package/lib/packageVersion.js +1 -1
  387. package/lib/packageVersion.js.map +1 -1
  388. package/lib/public.d.ts +5 -1
  389. package/lib/serializableDomainSchema.d.ts +8 -14
  390. package/lib/serializableDomainSchema.d.ts.map +1 -1
  391. package/lib/shared-tree/schematizeTree.js +2 -2
  392. package/lib/shared-tree/schematizeTree.js.map +1 -1
  393. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  394. package/lib/shared-tree/sharedTree.js +14 -10
  395. package/lib/shared-tree/sharedTree.js.map +1 -1
  396. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  397. package/lib/shared-tree/sharedTreeChangeFamily.js +2 -2
  398. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  399. package/lib/shared-tree/treeApiAlpha.d.ts +6 -2
  400. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  401. package/lib/shared-tree/treeApiAlpha.js +10 -7
  402. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  403. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  404. package/lib/shared-tree/treeCheckout.js +2 -2
  405. package/lib/shared-tree/treeCheckout.js.map +1 -1
  406. package/lib/shared-tree-core/branch.d.ts +4 -3
  407. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  408. package/lib/shared-tree-core/branch.js +2 -2
  409. package/lib/shared-tree-core/branch.js.map +1 -1
  410. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  411. package/lib/shared-tree-core/editManager.js +35 -29
  412. package/lib/shared-tree-core/editManager.js.map +1 -1
  413. package/lib/sharedTreeAttributes.d.ts +18 -0
  414. package/lib/sharedTreeAttributes.d.ts.map +1 -0
  415. package/lib/sharedTreeAttributes.js +22 -0
  416. package/lib/sharedTreeAttributes.js.map +1 -0
  417. package/lib/simple-tree/api/customTree.js +2 -2
  418. package/lib/simple-tree/api/customTree.js.map +1 -1
  419. package/lib/simple-tree/api/getJsonSchema.d.ts +10 -0
  420. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  421. package/lib/simple-tree/api/getJsonSchema.js +10 -0
  422. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  423. package/lib/simple-tree/api/getSimpleSchema.d.ts +13 -43
  424. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  425. package/lib/simple-tree/api/getSimpleSchema.js +13 -43
  426. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  427. package/lib/simple-tree/api/index.d.ts +3 -3
  428. package/lib/simple-tree/api/index.d.ts.map +1 -1
  429. package/lib/simple-tree/api/index.js +1 -0
  430. package/lib/simple-tree/api/index.js.map +1 -1
  431. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  432. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  433. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  434. package/lib/simple-tree/api/schemaFactory.d.ts +100 -58
  435. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  436. package/lib/simple-tree/api/schemaFactory.js +64 -132
  437. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  438. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +31 -23
  439. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  440. package/lib/simple-tree/api/schemaFactoryAlpha.js +18 -2
  441. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  442. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  443. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  444. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  445. package/lib/simple-tree/api/schemaFromSimple.d.ts +4 -4
  446. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  447. package/lib/simple-tree/api/schemaFromSimple.js +21 -10
  448. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  449. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  450. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  451. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -6
  452. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  453. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  454. package/lib/simple-tree/api/simpleTreeIndex.js +2 -1
  455. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  456. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  457. package/lib/simple-tree/api/tree.d.ts +1 -1
  458. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  459. package/lib/simple-tree/api/tree.js +2 -2
  460. package/lib/simple-tree/api/tree.js.map +1 -1
  461. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  462. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  463. package/lib/simple-tree/api/typesUnsafe.d.ts +87 -21
  464. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  465. package/lib/simple-tree/api/typesUnsafe.js +0 -1
  466. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  467. package/lib/simple-tree/api/verboseTree.js +2 -2
  468. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  469. package/lib/simple-tree/api/view.d.ts.map +1 -1
  470. package/lib/simple-tree/api/view.js +1 -2
  471. package/lib/simple-tree/api/view.js.map +1 -1
  472. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  473. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  474. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +69 -146
  475. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  476. package/lib/simple-tree/arrayNode.d.ts +5 -4
  477. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  478. package/lib/simple-tree/arrayNode.js +7 -3
  479. package/lib/simple-tree/arrayNode.js.map +1 -1
  480. package/lib/simple-tree/arrayNodeTypes.d.ts +46 -0
  481. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  482. package/lib/simple-tree/arrayNodeTypes.js +26 -0
  483. package/lib/simple-tree/arrayNodeTypes.js.map +1 -0
  484. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  485. package/lib/simple-tree/core/getOrCreateNode.js +2 -12
  486. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  487. package/lib/simple-tree/core/index.d.ts +1 -2
  488. package/lib/simple-tree/core/index.d.ts.map +1 -1
  489. package/lib/simple-tree/core/index.js +1 -2
  490. package/lib/simple-tree/core/index.js.map +1 -1
  491. package/lib/simple-tree/core/treeNodeKernel.d.ts +12 -5
  492. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  493. package/lib/simple-tree/core/treeNodeKernel.js +28 -14
  494. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  495. package/lib/simple-tree/core/treeNodeSchema.d.ts +14 -7
  496. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  497. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  498. package/lib/simple-tree/core/unhydratedFlexTree.js +2 -2
  499. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  500. package/lib/simple-tree/index.d.ts +9 -2
  501. package/lib/simple-tree/index.d.ts.map +1 -1
  502. package/lib/simple-tree/index.js +3 -0
  503. package/lib/simple-tree/index.js.map +1 -1
  504. package/lib/simple-tree/leafNodeSchema.d.ts +22 -5
  505. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  506. package/lib/simple-tree/leafNodeSchema.js +2 -0
  507. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  508. package/lib/simple-tree/mapNode.d.ts +3 -2
  509. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  510. package/lib/simple-tree/mapNode.js +5 -1
  511. package/lib/simple-tree/mapNode.js.map +1 -1
  512. package/lib/simple-tree/mapNodeTypes.d.ts +46 -0
  513. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -0
  514. package/lib/simple-tree/mapNodeTypes.js +26 -0
  515. package/lib/simple-tree/mapNodeTypes.js.map +1 -0
  516. package/lib/simple-tree/objectNode.d.ts +10 -3
  517. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  518. package/lib/simple-tree/objectNode.js +10 -5
  519. package/lib/simple-tree/objectNode.js.map +1 -1
  520. package/lib/simple-tree/objectNodeTypes.d.ts +9 -5
  521. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  522. package/lib/simple-tree/objectNodeTypes.js +3 -0
  523. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  524. package/lib/simple-tree/proxies.js +2 -1
  525. package/lib/simple-tree/proxies.js.map +1 -1
  526. package/lib/simple-tree/schemaTypes.d.ts +47 -6
  527. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  528. package/lib/simple-tree/schemaTypes.js +37 -3
  529. package/lib/simple-tree/schemaTypes.js.map +1 -1
  530. package/lib/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +54 -30
  531. package/lib/simple-tree/simpleSchema.d.ts.map +1 -0
  532. package/lib/simple-tree/simpleSchema.js.map +1 -0
  533. package/lib/simple-tree/toMapTree.js +2 -2
  534. package/lib/simple-tree/toMapTree.js.map +1 -1
  535. package/lib/simple-tree/toStoredSchema.js +2 -2
  536. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  537. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  538. package/lib/simple-tree/treeNodeValid.js +1 -2
  539. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  540. package/lib/treeFactory.d.ts +0 -12
  541. package/lib/treeFactory.d.ts.map +1 -1
  542. package/lib/treeFactory.js +1 -17
  543. package/lib/treeFactory.js.map +1 -1
  544. package/lib/tsdoc-metadata.json +1 -1
  545. package/lib/util/idAllocator.d.ts.map +1 -1
  546. package/lib/util/idAllocator.js +1 -2
  547. package/lib/util/idAllocator.js.map +1 -1
  548. package/lib/util/index.d.ts +1 -1
  549. package/lib/util/index.d.ts.map +1 -1
  550. package/lib/util/index.js +1 -1
  551. package/lib/util/index.js.map +1 -1
  552. package/lib/util/typeCheck.d.ts +7 -0
  553. package/lib/util/typeCheck.d.ts.map +1 -1
  554. package/lib/util/typeCheck.js.map +1 -1
  555. package/lib/util/utils.d.ts +0 -1
  556. package/lib/util/utils.d.ts.map +1 -1
  557. package/lib/util/utils.js +0 -2
  558. package/lib/util/utils.js.map +1 -1
  559. package/package.json +36 -26
  560. package/src/codec/codec.ts +2 -2
  561. package/src/codec/discriminatedUnions.ts +2 -2
  562. package/src/core/rebase/utils.ts +1 -1
  563. package/src/core/schema-stored/schema.ts +6 -2
  564. package/src/core/tree/anchorSet.ts +1 -2
  565. package/src/core/tree/treeTextFormat.ts +1 -1
  566. package/src/feature-libraries/chunked-forest/basicChunk.ts +2 -2
  567. package/src/feature-libraries/chunked-forest/chunkTree.ts +2 -2
  568. package/src/feature-libraries/chunked-forest/chunkedForest.ts +1 -2
  569. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
  570. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -2
  571. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +2 -2
  572. package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +1 -2
  573. package/src/feature-libraries/chunked-forest/emptyChunk.ts +1 -1
  574. package/src/feature-libraries/chunked-forest/uniformChunk.ts +2 -2
  575. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  576. package/src/feature-libraries/default-schema/schemaChecker.ts +1 -2
  577. package/src/feature-libraries/flex-tree/lazyField.ts +2 -2
  578. package/src/feature-libraries/flex-tree/lazyNode.ts +2 -2
  579. package/src/feature-libraries/indexing/anchorTreeIndex.ts +2 -2
  580. package/src/feature-libraries/modular-schema/comparison.ts +2 -2
  581. package/src/feature-libraries/modular-schema/isNeverTree.ts +1 -2
  582. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -2
  583. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1 -2
  584. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +2 -2
  585. package/src/feature-libraries/object-forest/objectForest.ts +1 -2
  586. package/src/feature-libraries/schema-index/codec.ts +2 -1
  587. package/src/feature-libraries/sequence-field/compose.ts +2 -2
  588. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  589. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +2 -2
  590. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +2 -2
  591. package/src/feature-libraries/sequence-field/utils.ts +2 -2
  592. package/src/feature-libraries/treeCursorUtils.ts +1 -2
  593. package/src/index.ts +26 -3
  594. package/src/jsonDomainSchema.ts +30 -11
  595. package/src/packageVersion.ts +1 -1
  596. package/src/shared-tree/schematizeTree.ts +2 -2
  597. package/src/shared-tree/sharedTree.ts +16 -10
  598. package/src/shared-tree/sharedTreeChangeFamily.ts +1 -2
  599. package/src/shared-tree/treeApiAlpha.ts +36 -13
  600. package/src/shared-tree/treeCheckout.ts +2 -8
  601. package/src/shared-tree-core/branch.ts +5 -3
  602. package/src/shared-tree-core/editManager.ts +37 -45
  603. package/src/sharedTreeAttributes.ts +25 -0
  604. package/src/simple-tree/api/customTree.ts +2 -2
  605. package/src/simple-tree/api/getJsonSchema.ts +10 -0
  606. package/src/simple-tree/api/getSimpleSchema.ts +14 -44
  607. package/src/simple-tree/api/index.ts +7 -11
  608. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -2
  609. package/src/simple-tree/api/schemaFactory.ts +161 -86
  610. package/src/simple-tree/api/schemaFactoryAlpha.ts +62 -67
  611. package/src/simple-tree/api/schemaFactoryRecursive.ts +44 -12
  612. package/src/simple-tree/api/schemaFromSimple.ts +41 -13
  613. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -7
  614. package/src/simple-tree/api/simpleTreeIndex.ts +2 -1
  615. package/src/simple-tree/api/tree.ts +3 -3
  616. package/src/simple-tree/api/treeNodeApi.ts +2 -2
  617. package/src/simple-tree/api/typesUnsafe.ts +151 -33
  618. package/src/simple-tree/api/verboseTree.ts +2 -2
  619. package/src/simple-tree/api/view.ts +1 -2
  620. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -185
  621. package/src/simple-tree/arrayNode.ts +20 -14
  622. package/src/simple-tree/arrayNodeTypes.ts +93 -0
  623. package/src/simple-tree/core/getOrCreateNode.ts +3 -13
  624. package/src/simple-tree/core/index.ts +1 -1
  625. package/src/simple-tree/core/treeNodeKernel.ts +32 -18
  626. package/src/simple-tree/core/treeNodeSchema.ts +14 -8
  627. package/src/simple-tree/core/unhydratedFlexTree.ts +2 -2
  628. package/src/simple-tree/index.ts +30 -9
  629. package/src/simple-tree/leafNodeSchema.ts +28 -7
  630. package/src/simple-tree/mapNode.ts +13 -11
  631. package/src/simple-tree/mapNodeTypes.ts +90 -0
  632. package/src/simple-tree/objectNode.ts +37 -13
  633. package/src/simple-tree/objectNodeTypes.ts +21 -16
  634. package/src/simple-tree/proxies.ts +2 -2
  635. package/src/simple-tree/schemaTypes.ts +83 -19
  636. package/src/simple-tree/{api/simpleSchema.ts → simpleSchema.ts} +61 -32
  637. package/src/simple-tree/toMapTree.ts +2 -2
  638. package/src/simple-tree/toStoredSchema.ts +2 -2
  639. package/src/simple-tree/treeNodeValid.ts +1 -2
  640. package/src/treeFactory.ts +1 -19
  641. package/src/util/idAllocator.ts +1 -3
  642. package/src/util/index.ts +0 -1
  643. package/src/util/typeCheck.ts +7 -0
  644. package/src/util/utils.ts +0 -3
  645. package/dist/simple-tree/api/simpleSchema.d.ts.map +0 -1
  646. package/dist/simple-tree/api/simpleSchema.js.map +0 -1
  647. package/dist/simple-tree/core/schemaCaching.d.ts +0 -16
  648. package/dist/simple-tree/core/schemaCaching.d.ts.map +0 -1
  649. package/dist/simple-tree/core/schemaCaching.js +0 -32
  650. package/dist/simple-tree/core/schemaCaching.js.map +0 -1
  651. package/lib/simple-tree/api/simpleSchema.d.ts.map +0 -1
  652. package/lib/simple-tree/api/simpleSchema.js.map +0 -1
  653. package/lib/simple-tree/core/schemaCaching.d.ts +0 -16
  654. package/lib/simple-tree/core/schemaCaching.d.ts.map +0 -1
  655. package/lib/simple-tree/core/schemaCaching.js +0 -27
  656. package/lib/simple-tree/core/schemaCaching.js.map +0 -1
  657. package/prettier.config.cjs +0 -8
  658. package/src/simple-tree/core/schemaCaching.ts +0 -35
  659. /package/dist/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
  660. /package/lib/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.UnsafeUnknownSchema = exports.markSchemaMostDerived = exports.evaluateLazySchema = exports.areFieldSchemaEqual = exports.areImplicitFieldSchemaEqual = exports.normalizeAllowedTypes = exports.normalizeFieldSchema = exports.FieldSchema = exports.createFieldSchema = exports.getDefaultProvider = exports.extractFieldProvider = exports.isConstant = exports.getExplicitStoredKey = exports.getStoredKey = exports.FieldKind = exports.isTreeNodeSchemaClass = void 0;
7
+ exports.UnsafeUnknownSchema = exports.markSchemaMostDerived = exports.evaluateLazySchema = exports.areFieldSchemaEqual = exports.areImplicitFieldSchemaEqual = exports.normalizeAllowedTypes = exports.normalizeFieldSchema = exports.ObjectFieldSchema = exports.FieldSchemaAlpha = exports.FieldSchema = exports.createFieldSchema = exports.getDefaultProvider = exports.extractFieldProvider = exports.isConstant = exports.getExplicitStoredKey = exports.getStoredKey = exports.FieldKind = exports.isTreeNodeSchemaClass = void 0;
8
8
  const internal_1 = require("@fluidframework/core-utils/internal");
9
9
  const internal_2 = require("@fluidframework/telemetry-utils/internal");
10
10
  const index_js_1 = require("../util/index.js");
@@ -87,7 +87,7 @@ exports.getDefaultProvider = getDefaultProvider;
87
87
  * including functionality that does not have to be kept consistent across versions or deterministic.
88
88
  *
89
89
  * This can include policy for how to use this schema for "view" purposes, and well as how to expose editing APIs.
90
- * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link schemaStatics.optional}.
90
+ * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link SchemaStatics.optional}.
91
91
  * @privateRemarks
92
92
  * Public access to the constructor is removed to prevent creating expressible but unsupported (or not stable) configurations.
93
93
  * {@link createFieldSchema} can be used internally to create instances.
@@ -95,6 +95,9 @@ exports.getDefaultProvider = getDefaultProvider;
95
95
  * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
96
96
  * See {@link FieldSchemaMetadata.custom}.
97
97
  *
98
+ * @remarks
99
+ * All implementations of this are actually {@link FieldSchemaAlpha} which exposes some additional alpha APIs.
100
+ *
98
101
  * @sealed @public
99
102
  */
100
103
  class FieldSchema {
@@ -109,8 +112,12 @@ class FieldSchema {
109
112
  * {@inheritDoc FieldProps.metadata}
110
113
  */
111
114
  get metadata() {
112
- return this.props?.metadata;
115
+ return this.props?.metadata ?? {};
113
116
  }
117
+ /**
118
+ * This class is `@sealed`: protected members like this constructor are for internal use only.
119
+ * Use {@link SchemaFactory} to create the FieldSchema instances.
120
+ */
114
121
  constructor(
115
122
  /**
116
123
  * The {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind } of this field.
@@ -128,6 +135,9 @@ class FieldSchema {
128
135
  this.kind = kind;
129
136
  this.allowedTypes = allowedTypes;
130
137
  this.props = props;
138
+ if (!(this instanceof FieldSchemaAlpha)) {
139
+ throw new internal_2.UsageError("FieldSchema is @sealed: sub-classing is not allowed.");
140
+ }
131
141
  this.lazyTypes = new internal_1.Lazy(() => normalizeAllowedTypes(this.allowedTypes));
132
142
  // TODO: optional fields should (by default) get a default provider that returns undefined, removing the need to special case them here:
133
143
  this.requiresValue =
@@ -135,9 +145,35 @@ class FieldSchema {
135
145
  }
136
146
  }
137
147
  exports.FieldSchema = FieldSchema;
148
+ /**
149
+ * {@link FieldSchema} including alpha APIs (currently {@link SimpleFieldSchema}).
150
+ * @remarks
151
+ * This class will go away once the alpha APIs are stable and implemented by {@link FieldSchema}.
152
+ * @sealed @alpha
153
+ */
154
+ class FieldSchemaAlpha extends FieldSchema {
155
+ constructor(kind, allowedTypes, props) {
156
+ super(kind, allowedTypes, props);
157
+ this.lazyIdentifiers = new internal_1.Lazy(() => new Set([...this.allowedTypeSet].map((t) => t.identifier)));
158
+ }
159
+ get allowedTypesIdentifiers() {
160
+ return this.lazyIdentifiers.value;
161
+ }
162
+ }
163
+ exports.FieldSchemaAlpha = FieldSchemaAlpha;
138
164
  (() => {
139
- exports.createFieldSchema = (kind, allowedTypes, props) => new FieldSchema(kind, allowedTypes, props);
165
+ exports.createFieldSchema = (kind, allowedTypes, props) => new FieldSchemaAlpha(kind, allowedTypes, props);
140
166
  })();
167
+ /**
168
+ * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.
169
+ */
170
+ class ObjectFieldSchema extends FieldSchemaAlpha {
171
+ constructor(kind, allowedTypes, props) {
172
+ super(kind, allowedTypes, props);
173
+ this.storedKey = props.key;
174
+ }
175
+ }
176
+ exports.ObjectFieldSchema = ObjectFieldSchema;
141
177
  /**
142
178
  * Normalizes a {@link ImplicitFieldSchema} to a {@link FieldSchema}.
143
179
  */
@@ -1 +1 @@
1
- {"version":3,"file":"schemaTypes.js","sourceR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,oEAAoE,CACrE,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,MAA+C,CAAC;IACpE,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;SAAM,CAAC;QACP,WAAW,CAAC,eAAe,EAAE,CAAC;IAC/B,CAAC;AACF,CAAC;AAvBD,sDAuBC;AA8ED;;;GAGG;AACU,QAAA,mBAAmB,GAAkB,MAAM,CAAC,qBAAqB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { NodeIdentifierManager } from \"../feature-libraries/index.js\";\nimport {\n\ttype MakeNominal,\n\tbrand,\n\tisReadonlyArray,\n\ttype UnionToIntersection,\n\tcompareSets,\n\ttype requireTrue,\n\ttype areOnlyKeys,\n\tgetOrCreate,\n} from \"../util/index.js\";\nimport type {\n\tUnhydrated,\n\tNodeKind,\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tTreeNode,\n\tTreeNodeSchemaCore,\n\tTreeNodeSchemaNonClass,\n} from \"./core/index.js\";\nimport { inPrototypeChain } from \"./core/index.js\";\nimport type { FieldKey } from \"../core/index.js\";\nimport type { InsertableContent } from \"./toMapTree.js\";\nimport { isLazy, type FlexListToUnion, type LazyItem } from \"./flexList.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { TreeNodeValid } from \"./treeNodeValid.js\";\n\n/**\n * Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.\n * @internal\n */\nexport function isTreeNodeSchemaClass<\n\tName extends string,\n\tKind extends NodeKind,\n\tTNode extends TreeNode | TreeLeafValue,\n\tTBuild,\n\tImplicitlyConstructable extends boolean,\n\tInfo,\n>(\n\tschema:\n\t\t| TreeNodeSchema<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>\n\t\t| TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>,\n): schema is TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode & TreeNode,\n\tTBuild,\n\tImplicitlyConstructable,\n\tInfo\n> {\n\treturn schema.constructor !== undefined;\n}\n\n/**\n * Types for use in fields.\n * @remarks\n * Type constraint used in schema declaration APIs.\n *\n * The order of types in the array is not significant.\n * Additionally, it is legal for users of this type to have the runtime and compile time order of items within this array not match.\n * Therefor to ensure type safety, these arrays should not be indexed, and instead just be iterated.\n *\n * Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)\n * way to declare and manipulate unordered sets of types in TypeScript.\n *\n * Not intended for direct use outside of package.\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @system @public\n */\nexport type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];\n\n/**\n * Kind of a field on a node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum FieldKind {\n\t/**\n\t * A field which can be empty or filled.\n\t * @remarks\n\t * Allows 0 or one child.\n\t */\n\tOptional,\n\t/**\n\t * A field which must always be filled.\n\t * @remarks\n\t * Only allows exactly one child.\n\t */\n\tRequired,\n\t/**\n\t * A special field used for node identifiers.\n\t * @remarks\n\t * Only allows exactly one child.\n\t */\n\tIdentifier,\n}\n\n/**\n * Maps from a property key to its corresponding {@link FieldProps.key | stored key} for the provided\n * {@link ImplicitFieldSchema | field schema}.\n *\n * @remarks\n * If an explicit stored key was specified in the schema, it will be used.\n * Otherwise, the stored key is the same as the property key.\n */\nexport function getStoredKey(propertyKey: string, fieldSchema: ImplicitFieldSchema): FieldKey {\n\treturn brand(getExplicitStoredKey(fieldSchema) ?? propertyKey);\n}\n\n/**\n * Gets the {@link FieldProps.key | stored key} specified by the schema, if one was explicitly specified.\n * Otherwise, returns undefined.\n */\nexport function getExplicitStoredKey(fieldSchema: ImplicitFieldSchema): string | undefined {\n\treturn fieldSchema instanceof FieldSchema ? fieldSchema.props?.key : undefined;\n}\n\n/**\n * Additional information to provide to a {@link FieldSchema}.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @public\n */\nexport interface FieldProps<TCustomMetadata = unknown> {\n\t/**\n\t * The unique identifier of a field, used in the persisted form of the tree.\n\t *\n\t * @remarks\n\t * If not explicitly set via the schema, this is the same as the schema's property key.\n\t *\n\t * Specifying a stored key that differs from the property key is particularly useful in refactoring scenarios.\n\t * To update the developer-facing API, while maintaining backwards compatibility with existing SharedTree data,\n\t * you can change the property key and specify the previous property key as the stored key.\n\t *\n\t * Notes:\n\t *\n\t * - Stored keys have no impact on standard JavaScript behavior, on tree nodes. For example, `Object.keys`\n\t * will always return the property keys specified in the schema, ignoring any stored keys that differ from\n\t * the property keys.\n\t *\n\t * - When specifying stored keys in an object schema, you must ensure that the final set of stored keys\n\t * (accounting for those implicitly derived from property keys) contains no duplicates.\n\t * This is validated at runtime.\n\t *\n\t * @example Refactoring code without breaking compatibility with existing data\n\t *\n\t * Consider some existing object schema:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \txPosition: schemaFactory.number,\n\t * \tyPosition: schemaFactory.number,\n\t * \tzPosition: schemaFactory.optional(schemaFactory.number),\n\t * });\n\t * ```\n\t *\n\t * Developers using nodes of this type would access the the `xPosition` property as `point.xPosition`.\n\t *\n\t * We would like to refactor the schema to omit \"Position\" from the property keys, but application data has\n\t * already been persisted using the original property keys. To maintain compatibility with existing data,\n\t * we can refactor the schema as follows:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \tx: schemaFactory.required(schemaFactory.number, { key: \"xPosition\" }),\n\t * \ty: schemaFactory.required(schemaFactory.number, { key: \"yPosition\" }),\n\t * \tz: schemaFactory.optional(schemaFactory.number, { key: \"zPosition\" }),\n\t * });\n\t * ```\n\t *\n\t * Now, developers can access the `x` property as `point.x`, while existing data can still be collaborated on.\n\t *\n\t * @defaultValue If not specified, the key that is persisted is the property key that was specified in the schema.\n\t */\n\treadonly key?: string;\n\n\t/**\n\t * A default provider used for fields which were not provided any values.\n\t * @privateRemarks\n\t * We are using an erased type here, as we want to expose this API but `InsertableContent` and `NodeKeyManager` are not public.\n\t */\n\treadonly defaultProvider?: DefaultProvider;\n\n\t/**\n\t * Optional metadata to associate with the field.\n\t *\n\t * @remarks\n\t * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.\n\t * Different clients in the same collaborative session may see different metadata for the same field.\n\t */\n\treadonly metadata?: FieldSchemaMetadata<TCustomMetadata>;\n}\n\n/**\n * A {@link FieldProvider} which requires additional context in order to produce its content\n */\nexport type ContextualFieldProvider = (\n\tcontext: NodeIdentifierManager,\n) => InsertableContent | undefined;\n/**\n * A {@link FieldProvider} which can produce its content in a vacuum\n */\nexport type ConstantFieldProvider = () => InsertableContent | undefined;\n/**\n * A function which produces content for a field every time that it is called\n */\nexport type FieldProvider = ContextualFieldProvider | ConstantFieldProvider;\n/**\n * Returns true if the given {@link FieldProvider} is a {@link ConstantFieldProvider}\n */\nexport function isConstant(\n\tfieldProvider: FieldProvider,\n): fieldProvider is ConstantFieldProvider {\n\treturn fieldProvider.length === 0;\n}\n\n/**\n * Provides a default value for a field.\n * @remarks\n * If present in a `FieldSchema`, when constructing new tree content that field can be omitted, and a default will be provided.\n * @system @sealed @public\n */\nexport interface DefaultProvider extends ErasedType<\"@fluidframework/tree.FieldProvider\"> {}\n\nexport function extractFieldProvider(input: DefaultProvider): FieldProvider {\n\treturn input as unknown as FieldProvider;\n}\n\nexport function getDefaultProvider(input: FieldProvider): DefaultProvider {\n\treturn input as unknown as DefaultProvider;\n}\n\n/**\n * Metadata associated with a {@link FieldSchema}.\n *\n * @remarks Specified via {@link FieldProps.metadata}.\n *\n * @sealed\n * @public\n */\nexport interface FieldSchemaMetadata<TCustomMetadata = unknown> {\n\t/**\n\t * User-defined metadata.\n\t */\n\treadonly custom?: TCustomMetadata;\n\n\t/**\n\t * The description of the field.\n\t *\n\t * @remarks\n\t *\n\t * If provided, will be used by the system in scenarios where a description of the field is useful.\n\t * E.g., when converting a field schema to {@link https://json-schema.org/ | JSON Schema}, this description will be\n\t * used as the `description` field.\n\t */\n\treadonly description?: string | undefined;\n}\n\n/**\n * Package internal construction API.\n */\nexport let createFieldSchema: <\n\tKind extends FieldKind = FieldKind,\n\tTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tallowedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n) => FieldSchema<Kind, Types, TCustomMetadata>;\n\n/**\n * All policy for a specific field,\n * including functionality that does not have to be kept consistent across versions or deterministic.\n *\n * This can include policy for how to use this schema for \"view\" purposes, and well as how to expose editing APIs.\n * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link schemaStatics.optional}.\n * @privateRemarks\n * Public access to the constructor is removed to prevent creating expressible but unsupported (or not stable) configurations.\n * {@link createFieldSchema} can be used internally to create instances.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @sealed @public\n */\nexport class FieldSchema<\n\tout Kind extends FieldKind = FieldKind,\n\tout Types extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\tout TCustomMetadata = unknown,\n> {\n\tstatic {\n\t\tcreateFieldSchema = <\n\t\t\tKind2 extends FieldKind = FieldKind,\n\t\t\tTypes2 extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t\t\tTCustomMetadata2 = unknown,\n\t\t>(\n\t\t\tkind: Kind2,\n\t\t\tallowedTypes: Types2,\n\t\t\tprops?: FieldProps<TCustomMetadata2>,\n\t\t) => new FieldSchema(kind, allowedTypes, props);\n\t}\n\t/**\n\t * This class is used with instanceof, and therefore should have nominal typing.\n\t * This field enforces that.\n\t */\n\tprotected _typeCheck!: MakeNominal;\n\n\tprivate readonly lazyTypes: Lazy<ReadonlySet<TreeNodeSchema>>;\n\n\t/**\n\t * What types of tree nodes are allowed in this field.\n\t * @remarks Counterpart to {@link FieldSchema.allowedTypes}, with any lazy definitions evaluated.\n\t */\n\tpublic get allowedTypeSet(): ReadonlySet<TreeNodeSchema> {\n\t\treturn this.lazyTypes.value;\n\t}\n\n\t/**\n\t * True if and only if, when constructing a node with this field, a value must be provided for it.\n\t */\n\tpublic readonly requiresValue: boolean;\n\n\t/**\n\t * {@inheritDoc FieldProps.metadata}\n\t */\n\tpublic get metadata(): FieldSchemaMetadata<TCustomMetadata> | undefined {\n\t\treturn this.props?.metadata;\n\t}\n\n\tprivate constructor(\n\t\t/**\n\t\t * The {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind } of this field.\n\t\t * Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.\n\t\t */\n\t\tpublic readonly kind: Kind,\n\t\t/**\n\t\t * What types of tree nodes are allowed in this field.\n\t\t */\n\t\tpublic readonly allowedTypes: Types,\n\t\t/**\n\t\t * Optional properties associated with the field.\n\t\t */\n\t\tpublic readonly props?: FieldProps<TCustomMetadata>,\n\t) {\n\t\tthis.lazyTypes = new Lazy(() => normalizeAllowedTypes(this.allowedTypes));\n\t\t// TODO: optional fields should (by default) get a default provider that returns undefined, removing the need to special case them here:\n\t\tthis.requiresValue =\n\t\t\tthis.props?.defaultProvider === undefined && this.kind !== FieldKind.Optional;\n\t}\n}\n\n/**\n * Normalizes a {@link ImplicitFieldSchema} to a {@link FieldSchema}.\n */\nexport function normalizeFieldSchema(schema: ImplicitFieldSchema): FieldSchema {\n\treturn schema instanceof FieldSchema\n\t\t? schema\n\t\t: createFieldSchema(FieldKind.Required, schema);\n}\n/**\n * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any\n * lazy schema declarations.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n *\n * @internal\n */\nexport function normalizeAllowedTypes(\n\ttypes: ImplicitAllowedTypes,\n): ReadonlySet<TreeNodeSchema> {\n\tconst normalized = new Set<TreeNodeSchema>();\n\tif (isReadonlyArray(types)) {\n\t\t// Types array must not be modified after it is normalized since that would result in the user of the normalized data having wrong (out of date) content.\n\t\tObject.freeze(types);\n\t\tfor (const lazyType of types) {\n\t\t\tnormalized.add(evaluateLazySchema(lazyType));\n\t\t}\n\t} else {\n\t\tnormalized.add(evaluateLazySchema(types));\n\t}\n\treturn normalized;\n}\n\n/**\n * Returns true if the given {@link ImplicitFieldSchema} are equivalent, otherwise false.\n * @remarks Two ImplicitFieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be (respectively) reference equal.\n *\n * For example, comparing an ImplicitFieldSchema that is a {@link TreeNodeSchema} to an ImplicitFieldSchema that is a {@link FieldSchema}\n * will return true if they are the same kind, the FieldSchema has exactly one allowed type (the TreeNodeSchema), and they have equivalent FieldProps.\n */\nexport function areImplicitFieldSchemaEqual(\n\ta: ImplicitFieldSchema,\n\tb: ImplicitFieldSchema,\n): boolean {\n\treturn areFieldSchemaEqual(normalizeFieldSchema(a), normalizeFieldSchema(b));\n}\n\n/**\n * Returns true if the given {@link FieldSchema} are equivalent, otherwise false.\n * @remarks Two FieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be reference equal.\n */\nexport function areFieldSchemaEqual(a: FieldSchema, b: FieldSchema): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.kind !== b.kind) {\n\t\treturn false;\n\t}\n\n\tif (!areFieldPropsEqual(a.props, b.props)) {\n\t\treturn false;\n\t}\n\n\treturn compareSets({ a: a.allowedTypeSet, b: b.allowedTypeSet });\n}\n\n/**\n * Returns true if the given {@link FieldProps} are equivalent, otherwise false.\n * @remarks FieldProps are considered equivalent if their keys and default providers are reference equal, and their metadata are {@link areMetadataEqual | equivalent}.\n */\nfunction areFieldPropsEqual(a: FieldProps | undefined, b: FieldProps | undefined): boolean {\n\t// If any new fields are added to FieldProps, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<areOnlyKeys<FieldProps, \"key\" | \"defaultProvider\" | \"metadata\">>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a?.key !== b?.key || a?.defaultProvider !== b?.defaultProvider) {\n\t\treturn false;\n\t}\n\n\tif (!areMetadataEqual(a?.metadata, b?.metadata)) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns true if the given {@link FieldSchemaMetadata} are equivalent, otherwise false.\n * @remarks FieldSchemaMetadata are considered equivalent if their custom data and descriptions are (respectively) reference equal.\n */\nfunction areMetadataEqual(\n\ta: FieldSchemaMetadata | undefined,\n\tb: FieldSchemaMetadata | undefined,\n): boolean {\n\t// If any new fields are added to FieldSchemaMetadata, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<areOnlyKeys<FieldSchemaMetadata, \"custom\" | \"description\">>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\treturn a?.custom === b?.custom && a?.description === b?.description;\n}\n\nconst cachedLazyItem = new WeakMap<() => unknown, unknown>();\n\n/**\n * Returns the schema referenced by the {@link LazyItem}.\n * @remarks\n * Caches results to handle {@link LazyItem}s which compute their resulting schema.\n * @alpha\n */\nexport function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T {\n\tconst evaluatedSchema = isLazy(value)\n\t\t? (getOrCreate(cachedLazyItem, value, value) as T)\n\t\t: value;\n\tif (evaluatedSchema === undefined) {\n\t\tthrow new UsageError(\n\t\t\t`Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated.`,\n\t\t);\n\t}\n\tmarkSchemaMostDerived(evaluatedSchema);\n\treturn evaluatedSchema;\n}\n\n/**\n * Indicates that the provided schema is the \"most derived\" version in its class hierarchy.\n *\n * @param oneTimeInitialize - If true this runs {@link TreeNodeValid.oneTimeInitialize} which does even more initialization and validation.\n * `oneTimeInitialize` can't safely be run until all transitively referenced schema are defined, so which cases can safely use it are more limited.\n * When legal for the caller to set this to true, it is preferred, but it is often not safe due to possible forward references.\n * @remarks\n * See {@link MostDerivedData} and {@link SchemaFactory} for details on what a \"most derived\" schema is and why it matters.\n *\n * This is a helper for invoking {@link TreeNodeValid.markMostDerived} for {@link TreeNodeSchema}.\n *\n * Calling this helps with error messages about invalid schema usage (See {@link SchemaFactory} for the rules, some of which this helps validate).\n * Typically this should be called for each schema as early as practical to improve error reporting for invalid usages of schema\n * (using two different schema derived from the same {@link SchemaFactory} produced base class).\n *\n * Note that construction of actual {@link TreeNode} instances or use of a schema transitively in a {@link TreeViewConfiguration} already do this,\n * so any calls to this that is unconditionally after that point for the given schema is not needed.\n * Instead most usages of this should be from those cases, and from miscellaneous cases where a schema is passed into an public API where theoretically someone could accidentally\n * pass in a base class of a schema instead of the most derived one.\n */\nexport function markSchemaMostDerived(\n\tschema: TreeNodeSchema,\n\toneTimeInitialize = false,\n): void {\n\tif (schema instanceof LeafNodeSchema) {\n\t\treturn;\n\t}\n\n\tif (!inPrototypeChain(schema, TreeNodeValid)) {\n\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\tthrow new UsageError(\n\t\t\t`Schema for ${JSON.stringify(\n\t\t\t\tschema.identifier,\n\t\t\t)} does not extend a SchemaFactory generated class. This is invalid.`,\n\t\t);\n\t}\n\n\tconst schemaValid = schema as typeof TreeNodeValid & TreeNodeSchema;\n\tif (oneTimeInitialize) {\n\t\tschemaValid.oneTimeInitialize();\n\t} else {\n\t\tschemaValid.markMostDerived();\n\t}\n}\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.\n * @remarks\n * Used by {@link TreeViewConfiguration} for the root and various kinds of {@link TreeNodeSchema} to specify their allowed child types.\n *\n * Use {@link SchemaFactory} to access leaf schema or declare new composite schema.\n *\n * Implicitly treats a single type as an array of one type.\n *\n * Arrays of schema can be used to specify multiple types are allowed, which result in unions of those types in the Tree APIs.\n *\n * When saved into variables, avoid type-erasing the details, as doing so loses the compile time schema awareness of APIs derived from the types.\n *\n * When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.\n * See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.\n *\n * @example Explicit use with strong typing\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * const childTypes = [sf.number, sf.string] as const satisfies ImplicitAllowedTypes;\n * const config = new TreeViewConfiguration({ schema: childTypes });\n * ```\n *\n * @example Forward reference\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * class A extends sf.array(\"example\", [() => B]) {}\n * class B extends sf.array(\"Inner\", sf.number) {}\n * ```\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @public\n */\nexport type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;\n\n/**\n * Schema for a field of a tree node.\n * @remarks\n * Implicitly treats {@link ImplicitAllowedTypes} as a Required field of that type.\n * @public\n */\nexport type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;\n\n/**\n * Converts an `ImplicitFieldSchema` to a property type suitable for reading a field with this that schema.\n *\n * @typeparam TSchema - When non-exact schema are provided this errors on the side of returning too general of a type (a conservative union of all possibilities).\n * This is ideal for \"output APIs\" - i.e. it converts the schema type to the runtime type that a user will _read_ from the tree.\n * Examples of such \"non-exact\" schema include `ImplicitFieldSchema`, `ImplicitAllowedTypes`, and TypeScript unions of schema types.\n * @public\n */\nexport type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> =\n\tTSchema extends FieldSchema<infer Kind, infer Types>\n\t\t? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind>\n\t\t: TSchema extends ImplicitAllowedTypes\n\t\t\t? TreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined;\n\n/**\n * Type of content that can be inserted into the tree for a field of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchemaInput - Schema to process.\n * @typeparam TSchema - Do not specify: default value used as implementation detail.\n * @public\n */\nexport type InsertableTreeFieldFromImplicitField<\n\tTSchemaInput extends ImplicitFieldSchema,\n\tTSchema = UnionToIntersection<TSchemaInput>,\n> = [TSchema] extends [FieldSchema<infer Kind, infer Types>]\n\t? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true>\n\t: [TSchema] extends [ImplicitAllowedTypes]\n\t\t? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t: never;\n\n/**\n * {@inheritdoc (UnsafeUnknownSchema:type)}\n * @alpha\n */\nexport const UnsafeUnknownSchema: unique symbol = Symbol(\"UnsafeUnknownSchema\");\n\n/**\n * A special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.\n * @remarks\n * When used, this means the TypeScript typing should err on the side of completeness (allow all inputs that could be valid).\n * This introduces the risk that out-of-schema data could be allowed at compile time, and only error at runtime.\n *\n * @privateRemarks\n * This only applies to APIs which input data which is expected to be in schema, since APIs outputting have easy mechanisms to do so in a type safe way even when the schema is unknown.\n * In most cases that amounts to returning `TreeNode | TreeLeafValue`.\n *\n * This can be contrasted with the default behavior of TypeScript, which is to require the intersection of the possible types for input APIs,\n * which for unknown schema defining input trees results in the `never` type.\n *\n * Any APIs which use this must produce UsageErrors when out of schema data is encountered, and never produce unrecoverable errors,\n * or silently accept invalid data.\n * This is currently only type exported from the package: the symbol is just used as a way to get a named type.\n * @alpha\n */\nexport type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;\n\n/**\n * Content which could be inserted into a tree.\n *\n * @see {@link Input}\n * @remarks\n * Extended version of {@link InsertableTreeNodeFromImplicitAllowedTypes} that also allows {@link (UnsafeUnknownSchema:type)}.\n * @alpha\n */\nexport type Insertable<TSchema extends ImplicitAllowedTypes | UnsafeUnknownSchema> =\n\tTSchema extends ImplicitAllowedTypes\n\t\t? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t: InsertableContent;\n\n/**\n * Content which could be inserted into a field within a tree.\n *\n * @see {@link Input}\n * @remarks\n * Extended version of {@link InsertableTreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * @alpha\n */\nexport type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? InsertableTreeFieldFromImplicitField<TSchema>\n\t: [TSchema] extends [UnsafeUnknownSchema]\n\t\t? InsertableContent | undefined\n\t\t: never;\n\n/**\n * Content which could be read from a field within a tree.\n *\n * @remarks\n * Extended version of {@link TreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * Since reading from fields with non-exact schema is still safe, this is only useful (compared to {@link TreeFieldFromImplicitField}) when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}\n * for use\n * @system @alpha\n */\nexport type ReadableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =\n\tTreeFieldFromImplicitField<ReadSchema<TSchema>>;\n\n/**\n * Adapter to remove {@link (UnsafeUnknownSchema:type)} from a schema type so it can be used with types for generating APIs for reading data.\n *\n * @remarks\n * Since reading with non-exact schema is still safe, this is mainly useful when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}.\n * @system @alpha\n */\nexport type ReadSchema<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? TSchema\n\t: ImplicitFieldSchema;\n\n/**\n * Suitable for output.\n * For input must error on side of excluding undefined instead.\n * @system @public\n */\nexport type ApplyKind<T, Kind extends FieldKind> = {\n\t[FieldKind.Required]: T;\n\t[FieldKind.Optional]: T | undefined;\n\t[FieldKind.Identifier]: T;\n}[Kind];\n\n/**\n * Suitable for input.\n *\n * @see {@link Input}\n * @system @public\n */\nexport type ApplyKindInput<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = [\n\tKind,\n] extends [FieldKind.Required]\n\t? T\n\t: [Kind] extends [FieldKind.Optional]\n\t\t? T | undefined\n\t\t: [Kind] extends [FieldKind.Identifier]\n\t\t\t? DefaultsAreOptional extends true\n\t\t\t\t? T | undefined\n\t\t\t\t: T\n\t\t\t: never;\n\n/**\n * Type of tree node for a field of the given schema.\n * @public\n */\nexport type TreeNodeFromImplicitAllowedTypes<\n\tTSchema extends ImplicitAllowedTypes = TreeNodeSchema,\n> = TSchema extends TreeNodeSchema\n\t? NodeFromSchema<TSchema>\n\t: TSchema extends AllowedTypes\n\t\t? NodeFromSchema<FlexListToUnion<TSchema>>\n\t\t: unknown;\n\n/**\n * This type exists only to be linked from documentation to provide a single linkable place to document some details of\n * \"Input\" types and how they handle schema.\n *\n * When a schema is used to describe data which is an input into an API, the API is [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) over the schema.\n * (See also, [TypeScript Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)).\n *\n * Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.\n *\n * Consider a field with schema type of `A | B` (where A and B are types of schema).\n *\n * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.\n * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.\n *\n * Note that this is distinct from the case where the schema is `[A, B]`.\n * In this case it is known that the field allows both A and B (the field can be set to an A or a B value).\n * When `A | B` is used, the field might allow\n * A but not B (so assigning a B value would be out of schema),\n * B but not A (so assigning an A value would be out of schema)\n * or both A and B.\n *\n * This gets more extreme when given completely unspecified schema.\n * For example if a field is just provided {@link ImplicitFieldSchema}, nothing is known about the content of the field.\n * This means that reading the field (via {@link TreeFieldFromImplicitField}) can give any valid tree field content,\n * but there are no safe values which could be written to the field (since it is unknown what values would be out of schema) so {@link InsertableTreeFieldFromImplicitField} gives `never`.\n *\n * To implement this variance correctly, the computation of types for input and output have to use separate utilities\n * which take very different approaches when encountering non-exact schema like unions or `ImplicitFieldSchema`.\n * The utilities which behave contravariantly (as required to handle input correctly) link this documentation to indicate that this is how they behave.\n *\n * In addition to behaving contravariantly, these input type computation utilities often have further limitations.\n * This is due to TypeScript making it difficult to implement this contravariance exactly.\n * When faced with these implementation limitations these contravariant type computation utilities error on the side of producing overly strict requirements.\n * For example in the above case of `A | B`, the utilities might compute an allowed insertable type as `never` even if there happens to be a common value accepted by both `A` and `B`.\n * Future versions of the API can relax these requirements as the type computations are made more accurate.\n *\n * For a more concrete example: if {@link InsertableTreeFieldFromImplicitField} produced `never` for a schema `A | OptionalField<A>`,\n * a future version could instead return a more flexible but still safe type, like `A`.\n *\n * More generally: try to avoid providing non-exact schema, especially for the fields of other schema.\n * While these APIs attempt to handle such cases correctly, there are limitations and known bugs in this handling.\n * Code using non-exact schema is much more likely to have its compilation break due to updates of this package or even TypeScript,\n * and thus compilation breaks due to edge cases of non-exact schema handling, especially with recursive schema, are not considered breaking changes.\n * This may change as the API become more stable.\n *\n * @privateRemarks\n * There likely is a better way to share this documentation, but none was found at the time of writing.\n *\n * TODO: Once {@link InsertableField} is public, consider using it in the examples above.\n * @system @public\n */\nexport type Input<T extends never> = T;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchema - Schema to process.\n *\n * @privateRemarks\n * This is a bit overly conservative, since cases like `A | [A]` give never and could give `A`.\n * @public\n */\nexport type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes> =\n\t[TSchema] extends [TreeNodeSchema]\n\t\t? InsertableTypedNode<TSchema>\n\t\t: [TSchema] extends [AllowedTypes]\n\t\t\t? InsertableTreeNodeFromAllowedTypes<TSchema>\n\t\t\t: never;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TList - AllowedTypes to process\n * @system @public\n */\nexport type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =\n\tTList extends readonly [\n\t\tLazyItem<infer TSchema extends TreeNodeSchema>,\n\t\t...infer Rest extends AllowedTypes,\n\t]\n\t\t? InsertableTypedNode<TSchema> | InsertableTreeNodeFromAllowedTypes<Rest>\n\t\t: never;\n\n/**\n * Takes in `TreeNodeSchema[]` and returns a TypedNode union.\n * @privateRemarks\n * If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.\n * @public\n */\nexport type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<\n\tstring,\n\tNodeKind,\n\tinfer TNode\n>\n\t? TNode\n\t: T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode>\n\t\t? TNode\n\t\t: never;\n\n/**\n * Data which can be used as a node to be inserted.\n * Either an unhydrated node, or content to build a new node.\n *\n * @see {@link Input}\n *\n * @typeparam TSchemaInput - Schema to process.\n * @typeparam T - Do not specify: default value used as implementation detail.\n * @privateRemarks\n * This can't really be fully correct, since TreeNodeSchema's TNode is generally use covariantly but this code uses it contravariantly.\n * That makes this TreeNodeSchema actually invariant with respect to TNode, but doing that would break all `extends TreeNodeSchema` clauses.\n * As is, this works correctly in most realistic use-cases.\n *\n * One special case this makes is if the result of NodeFromSchema contains TreeNode, this must be an under constrained schema, so the result is set to never.\n * Note that applying UnionToIntersection on the result of NodeFromSchema<T> does not work since it breaks booleans.\n *\n * @public\n */\nexport type InsertableTypedNode<\n\tTSchema extends TreeNodeSchema,\n\tT = UnionToIntersection<TSchema>,\n> =\n\t| (T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, never, true>\n\t\t\t? NodeBuilderData<T>\n\t\t\t: never)\n\t| (T extends TreeNodeSchema\n\t\t\t? Unhydrated<TreeNode extends NodeFromSchema<T> ? never : NodeFromSchema<T>>\n\t\t\t: never);\n\n/**\n * Given a node's schema, return the corresponding object from which the node could be built.\n * @privateRemarks\n * This uses TreeNodeSchemaCore, and thus depends on TreeNodeSchemaCore.createFromInsertable for the typing.\n * This works almost the same as using TreeNodeSchema,\n * except that the more complex typing in TreeNodeSchema case breaks for non-class schema and leaks in `undefined` from optional crete parameters.\n * @system @public\n */\nexport type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boolean>> =\n\tT extends TreeNodeSchemaCore<string, NodeKind, boolean, unknown, infer TBuild>\n\t\t? TBuild\n\t\t: never;\n\n/**\n * Value that may be stored as a leaf node.\n * @remarks\n * Some limitations apply, see the documentation for {@link schemaStatics.number} and {@link schemaStatics.string} for those restrictions.\n * @public\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport type TreeLeafValue = number | string | boolean | IFluidHandle | null;\n\n/**\n * Additional information to provide to Node Schema creation.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the Node Schema.\n * See {@link NodeSchemaMetadata.custom}.\n *\n * @sealed\n * @public\n */\nexport interface NodeSchemaOptions<out TCustomMetadata = unknown> {\n\t/**\n\t * Optional metadata to associate with the Node Schema.\n\t *\n\t * @remarks\n\t * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.\n\t * Different clients in the same collaborative session may see different metadata for the same field.\n\t */\n\treadonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;\n}\n\n/**\n * Metadata associated with a Node Schema.\n *\n * @remarks Specified via {@link NodeSchemaOptions.metadata}.\n *\n * @sealed\n * @public\n */\nexport interface NodeSchemaMetadata<out TCustomMetadata = unknown> {\n\t/**\n\t * User-defined metadata.\n\t */\n\treadonly custom?: TCustomMetadata | undefined;\n\n\t/**\n\t * The description of the Node Schema.\n\t *\n\t * @remarks\n\t *\n\t * If provided, will be used by the system in scenarios where a description of the kind of node is useful.\n\t * E.g., when converting a Node Schema to {@link https://json-schema.org/ | JSON Schema}, this description will be\n\t * used as the `description` property.\n\t */\n\treadonly description?: string | undefined;\n}\n"]}
1
+ {"version":3,"file":"schemaTypes.js","sourceRoot":"","sources":["../../src/simple-tree/schemaTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA2D;AAC3D,uEAAsE;AAGtE,+CAS0B;AAU1B,8CAAmD;AAGnD,+CAA4E;AAC5E,2DAAqD;AACrD,yDAAmD;AAGnD;;;GAGG;AACH,SAAgB,qBAAqB,CAQpC,MAE2F;IAS3F,OAAO,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC;AACzC,CAAC;AApBD,sDAoBC;AAqBD;;;;;GAKG;AACH,IAAY,SAmBX;AAnBD,WAAY,SAAS;IACpB;;;;OAIG;IACH,iDAAQ,CAAA;IACR;;;;OAIG;IACH,iDAAQ,CAAA;IACR;;;;OAIG;IACH,qDAAU,CAAA;AACX,CAAC,EAnBW,SAAS,yBAAT,SAAS,QAmBpB;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,WAAmB,EAAE,WAAgC;IACjF,OAAO,IAAA,gBAAK,EAAC,oBAAoB,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,CAAC;AAChE,CAAC;AAFD,oCAEC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,WAAgC;IACpE,OAAO,WAAW,YAAY,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC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AAC,SAAS,CAC3B,MAAM,CAAC,UAAU,CACjB,oEAAoE,CACrE,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,MAA+C,CAAC;IACpE,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;SAAM,CAAC;QACP,WAAW,CAAC,eAAe,EAAE,CAAC;IAC/B,CAAC;AACF,CAAC;AAvBD,sDAuBC;AA8ED;;;GAGG;AACU,QAAA,mBAAmB,GAAkB,MAAM,CAAC,qBAAqB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { NodeIdentifierManager } from \"../feature-libraries/index.js\";\nimport {\n\ttype MakeNominal,\n\tbrand,\n\tisReadonlyArray,\n\ttype UnionToIntersection,\n\tcompareSets,\n\ttype requireTrue,\n\ttype areOnlyKeys,\n\tgetOrCreate,\n} from \"../util/index.js\";\nimport type {\n\tUnhydrated,\n\tNodeKind,\n\tTreeNodeSchema,\n\tTreeNodeSchemaClass,\n\tTreeNode,\n\tTreeNodeSchemaCore,\n\tTreeNodeSchemaNonClass,\n} from \"./core/index.js\";\nimport { inPrototypeChain } from \"./core/index.js\";\nimport type { FieldKey } from \"../core/index.js\";\nimport type { InsertableContent } from \"./toMapTree.js\";\nimport { isLazy, type FlexListToUnion, type LazyItem } from \"./flexList.js\";\nimport { LeafNodeSchema } from \"./leafNodeSchema.js\";\nimport { TreeNodeValid } from \"./treeNodeValid.js\";\nimport type { SimpleFieldSchema, SimpleObjectFieldSchema } from \"./simpleSchema.js\";\n\n/**\n * Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.\n * @internal\n */\nexport function isTreeNodeSchemaClass<\n\tName extends string,\n\tKind extends NodeKind,\n\tTNode extends TreeNode | TreeLeafValue,\n\tTBuild,\n\tImplicitlyConstructable extends boolean,\n\tInfo,\n>(\n\tschema:\n\t\t| TreeNodeSchema<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>\n\t\t| TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>,\n): schema is TreeNodeSchemaClass<\n\tName,\n\tKind,\n\tTNode & TreeNode,\n\tTBuild,\n\tImplicitlyConstructable,\n\tInfo\n> {\n\treturn schema.constructor !== undefined;\n}\n\n/**\n * Types for use in fields.\n * @remarks\n * Type constraint used in schema declaration APIs.\n *\n * The order of types in the array is not significant.\n * Additionally, it is legal for users of this type to have the runtime and compile time order of items within this array not match.\n * Therefor to ensure type safety, these arrays should not be indexed, and instead just be iterated.\n *\n * Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)\n * way to declare and manipulate unordered sets of types in TypeScript.\n *\n * Not intended for direct use outside of package.\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @system @public\n */\nexport type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];\n\n/**\n * Kind of a field on a node.\n * @remarks\n * More kinds may be added over time, so do not assume this is an exhaustive set.\n * @public\n */\nexport enum FieldKind {\n\t/**\n\t * A field which can be empty or filled.\n\t * @remarks\n\t * Allows 0 or one child.\n\t */\n\tOptional,\n\t/**\n\t * A field which must always be filled.\n\t * @remarks\n\t * Only allows exactly one child.\n\t */\n\tRequired,\n\t/**\n\t * A special field used for node identifiers.\n\t * @remarks\n\t * Only allows exactly one child.\n\t */\n\tIdentifier,\n}\n\n/**\n * Maps from a property key to its corresponding {@link FieldProps.key | stored key} for the provided\n * {@link ImplicitFieldSchema | field schema}.\n *\n * @remarks\n * If an explicit stored key was specified in the schema, it will be used.\n * Otherwise, the stored key is the same as the property key.\n */\nexport function getStoredKey(propertyKey: string, fieldSchema: ImplicitFieldSchema): FieldKey {\n\treturn brand(getExplicitStoredKey(fieldSchema) ?? propertyKey);\n}\n\n/**\n * Gets the {@link FieldProps.key | stored key} specified by the schema, if one was explicitly specified.\n * Otherwise, returns undefined.\n */\nexport function getExplicitStoredKey(fieldSchema: ImplicitFieldSchema): string | undefined {\n\treturn fieldSchema instanceof FieldSchema ? fieldSchema.props?.key : undefined;\n}\n\n/**\n * Additional information to provide to a {@link FieldSchema}.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @public\n */\nexport interface FieldProps<TCustomMetadata = unknown> {\n\t/**\n\t * The unique identifier of a field, used in the persisted form of the tree.\n\t *\n\t * @remarks\n\t * If not explicitly set via the schema, this is the same as the schema's property key.\n\t *\n\t * Specifying a stored key that differs from the property key is particularly useful in refactoring scenarios.\n\t * To update the developer-facing API, while maintaining backwards compatibility with existing SharedTree data,\n\t * you can change the property key and specify the previous property key as the stored key.\n\t *\n\t * Notes:\n\t *\n\t * - Stored keys have no impact on standard JavaScript behavior, on tree nodes. For example, `Object.keys`\n\t * will always return the property keys specified in the schema, ignoring any stored keys that differ from\n\t * the property keys.\n\t *\n\t * - When specifying stored keys in an object schema, you must ensure that the final set of stored keys\n\t * (accounting for those implicitly derived from property keys) contains no duplicates.\n\t * This is validated at runtime.\n\t *\n\t * @example Refactoring code without breaking compatibility with existing data\n\t *\n\t * Consider some existing object schema:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \txPosition: schemaFactory.number,\n\t * \tyPosition: schemaFactory.number,\n\t * \tzPosition: schemaFactory.optional(schemaFactory.number),\n\t * });\n\t * ```\n\t *\n\t * Developers using nodes of this type would access the the `xPosition` property as `point.xPosition`.\n\t *\n\t * We would like to refactor the schema to omit \"Position\" from the property keys, but application data has\n\t * already been persisted using the original property keys. To maintain compatibility with existing data,\n\t * we can refactor the schema as follows:\n\t *\n\t * ```TypeScript\n\t * class Point extends schemaFactory.object(\"Point\", {\n\t * \tx: schemaFactory.required(schemaFactory.number, { key: \"xPosition\" }),\n\t * \ty: schemaFactory.required(schemaFactory.number, { key: \"yPosition\" }),\n\t * \tz: schemaFactory.optional(schemaFactory.number, { key: \"zPosition\" }),\n\t * });\n\t * ```\n\t *\n\t * Now, developers can access the `x` property as `point.x`, while existing data can still be collaborated on.\n\t *\n\t * @defaultValue If not specified, the key that is persisted is the property key that was specified in the schema.\n\t */\n\treadonly key?: string;\n\n\t/**\n\t * A default provider used for fields which were not provided any values.\n\t * @privateRemarks\n\t * We are using an erased type here, as we want to expose this API but `InsertableContent` and `NodeKeyManager` are not public.\n\t */\n\treadonly defaultProvider?: DefaultProvider;\n\n\t/**\n\t * Optional metadata to associate with the field.\n\t *\n\t * @remarks\n\t * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.\n\t * Different clients in the same collaborative session may see different metadata for the same field.\n\t */\n\treadonly metadata?: FieldSchemaMetadata<TCustomMetadata>;\n}\n\n/**\n * A {@link FieldProvider} which requires additional context in order to produce its content\n */\nexport type ContextualFieldProvider = (\n\tcontext: NodeIdentifierManager,\n) => InsertableContent | undefined;\n/**\n * A {@link FieldProvider} which can produce its content in a vacuum\n */\nexport type ConstantFieldProvider = () => InsertableContent | undefined;\n/**\n * A function which produces content for a field every time that it is called\n */\nexport type FieldProvider = ContextualFieldProvider | ConstantFieldProvider;\n/**\n * Returns true if the given {@link FieldProvider} is a {@link ConstantFieldProvider}\n */\nexport function isConstant(\n\tfieldProvider: FieldProvider,\n): fieldProvider is ConstantFieldProvider {\n\treturn fieldProvider.length === 0;\n}\n\n/**\n * Provides a default value for a field.\n * @remarks\n * If present in a `FieldSchema`, when constructing new tree content that field can be omitted, and a default will be provided.\n * @system @sealed @public\n */\nexport interface DefaultProvider extends ErasedType<\"@fluidframework/tree.FieldProvider\"> {}\n\nexport function extractFieldProvider(input: DefaultProvider): FieldProvider {\n\treturn input as unknown as FieldProvider;\n}\n\nexport function getDefaultProvider(input: FieldProvider): DefaultProvider {\n\treturn input as unknown as DefaultProvider;\n}\n\n/**\n * Metadata associated with a {@link FieldSchema}.\n *\n * @remarks Specified via {@link FieldProps.metadata}.\n *\n * @sealed\n * @public\n */\nexport interface FieldSchemaMetadata<TCustomMetadata = unknown> {\n\t/**\n\t * User-defined metadata.\n\t */\n\treadonly custom?: TCustomMetadata;\n\n\t/**\n\t * The description of the field.\n\t *\n\t * @remarks\n\t *\n\t * If provided, will be used by the system in scenarios where a description of the field is useful.\n\t * E.g., when converting a field schema to {@link https://json-schema.org/ | JSON Schema}, this description will be\n\t * used as the `description` field.\n\t */\n\treadonly description?: string | undefined;\n}\n\n/**\n * Package internal construction API.\n */\nexport let createFieldSchema: <\n\tKind extends FieldKind = FieldKind,\n\tTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tallowedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n) => FieldSchemaAlpha<Kind, Types, TCustomMetadata>;\n\n/**\n * All policy for a specific field,\n * including functionality that does not have to be kept consistent across versions or deterministic.\n *\n * This can include policy for how to use this schema for \"view\" purposes, and well as how to expose editing APIs.\n * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link SchemaStatics.optional}.\n * @privateRemarks\n * Public access to the constructor is removed to prevent creating expressible but unsupported (or not stable) configurations.\n * {@link createFieldSchema} can be used internally to create instances.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.\n * See {@link FieldSchemaMetadata.custom}.\n *\n * @remarks\n * All implementations of this are actually {@link FieldSchemaAlpha} which exposes some additional alpha APIs.\n *\n * @sealed @public\n */\nexport class FieldSchema<\n\tout Kind extends FieldKind = FieldKind,\n\tout Types extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\tout TCustomMetadata = unknown,\n> {\n\t/**\n\t * This class is used with instanceof, and therefore should have nominal typing.\n\t * This field enforces that.\n\t */\n\tprotected _typeCheck!: MakeNominal;\n\n\tprivate readonly lazyTypes: Lazy<ReadonlySet<TreeNodeSchema>>;\n\n\t/**\n\t * What types of tree nodes are allowed in this field.\n\t * @remarks Counterpart to {@link FieldSchema.allowedTypes}, with any lazy definitions evaluated.\n\t */\n\tpublic get allowedTypeSet(): ReadonlySet<TreeNodeSchema> {\n\t\treturn this.lazyTypes.value;\n\t}\n\n\t/**\n\t * True if and only if, when constructing a node with this field, a value must be provided for it.\n\t */\n\tpublic readonly requiresValue: boolean;\n\n\t/**\n\t * {@inheritDoc FieldProps.metadata}\n\t */\n\tpublic get metadata(): FieldSchemaMetadata<TCustomMetadata> {\n\t\treturn this.props?.metadata ?? {};\n\t}\n\n\t/**\n\t * This class is `@sealed`: protected members like this constructor are for internal use only.\n\t * Use {@link SchemaFactory} to create the FieldSchema instances.\n\t */\n\tprotected constructor(\n\t\t/**\n\t\t * The {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind } of this field.\n\t\t * Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.\n\t\t */\n\t\tpublic readonly kind: Kind,\n\t\t/**\n\t\t * What types of tree nodes are allowed in this field.\n\t\t */\n\t\tpublic readonly allowedTypes: Types,\n\t\t/**\n\t\t * Optional properties associated with the field.\n\t\t */\n\t\tpublic readonly props?: FieldProps<TCustomMetadata>,\n\t) {\n\t\tif (!(this instanceof FieldSchemaAlpha)) {\n\t\t\tthrow new UsageError(\"FieldSchema is @sealed: sub-classing is not allowed.\");\n\t\t}\n\n\t\tthis.lazyTypes = new Lazy(() => normalizeAllowedTypes(this.allowedTypes));\n\t\t// TODO: optional fields should (by default) get a default provider that returns undefined, removing the need to special case them here:\n\t\tthis.requiresValue =\n\t\t\tthis.props?.defaultProvider === undefined && this.kind !== FieldKind.Optional;\n\t}\n}\n\n/**\n * {@link FieldSchema} including alpha APIs (currently {@link SimpleFieldSchema}).\n * @remarks\n * This class will go away once the alpha APIs are stable and implemented by {@link FieldSchema}.\n * @sealed @alpha\n */\nexport class FieldSchemaAlpha<\n\t\tKind extends FieldKind = FieldKind,\n\t\tTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchema<Kind, Types, TCustomMetadata>\n\timplements SimpleFieldSchema\n{\n\tprivate readonly lazyIdentifiers: Lazy<ReadonlySet<string>>;\n\n\tstatic {\n\t\tcreateFieldSchema = <\n\t\t\tKind2 extends FieldKind = FieldKind,\n\t\t\tTypes2 extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t\t\tTCustomMetadata2 = unknown,\n\t\t>(\n\t\t\tkind: Kind2,\n\t\t\tallowedTypes: Types2,\n\t\t\tprops?: FieldProps<TCustomMetadata2>,\n\t\t) => new FieldSchemaAlpha(kind, allowedTypes, props);\n\t}\n\n\tprotected constructor(kind: Kind, allowedTypes: Types, props?: FieldProps<TCustomMetadata>) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.lazyIdentifiers = new Lazy(\n\t\t\t() => new Set([...this.allowedTypeSet].map((t) => t.identifier)),\n\t\t);\n\t}\n\n\tpublic get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\treturn this.lazyIdentifiers.value;\n\t}\n}\n\n/**\n * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.\n */\nexport class ObjectFieldSchema<\n\t\tKind extends FieldKind = FieldKind,\n\t\tTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchemaAlpha<Kind, Types, TCustomMetadata>\n\timplements SimpleObjectFieldSchema\n{\n\tpublic readonly storedKey: string;\n\n\tpublic constructor(\n\t\tkind: Kind,\n\t\tallowedTypes: Types,\n\t\tprops: FieldProps<TCustomMetadata> & { readonly key: string },\n\t) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.storedKey = props.key;\n\t}\n}\n\n/**\n * Normalizes a {@link ImplicitFieldSchema} to a {@link FieldSchema}.\n */\nexport function normalizeFieldSchema(schema: ImplicitFieldSchema): FieldSchemaAlpha {\n\treturn schema instanceof FieldSchema\n\t\t? (schema as FieldSchemaAlpha)\n\t\t: createFieldSchema(FieldKind.Required, schema);\n}\n/**\n * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any\n * lazy schema declarations.\n *\n * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of\n * recursive schemas may fail.\n *\n * @internal\n */\nexport function normalizeAllowedTypes(\n\ttypes: ImplicitAllowedTypes,\n): ReadonlySet<TreeNodeSchema> {\n\tconst normalized = new Set<TreeNodeSchema>();\n\tif (isReadonlyArray(types)) {\n\t\t// Types array must not be modified after it is normalized since that would result in the user of the normalized data having wrong (out of date) content.\n\t\tObject.freeze(types);\n\t\tfor (const lazyType of types) {\n\t\t\tnormalized.add(evaluateLazySchema(lazyType));\n\t\t}\n\t} else {\n\t\tnormalized.add(evaluateLazySchema(types));\n\t}\n\treturn normalized;\n}\n\n/**\n * Returns true if the given {@link ImplicitFieldSchema} are equivalent, otherwise false.\n * @remarks Two ImplicitFieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be (respectively) reference equal.\n *\n * For example, comparing an ImplicitFieldSchema that is a {@link TreeNodeSchema} to an ImplicitFieldSchema that is a {@link FieldSchema}\n * will return true if they are the same kind, the FieldSchema has exactly one allowed type (the TreeNodeSchema), and they have equivalent FieldProps.\n */\nexport function areImplicitFieldSchemaEqual(\n\ta: ImplicitFieldSchema,\n\tb: ImplicitFieldSchema,\n): boolean {\n\treturn areFieldSchemaEqual(normalizeFieldSchema(a), normalizeFieldSchema(b));\n}\n\n/**\n * Returns true if the given {@link FieldSchema} are equivalent, otherwise false.\n * @remarks Two FieldSchema are considered equivalent if all of the following are true:\n * 1. They have the same {@link FieldKind | kinds}.\n * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.\n * 3. They have the same exact set of allowed types. The allowed types must be reference equal.\n */\nexport function areFieldSchemaEqual(a: FieldSchema, b: FieldSchema): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.kind !== b.kind) {\n\t\treturn false;\n\t}\n\n\tif (!areFieldPropsEqual(a.props, b.props)) {\n\t\treturn false;\n\t}\n\n\treturn compareSets({ a: a.allowedTypeSet, b: b.allowedTypeSet });\n}\n\n/**\n * Returns true if the given {@link FieldProps} are equivalent, otherwise false.\n * @remarks FieldProps are considered equivalent if their keys and default providers are reference equal, and their metadata are {@link areMetadataEqual | equivalent}.\n */\nfunction areFieldPropsEqual(a: FieldProps | undefined, b: FieldProps | undefined): boolean {\n\t// If any new fields are added to FieldProps, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<areOnlyKeys<FieldProps, \"key\" | \"defaultProvider\" | \"metadata\">>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a?.key !== b?.key || a?.defaultProvider !== b?.defaultProvider) {\n\t\treturn false;\n\t}\n\n\tif (!areMetadataEqual(a?.metadata, b?.metadata)) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns true if the given {@link FieldSchemaMetadata} are equivalent, otherwise false.\n * @remarks FieldSchemaMetadata are considered equivalent if their custom data and descriptions are (respectively) reference equal.\n */\nfunction areMetadataEqual(\n\ta: FieldSchemaMetadata | undefined,\n\tb: FieldSchemaMetadata | undefined,\n): boolean {\n\t// If any new fields are added to FieldSchemaMetadata, this check will stop compiling as a reminder that this function needs to be updated.\n\ttype _keys = requireTrue<areOnlyKeys<FieldSchemaMetadata, \"custom\" | \"description\">>;\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\treturn a?.custom === b?.custom && a?.description === b?.description;\n}\n\nconst cachedLazyItem = new WeakMap<() => unknown, unknown>();\n\n/**\n * Returns the schema referenced by the {@link LazyItem}.\n * @remarks\n * Caches results to handle {@link LazyItem}s which compute their resulting schema.\n * @alpha\n */\nexport function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T {\n\tconst evaluatedSchema = isLazy(value)\n\t\t? (getOrCreate(cachedLazyItem, value, value) as T)\n\t\t: value;\n\tif (evaluatedSchema === undefined) {\n\t\tthrow new UsageError(\n\t\t\t`Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated.`,\n\t\t);\n\t}\n\tmarkSchemaMostDerived(evaluatedSchema);\n\treturn evaluatedSchema;\n}\n\n/**\n * Indicates that the provided schema is the \"most derived\" version in its class hierarchy.\n *\n * @param oneTimeInitialize - If true this runs {@link TreeNodeValid.oneTimeInitialize} which does even more initialization and validation.\n * `oneTimeInitialize` can't safely be run until all transitively referenced schema are defined, so which cases can safely use it are more limited.\n * When legal for the caller to set this to true, it is preferred, but it is often not safe due to possible forward references.\n * @remarks\n * See {@link MostDerivedData} and {@link SchemaFactory} for details on what a \"most derived\" schema is and why it matters.\n *\n * This is a helper for invoking {@link TreeNodeValid.markMostDerived} for {@link TreeNodeSchema}.\n *\n * Calling this helps with error messages about invalid schema usage (See {@link SchemaFactory} for the rules, some of which this helps validate).\n * Typically this should be called for each schema as early as practical to improve error reporting for invalid usages of schema\n * (using two different schema derived from the same {@link SchemaFactory} produced base class).\n *\n * Note that construction of actual {@link TreeNode} instances or use of a schema transitively in a {@link TreeViewConfiguration} already do this,\n * so any calls to this that is unconditionally after that point for the given schema is not needed.\n * Instead most usages of this should be from those cases, and from miscellaneous cases where a schema is passed into an public API where theoretically someone could accidentally\n * pass in a base class of a schema instead of the most derived one.\n */\nexport function markSchemaMostDerived(\n\tschema: TreeNodeSchema,\n\toneTimeInitialize = false,\n): void {\n\tif (schema instanceof LeafNodeSchema) {\n\t\treturn;\n\t}\n\n\tif (!inPrototypeChain(schema, TreeNodeValid)) {\n\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\tthrow new UsageError(\n\t\t\t`Schema for ${JSON.stringify(\n\t\t\t\tschema.identifier,\n\t\t\t)} does not extend a SchemaFactory generated class. This is invalid.`,\n\t\t);\n\t}\n\n\tconst schemaValid = schema as typeof TreeNodeValid & TreeNodeSchema;\n\tif (oneTimeInitialize) {\n\t\tschemaValid.oneTimeInitialize();\n\t} else {\n\t\tschemaValid.markMostDerived();\n\t}\n}\n\n/**\n * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.\n * @remarks\n * Used by {@link TreeViewConfiguration} for the root and various kinds of {@link TreeNodeSchema} to specify their allowed child types.\n *\n * Use {@link SchemaFactory} to access leaf schema or declare new composite schema.\n *\n * Implicitly treats a single type as an array of one type.\n *\n * Arrays of schema can be used to specify multiple types are allowed, which result in unions of those types in the Tree APIs.\n *\n * When saved into variables, avoid type-erasing the details, as doing so loses the compile time schema awareness of APIs derived from the types.\n *\n * When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.\n * See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.\n *\n * @example Explicit use with strong typing\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * const childTypes = [sf.number, sf.string] as const satisfies ImplicitAllowedTypes;\n * const config = new TreeViewConfiguration({ schema: childTypes });\n * ```\n *\n * @example Forward reference\n * ```typescript\n * const sf = new SchemaFactory(\"myScope\");\n * class A extends sf.array(\"example\", [() => B]) {}\n * class B extends sf.array(\"Inner\", sf.number) {}\n * ```\n * @privateRemarks\n * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.\n * @public\n */\nexport type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;\n\n/**\n * Schema for a field of a tree node.\n * @remarks\n * Implicitly treats {@link ImplicitAllowedTypes} as a Required field of that type.\n * @public\n */\nexport type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;\n\n/**\n * Converts an `ImplicitFieldSchema` to a property type suitable for reading a field with this that schema.\n *\n * @typeparam TSchema - When non-exact schema are provided this errors on the side of returning too general of a type (a conservative union of all possibilities).\n * This is ideal for \"output APIs\" - i.e. it converts the schema type to the runtime type that a user will _read_ from the tree.\n * Examples of such \"non-exact\" schema include `ImplicitFieldSchema`, `ImplicitAllowedTypes`, and TypeScript unions of schema types.\n * @public\n */\nexport type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> =\n\tTSchema extends FieldSchema<infer Kind, infer Types>\n\t\t? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind>\n\t\t: TSchema extends ImplicitAllowedTypes\n\t\t\t? TreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t\t: TreeNode | TreeLeafValue | undefined;\n\n/**\n * Type of content that can be inserted into the tree for a field of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchemaInput - Schema to process.\n * @typeparam TSchema - Do not specify: default value used as implementation detail.\n * @public\n */\nexport type InsertableTreeFieldFromImplicitField<\n\tTSchemaInput extends ImplicitFieldSchema,\n\tTSchema = UnionToIntersection<TSchemaInput>,\n> = [TSchema] extends [FieldSchema<infer Kind, infer Types>]\n\t? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true>\n\t: [TSchema] extends [ImplicitAllowedTypes]\n\t\t? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t: never;\n\n/**\n * {@inheritdoc (UnsafeUnknownSchema:type)}\n * @alpha\n */\nexport const UnsafeUnknownSchema: unique symbol = Symbol(\"UnsafeUnknownSchema\");\n\n/**\n * A special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.\n * @remarks\n * When used, this means the TypeScript typing should err on the side of completeness (allow all inputs that could be valid).\n * This introduces the risk that out-of-schema data could be allowed at compile time, and only error at runtime.\n *\n * @privateRemarks\n * This only applies to APIs which input data which is expected to be in schema, since APIs outputting have easy mechanisms to do so in a type safe way even when the schema is unknown.\n * In most cases that amounts to returning `TreeNode | TreeLeafValue`.\n *\n * This can be contrasted with the default behavior of TypeScript, which is to require the intersection of the possible types for input APIs,\n * which for unknown schema defining input trees results in the `never` type.\n *\n * Any APIs which use this must produce UsageErrors when out of schema data is encountered, and never produce unrecoverable errors,\n * or silently accept invalid data.\n * This is currently only type exported from the package: the symbol is just used as a way to get a named type.\n * @alpha\n */\nexport type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;\n\n/**\n * Content which could be inserted into a tree.\n *\n * @see {@link Input}\n * @remarks\n * Extended version of {@link InsertableTreeNodeFromImplicitAllowedTypes} that also allows {@link (UnsafeUnknownSchema:type)}.\n * @alpha\n */\nexport type Insertable<TSchema extends ImplicitAllowedTypes | UnsafeUnknownSchema> =\n\tTSchema extends ImplicitAllowedTypes\n\t\t? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>\n\t\t: InsertableContent;\n\n/**\n * Content which could be inserted into a field within a tree.\n *\n * @see {@link Input}\n * @remarks\n * Extended version of {@link InsertableTreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * @alpha\n */\nexport type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? InsertableTreeFieldFromImplicitField<TSchema>\n\t: [TSchema] extends [UnsafeUnknownSchema]\n\t\t? InsertableContent | undefined\n\t\t: never;\n\n/**\n * Content which could be read from a field within a tree.\n *\n * @remarks\n * Extended version of {@link TreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.\n * Since reading from fields with non-exact schema is still safe, this is only useful (compared to {@link TreeFieldFromImplicitField}) when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}\n * for use\n * @system @alpha\n */\nexport type ReadableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =\n\tTreeFieldFromImplicitField<ReadSchema<TSchema>>;\n\n/**\n * Adapter to remove {@link (UnsafeUnknownSchema:type)} from a schema type so it can be used with types for generating APIs for reading data.\n *\n * @remarks\n * Since reading with non-exact schema is still safe, this is mainly useful when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}.\n * @system @alpha\n */\nexport type ReadSchema<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [\n\tTSchema,\n] extends [ImplicitFieldSchema]\n\t? TSchema\n\t: ImplicitFieldSchema;\n\n/**\n * Suitable for output.\n * For input must error on side of excluding undefined instead.\n * @system @public\n */\nexport type ApplyKind<T, Kind extends FieldKind> = {\n\t[FieldKind.Required]: T;\n\t[FieldKind.Optional]: T | undefined;\n\t[FieldKind.Identifier]: T;\n}[Kind];\n\n/**\n * Suitable for input.\n *\n * @see {@link Input}\n * @system @public\n */\nexport type ApplyKindInput<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = [\n\tKind,\n] extends [FieldKind.Required]\n\t? T\n\t: [Kind] extends [FieldKind.Optional]\n\t\t? T | undefined\n\t\t: [Kind] extends [FieldKind.Identifier]\n\t\t\t? DefaultsAreOptional extends true\n\t\t\t\t? T | undefined\n\t\t\t\t: T\n\t\t\t: never;\n\n/**\n * Type of tree node for a field of the given schema.\n * @public\n */\nexport type TreeNodeFromImplicitAllowedTypes<\n\tTSchema extends ImplicitAllowedTypes = TreeNodeSchema,\n> = TSchema extends TreeNodeSchema\n\t? NodeFromSchema<TSchema>\n\t: TSchema extends AllowedTypes\n\t\t? NodeFromSchema<FlexListToUnion<TSchema>>\n\t\t: unknown;\n\n/**\n * This type exists only to be linked from documentation to provide a single linkable place to document some details of\n * \"Input\" types and how they handle schema.\n *\n * When a schema is used to describe data which is an input into an API, the API is [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) over the schema.\n * (See also, [TypeScript Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)).\n *\n * Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.\n *\n * Consider a field with schema type of `A | B` (where A and B are types of schema).\n *\n * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.\n * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.\n *\n * Note that this is distinct from the case where the schema is `[A, B]`.\n * In this case it is known that the field allows both A and B (the field can be set to an A or a B value).\n * When `A | B` is used, the field might allow\n * A but not B (so assigning a B value would be out of schema),\n * B but not A (so assigning an A value would be out of schema)\n * or both A and B.\n *\n * This gets more extreme when given completely unspecified schema.\n * For example if a field is just provided {@link ImplicitFieldSchema}, nothing is known about the content of the field.\n * This means that reading the field (via {@link TreeFieldFromImplicitField}) can give any valid tree field content,\n * but there are no safe values which could be written to the field (since it is unknown what values would be out of schema) so {@link InsertableTreeFieldFromImplicitField} gives `never`.\n *\n * To implement this variance correctly, the computation of types for input and output have to use separate utilities\n * which take very different approaches when encountering non-exact schema like unions or `ImplicitFieldSchema`.\n * The utilities which behave contravariantly (as required to handle input correctly) link this documentation to indicate that this is how they behave.\n *\n * In addition to behaving contravariantly, these input type computation utilities often have further limitations.\n * This is due to TypeScript making it difficult to implement this contravariance exactly.\n * When faced with these implementation limitations these contravariant type computation utilities error on the side of producing overly strict requirements.\n * For example in the above case of `A | B`, the utilities might compute an allowed insertable type as `never` even if there happens to be a common value accepted by both `A` and `B`.\n * Future versions of the API can relax these requirements as the type computations are made more accurate.\n *\n * For a more concrete example: if {@link InsertableTreeFieldFromImplicitField} produced `never` for a schema `A | OptionalField<A>`,\n * a future version could instead return a more flexible but still safe type, like `A`.\n *\n * More generally: try to avoid providing non-exact schema, especially for the fields of other schema.\n * While these APIs attempt to handle such cases correctly, there are limitations and known bugs in this handling.\n * Code using non-exact schema is much more likely to have its compilation break due to updates of this package or even TypeScript,\n * and thus compilation breaks due to edge cases of non-exact schema handling, especially with recursive schema, are not considered breaking changes.\n * This may change as the API become more stable.\n *\n * @privateRemarks\n * There likely is a better way to share this documentation, but none was found at the time of writing.\n *\n * TODO: Once {@link InsertableField} is public, consider using it in the examples above.\n * @system @public\n */\nexport type Input<T extends never> = T;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TSchema - Schema to process.\n *\n * @privateRemarks\n * This is a bit overly conservative, since cases like `A | [A]` give never and could give `A`.\n * @public\n */\nexport type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes> =\n\t[TSchema] extends [TreeNodeSchema]\n\t\t? InsertableTypedNode<TSchema>\n\t\t: [TSchema] extends [AllowedTypes]\n\t\t\t? InsertableTreeNodeFromAllowedTypes<TSchema>\n\t\t\t: never;\n\n/**\n * Type of content that can be inserted into the tree for a node of the given schema.\n *\n * @see {@link Input}\n *\n * @typeparam TList - AllowedTypes to process\n * @system @public\n */\nexport type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =\n\tTList extends readonly [\n\t\tLazyItem<infer TSchema extends TreeNodeSchema>,\n\t\t...infer Rest extends AllowedTypes,\n\t]\n\t\t? InsertableTypedNode<TSchema> | InsertableTreeNodeFromAllowedTypes<Rest>\n\t\t: never;\n\n/**\n * Takes in `TreeNodeSchema[]` and returns a TypedNode union.\n * @privateRemarks\n * If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.\n * @public\n */\nexport type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<\n\tstring,\n\tNodeKind,\n\tinfer TNode\n>\n\t? TNode\n\t: T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode>\n\t\t? TNode\n\t\t: never;\n\n/**\n * Data which can be used as a node to be inserted.\n * Either an unhydrated node, or content to build a new node.\n *\n * @see {@link Input}\n *\n * @typeparam TSchemaInput - Schema to process.\n * @typeparam T - Do not specify: default value used as implementation detail.\n * @privateRemarks\n * This can't really be fully correct, since TreeNodeSchema's TNode is generally use covariantly but this code uses it contravariantly.\n * That makes this TreeNodeSchema actually invariant with respect to TNode, but doing that would break all `extends TreeNodeSchema` clauses.\n * As is, this works correctly in most realistic use-cases.\n *\n * One special case this makes is if the result of NodeFromSchema contains TreeNode, this must be an under constrained schema, so the result is set to never.\n * Note that applying UnionToIntersection on the result of NodeFromSchema<T> does not work since it breaks booleans.\n *\n * @public\n */\nexport type InsertableTypedNode<\n\tTSchema extends TreeNodeSchema,\n\tT = UnionToIntersection<TSchema>,\n> =\n\t| (T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, never, true>\n\t\t\t? NodeBuilderData<T>\n\t\t\t: never)\n\t| (T extends TreeNodeSchema\n\t\t\t? Unhydrated<TreeNode extends NodeFromSchema<T> ? never : NodeFromSchema<T>>\n\t\t\t: never);\n\n/**\n * Given a node's schema, return the corresponding object from which the node could be built.\n * @privateRemarks\n * This uses TreeNodeSchemaCore, and thus depends on TreeNodeSchemaCore.createFromInsertable for the typing.\n * This works almost the same as using TreeNodeSchema,\n * except that the more complex typing in TreeNodeSchema case breaks for non-class schema and leaks in `undefined` from optional crete parameters.\n * @system @public\n */\nexport type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boolean>> =\n\tT extends TreeNodeSchemaCore<string, NodeKind, boolean, unknown, infer TBuild>\n\t\t? TBuild\n\t\t: never;\n\n/**\n * Value that may be stored as a leaf node.\n * @remarks\n * Some limitations apply, see the documentation for {@link SchemaStatics.number} and {@link SchemaStatics.string} for those restrictions.\n * @public\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport type TreeLeafValue = number | string | boolean | IFluidHandle | null;\n\n/**\n * Additional information to provide to Node Schema creation.\n *\n * @typeParam TCustomMetadata - Custom metadata properties to associate with the Node Schema.\n * See {@link NodeSchemaMetadata.custom}.\n *\n * @sealed\n * @public\n */\nexport interface NodeSchemaOptions<out TCustomMetadata = unknown> {\n\t/**\n\t * Optional metadata to associate with the Node Schema.\n\t *\n\t * @remarks\n\t * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.\n\t * Different clients in the same collaborative session may see different metadata for the same field.\n\t */\n\treadonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;\n}\n\n/**\n * Metadata associated with a Node Schema.\n *\n * @remarks Specified via {@link NodeSchemaOptions.metadata}.\n *\n * @sealed\n * @public\n */\nexport interface NodeSchemaMetadata<out TCustomMetadata = unknown> {\n\t/**\n\t * User-defined metadata.\n\t */\n\treadonly custom?: TCustomMetadata | undefined;\n\n\t/**\n\t * The description of the Node Schema.\n\t *\n\t * @remarks\n\t *\n\t * If provided, will be used by the system in scenarios where a description of the kind of node is useful.\n\t * E.g., when converting a Node Schema to {@link https://json-schema.org/ | JSON Schema}, this description will be\n\t * used as the `description` property.\n\t */\n\treadonly description?: string | undefined;\n}\n"]}
@@ -2,78 +2,97 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ValueSchema } from "../../core/index.js";
6
- import type { NodeKind } from "../core/index.js";
7
- import type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from "../schemaTypes.js";
5
+ import type { ValueSchema } from "../core/index.js";
6
+ import type { NodeKind } from "./core/index.js";
7
+ import type { FieldKind, FieldSchemaMetadata, NodeSchemaMetadata } from "./schemaTypes.js";
8
8
  /**
9
- * Base interface for all {@link SimpleNodeSchema} implementations.
10
- *
11
- * @internal
9
+ * Base interface for {@link TreeNodeSchema} and {@link SimpleNodeSchema} types.
10
+ * Once simple schema is stable this doesn't have a reason to be kept `@system`, but it could be.
11
+ * @system
12
+ * @public
12
13
  * @sealed
13
14
  */
14
- export interface SimpleNodeSchemaBase<TNodeKind extends NodeKind> {
15
+ export interface SimpleNodeSchemaBase<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> {
15
16
  /**
16
- * The kind of {@link SimpleNodeSchema}.
17
+ * The {@link NodeKind}.
17
18
  *
18
19
  * @remarks can be used to type-switch between implementations.
19
20
  */
20
21
  readonly kind: TNodeKind;
21
22
  /**
22
- * {@inheritDoc NodeSchemaMetadata}
23
+ * User-provided {@link NodeSchemaMetadata} for this schema.
23
24
  */
24
- readonly metadata?: NodeSchemaMetadata | undefined;
25
+ readonly metadata: NodeSchemaMetadata<TCustomMetadata>;
25
26
  }
26
27
  /**
27
28
  * A {@link SimpleNodeSchema} for an object node.
28
29
  *
29
- * @internal
30
+ * @alpha
30
31
  * @sealed
31
32
  */
32
- export interface SimpleObjectNodeSchema extends SimpleNodeSchemaBase<NodeKind.Object> {
33
+ export interface SimpleObjectNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<NodeKind.Object, TCustomMetadata> {
33
34
  /**
34
35
  * Schemas for each of the object's fields, keyed off of schema's keys.
35
36
  * @remarks
36
- * Depending on how this schema was exported, the string keys may be either the property keys or the stored keys.
37
+ * The keys are the property keys if known, otherwise they are the stored keys.
38
+ * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.
37
39
  * @privateRemarks
38
- * TODO: if these are supposed to be JSON compatible,
39
- * then using a record here makes sense, but if not, this should use a map, and the allowedTypes sets elsewhere should be arrays for JSON compatibility.
40
+ * TODO: Provide and link a way to translate from stored keys to the property keys.
41
+ * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,
42
+ * especially if/when TreeNodeSchema for objects provide more maps.
43
+ */
44
+ readonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;
45
+ }
46
+ /**
47
+ * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.
48
+ * @remarks
49
+ * The only other case fields are uses in the root schema.
50
+ *
51
+ * @alpha
52
+ * @sealed
53
+ */
54
+ export interface SimpleObjectFieldSchema extends SimpleFieldSchema {
55
+ /**
56
+ * The stored key of the field.
57
+ * @remarks
58
+ * See {@link FieldProps.key} for more information.
40
59
  */
41
- readonly fields: Record<string, SimpleFieldSchema>;
60
+ readonly storedKey: string;
42
61
  }
43
62
  /**
44
63
  * A {@link SimpleNodeSchema} for an array node.
45
64
  *
46
- * @internal
65
+ * @alpha
47
66
  * @sealed
48
67
  */
49
- export interface SimpleArrayNodeSchema extends SimpleNodeSchemaBase<NodeKind.Array> {
68
+ export interface SimpleArrayNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<NodeKind.Array, TCustomMetadata> {
50
69
  /**
51
70
  * The types allowed in the array.
52
71
  *
53
72
  * @remarks Refers to the types by identifier.
54
73
  * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
55
74
  */
56
- readonly allowedTypes: ReadonlySet<string>;
75
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
57
76
  }
58
77
  /**
59
78
  * A {@link SimpleNodeSchema} for a map node.
60
79
  *
61
- * @internal
80
+ * @alpha
62
81
  * @sealed
63
82
  */
64
- export interface SimpleMapNodeSchema extends SimpleNodeSchemaBase<NodeKind.Map> {
83
+ export interface SimpleMapNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<NodeKind.Map, TCustomMetadata> {
65
84
  /**
66
85
  * The types allowed as values in the map.
67
86
  *
68
87
  * @remarks Refers to the types by identifier.
69
88
  * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
70
89
  */
71
- readonly allowedTypes: ReadonlySet<string>;
90
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
72
91
  }
73
92
  /**
74
93
  * A {@link SimpleNodeSchema} for a leaf node.
75
94
  *
76
- * @internal
95
+ * @alpha
77
96
  * @sealed
78
97
  */
79
98
  export interface SimpleLeafNodeSchema extends SimpleNodeSchemaBase<NodeKind.Leaf> {
@@ -89,7 +108,12 @@ export interface SimpleLeafNodeSchema extends SimpleNodeSchemaBase<NodeKind.Leaf
89
108
  * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which
90
109
  * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.
91
110
  *
92
- * @internal
111
+ * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,
112
+ * and therefore code should not assume that switching over all these cases can be done exhaustively.
113
+ * @privateRemarks
114
+ * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?
115
+ *
116
+ * @alpha
93
117
  */
94
118
  export type SimpleNodeSchema = SimpleLeafNodeSchema | SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleObjectNodeSchema;
95
119
  /**
@@ -99,7 +123,7 @@ export type SimpleNodeSchema = SimpleLeafNodeSchema | SimpleMapNodeSchema | Simp
99
123
  * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which
100
124
  * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.
101
125
  *
102
- * @internal
126
+ * @alpha
103
127
  * @sealed
104
128
  */
105
129
  export interface SimpleFieldSchema {
@@ -113,11 +137,11 @@ export interface SimpleFieldSchema {
113
137
  * @remarks Refers to the types by identifier.
114
138
  * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
115
139
  */
116
- readonly allowedTypes: ReadonlySet<string>;
140
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
117
141
  /**
118
142
  * {@inheritDoc FieldSchemaMetadata}
119
143
  */
120
- readonly metadata?: FieldSchemaMetadata | undefined;
144
+ readonly metadata: FieldSchemaMetadata;
121
145
  }
122
146
  /**
123
147
  * A simplified representation of a schema for a tree.
@@ -125,7 +149,7 @@ export interface SimpleFieldSchema {
125
149
  * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,
126
150
  * which are represented inline with identifiers.
127
151
  *
128
- * @internal
152
+ * @alpha
129
153
  * @sealed
130
154
  */
131
155
  export interface SimpleTreeSchema extends SimpleFieldSchema {
@@ -139,9 +163,9 @@ export interface SimpleTreeSchema extends SimpleFieldSchema {
139
163
  * @remarks Refers to the types by identifier.
140
164
  * Can be resolved via {@link SimpleTreeSchema.definitions}.
141
165
  */
142
- readonly allowedTypes: ReadonlySet<string>;
166
+ readonly allowedTypesIdentifiers: ReadonlySet<string>;
143
167
  /**
144
- * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypes}.
168
+ * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypesIdentifiers}.
145
169
  *
146
170
  * @remarks the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.
147
171
  */
@@ -0,0 +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,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAO3F;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB,CACpC,GAAG,CAAC,SAAS,SAAS,QAAQ,EAC9B,GAAG,CAAC,eAAe,GAAG,OAAO;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;CACvD;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CACpE,SAAQ,oBAAoB,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAC9D;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;CAC9D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IACjE;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,M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,CAAC;CAC5D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleSchema.js","sourceRoot":"","sources":["../../src/simple-tree/simpleSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ValueSchema } from \"../core/index.js\";\nimport type { 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} for an object node.\n *\n * @alpha\n * @sealed\n */\nexport interface SimpleObjectNodeSchema<out TCustomMetadata = unknown>\n\textends SimpleNodeSchemaBase<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 SimpleNodeSchemaBase<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 SimpleNodeSchemaBase<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 SimpleNodeSchemaBase<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\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 extends SimpleFieldSchema {\n\t/**\n\t * The kind of tree field representing the root of the tree.\n\t */\n\treadonly kind: FieldKind;\n\n\t/**\n\t * The types allowed under the tree root.\n\t *\n\t * @remarks Refers to the types by identifier.\n\t * Can be resolved via {@link SimpleTreeSchema.definitions}.\n\t */\n\treadonly allowedTypesIdentifiers: ReadonlySet<string>;\n\n\t/**\n\t * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.allowedTypesIdentifiers}.\n\t *\n\t * @remarks the keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.\n\t */\n\treadonly definitions: ReadonlyMap<string, SimpleNodeSchema>;\n}\n"]}
@@ -85,7 +85,7 @@ function nodeDataToMapTree(data, allowedTypes) {
85
85
  result = objectToMapTree(data, schema);
86
86
  break;
87
87
  default:
88
- (0, index_js_3.fail)(0xae0 /* Unrecognized schema kind */);
88
+ (0, internal_1.fail)(0xae0 /* Unrecognized schema kind */);
89
89
  }
90
90
  return result;
91
91
  }
@@ -441,7 +441,7 @@ function allowsValue(schema, value) {
441
441
  */
442
442
  function addDefaultsToMapTree(mapTree, allowedTypes, context) {
443
443
  const schema = (0, index_js_3.find)((0, schemaTypes_js_1.normalizeAllowedTypes)(allowedTypes), (s) => s.identifier === mapTree.type) ??
444
- (0, index_js_3.fail)(0xae1 /* MapTree is incompatible with schema */);
444
+ (0, internal_1.fail)(0xae1 /* MapTree is incompatible with schema */);
445
445
  if ((0, objectNodeTypes_js_1.isObjectNodeSchema)(schema)) {
446
446
  for (const [_key, fieldInfo] of schema.flexKeyMap) {
447
447
  const field = mapTree.fields.get(fieldInfo.storedKey);
@@ -459,7 +459,7 @@ function addDefaultsToMapTree(mapTree, allowedTypes, context) {
459
459
  setFieldValue(mapTree.fields, data, fieldInfo.schema, fieldInfo.storedKey);
460
460
  // call addDefaultsToMapTree on newly inserted default values
461
461
  for (const child of mapTree.fields.get(fieldInfo.storedKey) ??
462
- (0, index_js_3.fail)(0xae2 /* Expected field to be populated */)) {
462
+ (0, internal_1.fail)(0xae2 /* Expected field to be populated */)) {
463
463
  addDefaultsToMapTree(child, fieldInfo.schema.allowedTypes, context);
464
464
  }
465
465
  }