@fluidframework/tree 2.23.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 (1027) hide show
  1. package/CHANGELOG.md +1636 -1466
  2. package/api-extractor/api-extractor.current.json +0 -3
  3. package/api-report/tree.alpha.api.md +261 -100
  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 +32 -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/forest/editableForest.d.ts +1 -14
  18. package/dist/core/forest/editableForest.d.ts.map +1 -1
  19. package/dist/core/forest/editableForest.js +1 -28
  20. package/dist/core/forest/editableForest.js.map +1 -1
  21. package/dist/core/forest/forest.d.ts +16 -3
  22. package/dist/core/forest/forest.d.ts.map +1 -1
  23. package/dist/core/forest/forest.js +4 -1
  24. package/dist/core/forest/forest.js.map +1 -1
  25. package/dist/core/forest/index.d.ts +1 -1
  26. package/dist/core/forest/index.d.ts.map +1 -1
  27. package/dist/core/forest/index.js +1 -2
  28. package/dist/core/forest/index.js.map +1 -1
  29. package/dist/core/index.d.ts +2 -2
  30. package/dist/core/index.d.ts.map +1 -1
  31. package/dist/core/index.js +3 -3
  32. package/dist/core/index.js.map +1 -1
  33. package/dist/core/rebase/utils.js +1 -1
  34. package/dist/core/rebase/utils.js.map +1 -1
  35. package/dist/core/schema-stored/schema.d.ts +4 -1
  36. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  37. package/dist/core/schema-stored/schema.js +8 -4
  38. package/dist/core/schema-stored/schema.js.map +1 -1
  39. package/dist/core/tree/anchorSet.d.ts +8 -3
  40. package/dist/core/tree/anchorSet.d.ts.map +1 -1
  41. package/dist/core/tree/anchorSet.js +16 -9
  42. package/dist/core/tree/anchorSet.js.map +1 -1
  43. package/dist/core/tree/delta.d.ts +8 -23
  44. package/dist/core/tree/delta.d.ts.map +1 -1
  45. package/dist/core/tree/delta.js.map +1 -1
  46. package/dist/core/tree/deltaUtil.d.ts +3 -3
  47. package/dist/core/tree/deltaUtil.d.ts.map +1 -1
  48. package/dist/core/tree/deltaUtil.js +2 -2
  49. package/dist/core/tree/deltaUtil.js.map +1 -1
  50. package/dist/core/tree/index.d.ts +2 -2
  51. package/dist/core/tree/index.d.ts.map +1 -1
  52. package/dist/core/tree/index.js +2 -1
  53. package/dist/core/tree/index.js.map +1 -1
  54. package/dist/core/tree/pathTree.d.ts +54 -1
  55. package/dist/core/tree/pathTree.d.ts.map +1 -1
  56. package/dist/core/tree/pathTree.js +8 -1
  57. package/dist/core/tree/pathTree.js.map +1 -1
  58. package/dist/core/tree/treeTextFormat.js +2 -2
  59. package/dist/core/tree/treeTextFormat.js.map +1 -1
  60. package/dist/core/tree/visitDelta.d.ts +7 -5
  61. package/dist/core/tree/visitDelta.d.ts.map +1 -1
  62. package/dist/core/tree/visitDelta.js +19 -9
  63. package/dist/core/tree/visitDelta.js.map +1 -1
  64. package/dist/core/tree/visitorUtils.d.ts +5 -23
  65. package/dist/core/tree/visitorUtils.d.ts.map +1 -1
  66. package/dist/core/tree/visitorUtils.js +8 -5
  67. package/dist/core/tree/visitorUtils.js.map +1 -1
  68. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  69. package/dist/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  70. package/dist/feature-libraries/chunked-forest/basicChunk.js +9 -9
  71. package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  72. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  73. package/dist/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  74. package/dist/feature-libraries/chunked-forest/chunkTree.js +12 -9
  75. package/dist/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  76. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  77. package/dist/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  78. package/dist/feature-libraries/chunked-forest/chunkedForest.js +8 -5
  79. package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  80. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +3 -3
  81. package/dist/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  82. package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
  83. package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  84. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  85. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +4 -4
  86. package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  87. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  88. package/dist/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  89. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  90. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  91. package/dist/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +4 -5
  92. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  93. package/dist/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  94. package/dist/feature-libraries/chunked-forest/emptyChunk.js +15 -15
  95. package/dist/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  96. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  97. package/dist/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  98. package/dist/feature-libraries/chunked-forest/uniformChunk.js +7 -6
  99. package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  100. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  101. package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  102. package/dist/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  103. package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  104. package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  105. package/dist/feature-libraries/default-schema/defaultFieldKinds.js +19 -19
  106. package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  107. package/dist/feature-libraries/default-schema/index.d.ts +1 -0
  108. package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
  109. package/dist/feature-libraries/default-schema/index.js +3 -1
  110. package/dist/feature-libraries/default-schema/index.js.map +1 -1
  111. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  112. package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  113. package/dist/feature-libraries/default-schema/mappedEditBuilder.js +57 -0
  114. package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  115. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  116. package/dist/feature-libraries/default-schema/schemaChecker.js +1 -2
  117. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  118. package/dist/feature-libraries/deltaUtils.js +1 -1
  119. package/dist/feature-libraries/deltaUtils.js.map +1 -1
  120. package/dist/feature-libraries/flex-tree/context.d.ts +5 -5
  121. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  122. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  123. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  124. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  125. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  126. package/dist/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  127. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  128. package/dist/feature-libraries/flex-tree/lazyField.js +12 -9
  129. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  130. package/dist/feature-libraries/flex-tree/lazyNode.js +4 -4
  131. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  132. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  133. package/dist/feature-libraries/forest-summary/forestSummarizer.js +4 -5
  134. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  135. package/dist/feature-libraries/index.d.ts +2 -1
  136. package/dist/feature-libraries/index.d.ts.map +1 -1
  137. package/dist/feature-libraries/index.js +9 -7
  138. package/dist/feature-libraries/index.js.map +1 -1
  139. package/dist/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  140. package/dist/feature-libraries/indexing/anchorTreeIndex.js +1 -1
  141. package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  142. package/dist/feature-libraries/initializeForest.d.ts +18 -0
  143. package/dist/feature-libraries/initializeForest.d.ts.map +1 -0
  144. package/dist/feature-libraries/initializeForest.js +35 -0
  145. package/dist/feature-libraries/initializeForest.js.map +1 -0
  146. package/dist/feature-libraries/modular-schema/comparison.js +4 -4
  147. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  148. package/dist/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  149. package/dist/feature-libraries/modular-schema/isNeverTree.js +2 -3
  150. package/dist/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  151. package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  152. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +4 -4
  153. package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  154. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  155. package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  156. package/dist/feature-libraries/modular-schema/modularChangeFamily.js +13 -19
  157. package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  158. package/dist/feature-libraries/node-identifier/index.d.ts +8 -0
  159. package/dist/feature-libraries/node-identifier/index.d.ts.map +1 -0
  160. package/dist/feature-libraries/node-identifier/index.js +16 -0
  161. package/dist/feature-libraries/node-identifier/index.js.map +1 -0
  162. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  163. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  164. package/dist/feature-libraries/{node-key/mockNodeKeyManager.js → node-identifier/mockNodeIdentifierManager.js} +18 -18
  165. package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  166. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  167. package/dist/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  168. package/dist/feature-libraries/node-identifier/nodeIdentifier.js +26 -0
  169. package/dist/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  170. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  171. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  172. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +48 -0
  173. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  174. package/dist/feature-libraries/object-forest/objectForest.d.ts +2 -1
  175. package/dist/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  176. package/dist/feature-libraries/object-forest/objectForest.js +7 -3
  177. package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
  178. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  179. package/dist/feature-libraries/schema-index/codec.js +2 -1
  180. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  181. package/dist/feature-libraries/sequence-field/compose.d.ts +1 -1
  182. package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  183. package/dist/feature-libraries/sequence-field/compose.js +16 -17
  184. package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
  185. package/dist/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  186. package/dist/feature-libraries/sequence-field/invert.js +1 -1
  187. package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
  188. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  189. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
  190. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  191. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  192. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
  193. package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  194. package/dist/feature-libraries/sequence-field/utils.js +1 -1
  195. package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
  196. package/dist/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  197. package/dist/feature-libraries/treeCursorUtils.js +5 -6
  198. package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
  199. package/dist/index.d.ts +5 -4
  200. package/dist/index.d.ts.map +1 -1
  201. package/dist/index.js +15 -3
  202. package/dist/index.js.map +1 -1
  203. package/dist/jsonDomainSchema.d.ts +15 -16
  204. package/dist/jsonDomainSchema.d.ts.map +1 -1
  205. package/dist/jsonDomainSchema.js +10 -5
  206. package/dist/jsonDomainSchema.js.map +1 -1
  207. package/dist/legacy.d.ts +5 -1
  208. package/dist/packageVersion.d.ts +1 -1
  209. package/dist/packageVersion.js +1 -1
  210. package/dist/packageVersion.js.map +1 -1
  211. package/dist/public.d.ts +5 -1
  212. package/dist/serializableDomainSchema.d.ts +8 -14
  213. package/dist/serializableDomainSchema.d.ts.map +1 -1
  214. package/dist/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  215. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  216. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  217. package/dist/shared-tree/independentView.d.ts.map +1 -1
  218. package/dist/shared-tree/independentView.js +3 -18
  219. package/dist/shared-tree/independentView.js.map +1 -1
  220. package/dist/shared-tree/index.d.ts +1 -1
  221. package/dist/shared-tree/index.d.ts.map +1 -1
  222. package/dist/shared-tree/index.js +2 -1
  223. package/dist/shared-tree/index.js.map +1 -1
  224. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  225. package/dist/shared-tree/schematizeTree.js +4 -3
  226. package/dist/shared-tree/schematizeTree.js.map +1 -1
  227. package/dist/shared-tree/schematizingTreeView.d.ts +4 -4
  228. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  229. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  230. package/dist/shared-tree/sharedTree.d.ts +1 -0
  231. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  232. package/dist/shared-tree/sharedTree.js +27 -19
  233. package/dist/shared-tree/sharedTree.js.map +1 -1
  234. package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  235. package/dist/shared-tree/sharedTreeChangeFamily.js +2 -2
  236. package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  237. package/dist/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  238. package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  239. package/dist/shared-tree/sharedTreeEditBuilder.js +2 -2
  240. package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  241. package/dist/shared-tree/treeApiAlpha.d.ts +9 -30
  242. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  243. package/dist/shared-tree/treeApiAlpha.js +22 -34
  244. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  245. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  246. package/dist/shared-tree/treeCheckout.js +2 -2
  247. package/dist/shared-tree/treeCheckout.js.map +1 -1
  248. package/dist/shared-tree-core/branch.d.ts +4 -3
  249. package/dist/shared-tree-core/branch.d.ts.map +1 -1
  250. package/dist/shared-tree-core/branch.js +2 -2
  251. package/dist/shared-tree-core/branch.js.map +1 -1
  252. package/dist/shared-tree-core/editManager.d.ts.map +1 -1
  253. package/dist/shared-tree-core/editManager.js +37 -31
  254. package/dist/shared-tree-core/editManager.js.map +1 -1
  255. package/dist/sharedTreeAttributes.d.ts +18 -0
  256. package/dist/sharedTreeAttributes.d.ts.map +1 -0
  257. package/dist/sharedTreeAttributes.js +25 -0
  258. package/dist/sharedTreeAttributes.js.map +1 -0
  259. package/dist/simple-tree/api/conciseTree.d.ts +8 -2
  260. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  261. package/dist/simple-tree/api/conciseTree.js +10 -1
  262. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  263. package/dist/simple-tree/api/create.d.ts +3 -3
  264. package/dist/simple-tree/api/create.d.ts.map +1 -1
  265. package/dist/simple-tree/api/create.js.map +1 -1
  266. package/dist/simple-tree/api/customTree.d.ts +42 -12
  267. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  268. package/dist/simple-tree/api/customTree.js +33 -5
  269. package/dist/simple-tree/api/customTree.js.map +1 -1
  270. package/dist/simple-tree/api/getJsonSchema.d.ts +10 -0
  271. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  272. package/dist/simple-tree/api/getJsonSchema.js +10 -0
  273. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  274. package/dist/simple-tree/api/getSimpleSchema.d.ts +13 -43
  275. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  276. package/dist/simple-tree/api/getSimpleSchema.js +13 -43
  277. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  278. package/dist/simple-tree/api/index.d.ts +7 -6
  279. package/dist/simple-tree/api/index.d.ts.map +1 -1
  280. package/dist/simple-tree/api/index.js +8 -1
  281. package/dist/simple-tree/api/index.js.map +1 -1
  282. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  283. package/dist/simple-tree/api/schemaCreationUtilities.js +2 -2
  284. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  285. package/dist/simple-tree/api/schemaFactory.d.ts +112 -67
  286. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  287. package/dist/simple-tree/api/schemaFactory.js +80 -158
  288. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  289. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +38 -23
  290. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  291. package/dist/simple-tree/api/schemaFactoryAlpha.js +26 -1
  292. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  293. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  294. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  295. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  296. package/dist/simple-tree/api/schemaFromSimple.d.ts +19 -0
  297. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  298. package/dist/simple-tree/api/schemaFromSimple.js +71 -0
  299. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -0
  300. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  301. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  302. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +7 -6
  303. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  304. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  305. package/dist/simple-tree/api/simpleTreeIndex.js +4 -3
  306. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  307. package/dist/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  308. package/dist/simple-tree/api/tree.d.ts +12 -6
  309. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  310. package/dist/simple-tree/api/tree.js +17 -8
  311. package/dist/simple-tree/api/tree.js.map +1 -1
  312. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  313. package/dist/simple-tree/api/treeNodeApi.js +5 -20
  314. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  315. package/dist/simple-tree/api/typesUnsafe.d.ts +102 -36
  316. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  317. package/dist/simple-tree/api/typesUnsafe.js +0 -1
  318. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  319. package/dist/simple-tree/api/verboseTree.d.ts +16 -25
  320. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  321. package/dist/simple-tree/api/verboseTree.js +19 -14
  322. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  323. package/dist/simple-tree/api/view.d.ts.map +1 -1
  324. package/dist/simple-tree/api/view.js +16 -17
  325. package/dist/simple-tree/api/view.js.map +1 -1
  326. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  327. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  328. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +70 -147
  329. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  330. package/dist/simple-tree/arrayNode.d.ts +5 -4
  331. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  332. package/dist/simple-tree/arrayNode.js +13 -9
  333. package/dist/simple-tree/arrayNode.js.map +1 -1
  334. package/dist/simple-tree/arrayNodeTypes.d.ts +46 -0
  335. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  336. package/dist/simple-tree/arrayNodeTypes.js +30 -0
  337. package/dist/simple-tree/arrayNodeTypes.js.map +1 -0
  338. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  339. package/dist/simple-tree/core/getOrCreateNode.js +1 -11
  340. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  341. package/dist/simple-tree/core/index.d.ts +1 -2
  342. package/dist/simple-tree/core/index.d.ts.map +1 -1
  343. package/dist/simple-tree/core/index.js +2 -3
  344. package/dist/simple-tree/core/index.js.map +1 -1
  345. package/dist/simple-tree/core/treeNodeKernel.d.ts +12 -5
  346. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  347. package/dist/simple-tree/core/treeNodeKernel.js +36 -20
  348. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  349. package/dist/simple-tree/core/treeNodeSchema.d.ts +14 -7
  350. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  351. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  352. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  353. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  354. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -5
  355. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  356. package/dist/simple-tree/flexList.d.ts +4 -5
  357. package/dist/simple-tree/flexList.d.ts.map +1 -1
  358. package/dist/simple-tree/flexList.js +1 -14
  359. package/dist/simple-tree/flexList.js.map +1 -1
  360. package/dist/simple-tree/index.d.ts +9 -2
  361. package/dist/simple-tree/index.d.ts.map +1 -1
  362. package/dist/simple-tree/index.js +15 -2
  363. package/dist/simple-tree/index.js.map +1 -1
  364. package/dist/simple-tree/leafNodeSchema.d.ts +22 -5
  365. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  366. package/dist/simple-tree/leafNodeSchema.js +2 -0
  367. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  368. package/dist/simple-tree/mapNode.d.ts +3 -2
  369. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  370. package/dist/simple-tree/mapNode.js +5 -1
  371. package/dist/simple-tree/mapNode.js.map +1 -1
  372. package/dist/simple-tree/mapNodeTypes.d.ts +46 -0
  373. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -0
  374. package/dist/simple-tree/mapNodeTypes.js +30 -0
  375. package/dist/simple-tree/mapNodeTypes.js.map +1 -0
  376. package/dist/simple-tree/objectNode.d.ts +10 -3
  377. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  378. package/dist/simple-tree/objectNode.js +12 -5
  379. package/dist/simple-tree/objectNode.js.map +1 -1
  380. package/dist/simple-tree/objectNodeTypes.d.ts +9 -5
  381. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  382. package/dist/simple-tree/objectNodeTypes.js +3 -0
  383. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  384. package/dist/simple-tree/proxies.js +2 -1
  385. package/dist/simple-tree/proxies.js.map +1 -1
  386. package/dist/simple-tree/schemaTypes.d.ts +81 -8
  387. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  388. package/dist/simple-tree/schemaTypes.js +94 -5
  389. package/dist/simple-tree/schemaTypes.js.map +1 -1
  390. package/dist/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +55 -28
  391. package/dist/simple-tree/simpleSchema.d.ts.map +1 -0
  392. package/dist/simple-tree/simpleSchema.js.map +1 -0
  393. package/dist/simple-tree/toMapTree.d.ts +4 -4
  394. package/dist/simple-tree/toMapTree.d.ts.map +1 -1
  395. package/dist/simple-tree/toMapTree.js +3 -3
  396. package/dist/simple-tree/toMapTree.js.map +1 -1
  397. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  398. package/dist/simple-tree/toStoredSchema.js +2 -6
  399. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  400. package/dist/simple-tree/treeNodeValid.d.ts +7 -1
  401. package/dist/simple-tree/treeNodeValid.d.ts.map +1 -1
  402. package/dist/simple-tree/treeNodeValid.js +17 -10
  403. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  404. package/dist/treeFactory.d.ts +0 -12
  405. package/dist/treeFactory.d.ts.map +1 -1
  406. package/dist/treeFactory.js +5 -21
  407. package/dist/treeFactory.js.map +1 -1
  408. package/dist/util/cloneWithReplacements.d.ts +21 -0
  409. package/dist/util/cloneWithReplacements.d.ts.map +1 -0
  410. package/dist/util/cloneWithReplacements.js +38 -0
  411. package/dist/util/cloneWithReplacements.js.map +1 -0
  412. package/dist/util/idAllocator.d.ts.map +1 -1
  413. package/dist/util/idAllocator.js +1 -2
  414. package/dist/util/idAllocator.js.map +1 -1
  415. package/dist/util/index.d.ts +2 -1
  416. package/dist/util/index.d.ts.map +1 -1
  417. package/dist/util/index.js +4 -3
  418. package/dist/util/index.js.map +1 -1
  419. package/dist/util/referenceCounting.d.ts +18 -0
  420. package/dist/util/referenceCounting.d.ts.map +1 -1
  421. package/dist/util/referenceCounting.js.map +1 -1
  422. package/dist/util/typeCheck.d.ts +7 -0
  423. package/dist/util/typeCheck.d.ts.map +1 -1
  424. package/dist/util/typeCheck.js.map +1 -1
  425. package/dist/util/utils.d.ts +0 -1
  426. package/dist/util/utils.d.ts.map +1 -1
  427. package/dist/util/utils.js +1 -4
  428. package/dist/util/utils.js.map +1 -1
  429. package/lib/alpha.d.ts +32 -1
  430. package/lib/beta.d.ts +5 -1
  431. package/lib/codec/codec.d.ts +1 -1
  432. package/lib/codec/codec.d.ts.map +1 -1
  433. package/lib/codec/codec.js +1 -2
  434. package/lib/codec/codec.js.map +1 -1
  435. package/lib/codec/discriminatedUnions.d.ts.map +1 -1
  436. package/lib/codec/discriminatedUnions.js +2 -2
  437. package/lib/codec/discriminatedUnions.js.map +1 -1
  438. package/lib/core/forest/editableForest.d.ts +1 -14
  439. package/lib/core/forest/editableForest.d.ts.map +1 -1
  440. package/lib/core/forest/editableForest.js +0 -26
  441. package/lib/core/forest/editableForest.js.map +1 -1
  442. package/lib/core/forest/forest.d.ts +16 -3
  443. package/lib/core/forest/forest.d.ts.map +1 -1
  444. package/lib/core/forest/forest.js +4 -1
  445. package/lib/core/forest/forest.js.map +1 -1
  446. package/lib/core/forest/index.d.ts +1 -1
  447. package/lib/core/forest/index.d.ts.map +1 -1
  448. package/lib/core/forest/index.js +1 -1
  449. package/lib/core/forest/index.js.map +1 -1
  450. package/lib/core/index.d.ts +2 -2
  451. package/lib/core/index.d.ts.map +1 -1
  452. package/lib/core/index.js +2 -2
  453. package/lib/core/index.js.map +1 -1
  454. package/lib/core/rebase/utils.js +1 -1
  455. package/lib/core/rebase/utils.js.map +1 -1
  456. package/lib/core/schema-stored/schema.d.ts +4 -1
  457. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  458. package/lib/core/schema-stored/schema.js +6 -2
  459. package/lib/core/schema-stored/schema.js.map +1 -1
  460. package/lib/core/tree/anchorSet.d.ts +8 -3
  461. package/lib/core/tree/anchorSet.d.ts.map +1 -1
  462. package/lib/core/tree/anchorSet.js +14 -7
  463. package/lib/core/tree/anchorSet.js.map +1 -1
  464. package/lib/core/tree/delta.d.ts +8 -23
  465. package/lib/core/tree/delta.d.ts.map +1 -1
  466. package/lib/core/tree/delta.js.map +1 -1
  467. package/lib/core/tree/deltaUtil.d.ts +3 -3
  468. package/lib/core/tree/deltaUtil.d.ts.map +1 -1
  469. package/lib/core/tree/deltaUtil.js +2 -2
  470. package/lib/core/tree/deltaUtil.js.map +1 -1
  471. package/lib/core/tree/index.d.ts +2 -2
  472. package/lib/core/tree/index.d.ts.map +1 -1
  473. package/lib/core/tree/index.js +1 -1
  474. package/lib/core/tree/index.js.map +1 -1
  475. package/lib/core/tree/pathTree.d.ts +54 -1
  476. package/lib/core/tree/pathTree.d.ts.map +1 -1
  477. package/lib/core/tree/pathTree.js +6 -0
  478. package/lib/core/tree/pathTree.js.map +1 -1
  479. package/lib/core/tree/treeTextFormat.js +1 -1
  480. package/lib/core/tree/treeTextFormat.js.map +1 -1
  481. package/lib/core/tree/visitDelta.d.ts +7 -5
  482. package/lib/core/tree/visitDelta.d.ts.map +1 -1
  483. package/lib/core/tree/visitDelta.js +19 -9
  484. package/lib/core/tree/visitDelta.js.map +1 -1
  485. package/lib/core/tree/visitorUtils.d.ts +5 -23
  486. package/lib/core/tree/visitorUtils.d.ts.map +1 -1
  487. package/lib/core/tree/visitorUtils.js +8 -5
  488. package/lib/core/tree/visitorUtils.js.map +1 -1
  489. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts +1 -1
  490. package/lib/feature-libraries/chunked-forest/basicChunk.d.ts.map +1 -1
  491. package/lib/feature-libraries/chunked-forest/basicChunk.js +3 -3
  492. package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
  493. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts +5 -3
  494. package/lib/feature-libraries/chunked-forest/chunkTree.d.ts.map +1 -1
  495. package/lib/feature-libraries/chunked-forest/chunkTree.js +12 -9
  496. package/lib/feature-libraries/chunked-forest/chunkTree.js.map +1 -1
  497. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts +1 -0
  498. package/lib/feature-libraries/chunked-forest/chunkedForest.d.ts.map +1 -1
  499. package/lib/feature-libraries/chunked-forest/chunkedForest.js +8 -5
  500. package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
  501. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js +1 -1
  502. package/lib/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.js.map +1 -1
  503. package/lib/feature-libraries/chunked-forest/codec/codecs.js +1 -1
  504. package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
  505. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.d.ts +1 -1
  506. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
  507. package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
  508. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js +2 -2
  509. package/lib/feature-libraries/chunked-forest/codec/nodeShape.js.map +1 -1
  510. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.d.ts → schemaBasedEncode.d.ts} +1 -1
  511. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.d.ts.map +1 -0
  512. package/lib/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.js → schemaBasedEncode.js} +2 -3
  513. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -0
  514. package/lib/feature-libraries/chunked-forest/emptyChunk.d.ts.map +1 -1
  515. package/lib/feature-libraries/chunked-forest/emptyChunk.js +1 -1
  516. package/lib/feature-libraries/chunked-forest/emptyChunk.js.map +1 -1
  517. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts +3 -2
  518. package/lib/feature-libraries/chunked-forest/uniformChunk.d.ts.map +1 -1
  519. package/lib/feature-libraries/chunked-forest/uniformChunk.js +5 -4
  520. package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
  521. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +12 -14
  522. package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
  523. package/lib/feature-libraries/default-schema/defaultEditBuilder.js +5 -6
  524. package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
  525. package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
  526. package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
  527. package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
  528. package/lib/feature-libraries/default-schema/index.d.ts +1 -0
  529. package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
  530. package/lib/feature-libraries/default-schema/index.js +1 -0
  531. package/lib/feature-libraries/default-schema/index.js.map +1 -1
  532. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +21 -0
  533. package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -0
  534. package/lib/feature-libraries/default-schema/mappedEditBuilder.js +53 -0
  535. package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -0
  536. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  537. package/lib/feature-libraries/default-schema/schemaChecker.js +1 -2
  538. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  539. package/lib/feature-libraries/deltaUtils.js +1 -1
  540. package/lib/feature-libraries/deltaUtils.js.map +1 -1
  541. package/lib/feature-libraries/flex-tree/context.d.ts +5 -5
  542. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  543. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  544. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +2 -2
  545. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  546. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  547. package/lib/feature-libraries/flex-tree/lazyField.d.ts +5 -4
  548. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  549. package/lib/feature-libraries/flex-tree/lazyField.js +13 -10
  550. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  551. package/lib/feature-libraries/flex-tree/lazyNode.js +2 -2
  552. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  553. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  554. package/lib/feature-libraries/forest-summary/forestSummarizer.js +6 -7
  555. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  556. package/lib/feature-libraries/index.d.ts +2 -1
  557. package/lib/feature-libraries/index.d.ts.map +1 -1
  558. package/lib/feature-libraries/index.js +2 -1
  559. package/lib/feature-libraries/index.js.map +1 -1
  560. package/lib/feature-libraries/indexing/anchorTreeIndex.d.ts.map +1 -1
  561. package/lib/feature-libraries/indexing/anchorTreeIndex.js +2 -2
  562. package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
  563. package/lib/feature-libraries/initializeForest.d.ts +18 -0
  564. package/lib/feature-libraries/initializeForest.d.ts.map +1 -0
  565. package/lib/feature-libraries/initializeForest.js +31 -0
  566. package/lib/feature-libraries/initializeForest.js.map +1 -0
  567. package/lib/feature-libraries/modular-schema/comparison.js +2 -2
  568. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  569. package/lib/feature-libraries/modular-schema/isNeverTree.d.ts.map +1 -1
  570. package/lib/feature-libraries/modular-schema/isNeverTree.js +1 -2
  571. package/lib/feature-libraries/modular-schema/isNeverTree.js.map +1 -1
  572. package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
  573. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +2 -2
  574. package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
  575. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +5 -5
  576. package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
  577. package/lib/feature-libraries/modular-schema/modularChangeFamily.js +12 -18
  578. package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
  579. package/lib/feature-libraries/node-identifier/index.d.ts +8 -0
  580. package/lib/feature-libraries/node-identifier/index.d.ts.map +1 -0
  581. package/lib/feature-libraries/node-identifier/index.js +8 -0
  582. package/lib/feature-libraries/node-identifier/index.js.map +1 -0
  583. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts +22 -0
  584. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.d.ts.map +1 -0
  585. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +45 -0
  586. package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -0
  587. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts +38 -0
  588. package/lib/feature-libraries/node-identifier/nodeIdentifier.d.ts.map +1 -0
  589. package/lib/feature-libraries/node-identifier/nodeIdentifier.js +22 -0
  590. package/lib/feature-libraries/node-identifier/nodeIdentifier.js.map +1 -0
  591. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts +37 -0
  592. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -0
  593. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +43 -0
  594. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -0
  595. package/lib/feature-libraries/object-forest/objectForest.d.ts +2 -1
  596. package/lib/feature-libraries/object-forest/objectForest.d.ts.map +1 -1
  597. package/lib/feature-libraries/object-forest/objectForest.js +8 -4
  598. package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
  599. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  600. package/lib/feature-libraries/schema-index/codec.js +2 -1
  601. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  602. package/lib/feature-libraries/sequence-field/compose.d.ts +1 -1
  603. package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
  604. package/lib/feature-libraries/sequence-field/compose.js +1 -2
  605. package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
  606. package/lib/feature-libraries/sequence-field/invert.d.ts.map +1 -1
  607. package/lib/feature-libraries/sequence-field/invert.js +2 -2
  608. package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
  609. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
  610. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +2 -2
  611. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
  612. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
  613. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +2 -2
  614. package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
  615. package/lib/feature-libraries/sequence-field/utils.js +2 -2
  616. package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
  617. package/lib/feature-libraries/treeCursorUtils.d.ts.map +1 -1
  618. package/lib/feature-libraries/treeCursorUtils.js +2 -3
  619. package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
  620. package/lib/index.d.ts +5 -4
  621. package/lib/index.d.ts.map +1 -1
  622. package/lib/index.js +5 -3
  623. package/lib/index.js.map +1 -1
  624. package/lib/jsonDomainSchema.d.ts +15 -16
  625. package/lib/jsonDomainSchema.d.ts.map +1 -1
  626. package/lib/jsonDomainSchema.js +11 -6
  627. package/lib/jsonDomainSchema.js.map +1 -1
  628. package/lib/legacy.d.ts +5 -1
  629. package/lib/packageVersion.d.ts +1 -1
  630. package/lib/packageVersion.js +1 -1
  631. package/lib/packageVersion.js.map +1 -1
  632. package/lib/public.d.ts +5 -1
  633. package/lib/serializableDomainSchema.d.ts +8 -14
  634. package/lib/serializableDomainSchema.d.ts.map +1 -1
  635. package/lib/shared-tree/checkoutFlexTreeView.d.ts +3 -3
  636. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  637. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  638. package/lib/shared-tree/independentView.d.ts.map +1 -1
  639. package/lib/shared-tree/independentView.js +5 -20
  640. package/lib/shared-tree/independentView.js.map +1 -1
  641. package/lib/shared-tree/index.d.ts +1 -1
  642. package/lib/shared-tree/index.d.ts.map +1 -1
  643. package/lib/shared-tree/index.js +1 -1
  644. package/lib/shared-tree/index.js.map +1 -1
  645. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  646. package/lib/shared-tree/schematizeTree.js +5 -4
  647. package/lib/shared-tree/schematizeTree.js.map +1 -1
  648. package/lib/shared-tree/schematizingTreeView.d.ts +4 -4
  649. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  650. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  651. package/lib/shared-tree/sharedTree.d.ts +1 -0
  652. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  653. package/lib/shared-tree/sharedTree.js +23 -16
  654. package/lib/shared-tree/sharedTree.js.map +1 -1
  655. package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
  656. package/lib/shared-tree/sharedTreeChangeFamily.js +3 -3
  657. package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
  658. package/lib/shared-tree/sharedTreeEditBuilder.d.ts +1 -2
  659. package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
  660. package/lib/shared-tree/sharedTreeEditBuilder.js +2 -2
  661. package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
  662. package/lib/shared-tree/treeApiAlpha.d.ts +9 -30
  663. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  664. package/lib/shared-tree/treeApiAlpha.js +12 -24
  665. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  666. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  667. package/lib/shared-tree/treeCheckout.js +4 -4
  668. package/lib/shared-tree/treeCheckout.js.map +1 -1
  669. package/lib/shared-tree-core/branch.d.ts +4 -3
  670. package/lib/shared-tree-core/branch.d.ts.map +1 -1
  671. package/lib/shared-tree-core/branch.js +2 -2
  672. package/lib/shared-tree-core/branch.js.map +1 -1
  673. package/lib/shared-tree-core/editManager.d.ts.map +1 -1
  674. package/lib/shared-tree-core/editManager.js +35 -29
  675. package/lib/shared-tree-core/editManager.js.map +1 -1
  676. package/lib/sharedTreeAttributes.d.ts +18 -0
  677. package/lib/sharedTreeAttributes.d.ts.map +1 -0
  678. package/lib/sharedTreeAttributes.js +22 -0
  679. package/lib/sharedTreeAttributes.js.map +1 -0
  680. package/lib/simple-tree/api/conciseTree.d.ts +8 -2
  681. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  682. package/lib/simple-tree/api/conciseTree.js +9 -1
  683. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  684. package/lib/simple-tree/api/create.d.ts +3 -3
  685. package/lib/simple-tree/api/create.d.ts.map +1 -1
  686. package/lib/simple-tree/api/create.js.map +1 -1
  687. package/lib/simple-tree/api/customTree.d.ts +42 -12
  688. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  689. package/lib/simple-tree/api/customTree.js +30 -3
  690. package/lib/simple-tree/api/customTree.js.map +1 -1
  691. package/lib/simple-tree/api/getJsonSchema.d.ts +10 -0
  692. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  693. package/lib/simple-tree/api/getJsonSchema.js +10 -0
  694. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  695. package/lib/simple-tree/api/getSimpleSchema.d.ts +13 -43
  696. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  697. package/lib/simple-tree/api/getSimpleSchema.js +13 -43
  698. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  699. package/lib/simple-tree/api/index.d.ts +7 -6
  700. package/lib/simple-tree/api/index.d.ts.map +1 -1
  701. package/lib/simple-tree/api/index.js +5 -3
  702. package/lib/simple-tree/api/index.js.map +1 -1
  703. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  704. package/lib/simple-tree/api/schemaCreationUtilities.js +1 -1
  705. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  706. package/lib/simple-tree/api/schemaFactory.d.ts +112 -67
  707. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  708. package/lib/simple-tree/api/schemaFactory.js +78 -155
  709. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  710. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +38 -23
  711. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  712. package/lib/simple-tree/api/schemaFactoryAlpha.js +27 -2
  713. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  714. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +40 -5
  715. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  716. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  717. package/lib/simple-tree/api/schemaFromSimple.d.ts +19 -0
  718. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -0
  719. package/lib/simple-tree/api/schemaFromSimple.js +67 -0
  720. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -0
  721. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +3 -2
  722. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  723. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +6 -6
  724. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  725. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  726. package/lib/simple-tree/api/simpleTreeIndex.js +2 -1
  727. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  728. package/lib/simple-tree/api/testRecursiveDomain.d.ts +10 -10
  729. package/lib/simple-tree/api/tree.d.ts +12 -6
  730. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  731. package/lib/simple-tree/api/tree.js +14 -5
  732. package/lib/simple-tree/api/tree.js.map +1 -1
  733. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  734. package/lib/simple-tree/api/treeNodeApi.js +5 -20
  735. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  736. package/lib/simple-tree/api/typesUnsafe.d.ts +102 -36
  737. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  738. package/lib/simple-tree/api/typesUnsafe.js +0 -1
  739. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  740. package/lib/simple-tree/api/verboseTree.d.ts +16 -25
  741. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  742. package/lib/simple-tree/api/verboseTree.js +16 -12
  743. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  744. package/lib/simple-tree/api/view.d.ts.map +1 -1
  745. package/lib/simple-tree/api/view.js +1 -2
  746. package/lib/simple-tree/api/view.js.map +1 -1
  747. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +16 -3
  748. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  749. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +69 -146
  750. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  751. package/lib/simple-tree/arrayNode.d.ts +5 -4
  752. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  753. package/lib/simple-tree/arrayNode.js +7 -3
  754. package/lib/simple-tree/arrayNode.js.map +1 -1
  755. package/lib/simple-tree/arrayNodeTypes.d.ts +46 -0
  756. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -0
  757. package/lib/simple-tree/arrayNodeTypes.js +26 -0
  758. package/lib/simple-tree/arrayNodeTypes.js.map +1 -0
  759. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  760. package/lib/simple-tree/core/getOrCreateNode.js +2 -12
  761. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  762. package/lib/simple-tree/core/index.d.ts +1 -2
  763. package/lib/simple-tree/core/index.d.ts.map +1 -1
  764. package/lib/simple-tree/core/index.js +1 -2
  765. package/lib/simple-tree/core/index.js.map +1 -1
  766. package/lib/simple-tree/core/treeNodeKernel.d.ts +12 -5
  767. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  768. package/lib/simple-tree/core/treeNodeKernel.js +28 -14
  769. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  770. package/lib/simple-tree/core/treeNodeSchema.d.ts +14 -7
  771. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  772. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  773. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -2
  774. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  775. package/lib/simple-tree/core/unhydratedFlexTree.js +2 -2
  776. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  777. package/lib/simple-tree/flexList.d.ts +4 -5
  778. package/lib/simple-tree/flexList.d.ts.map +1 -1
  779. package/lib/simple-tree/flexList.js +0 -12
  780. package/lib/simple-tree/flexList.js.map +1 -1
  781. package/lib/simple-tree/index.d.ts +9 -2
  782. package/lib/simple-tree/index.d.ts.map +1 -1
  783. package/lib/simple-tree/index.js +5 -2
  784. package/lib/simple-tree/index.js.map +1 -1
  785. package/lib/simple-tree/leafNodeSchema.d.ts +22 -5
  786. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  787. package/lib/simple-tree/leafNodeSchema.js +2 -0
  788. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  789. package/lib/simple-tree/mapNode.d.ts +3 -2
  790. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  791. package/lib/simple-tree/mapNode.js +5 -1
  792. package/lib/simple-tree/mapNode.js.map +1 -1
  793. package/lib/simple-tree/mapNodeTypes.d.ts +46 -0
  794. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -0
  795. package/lib/simple-tree/mapNodeTypes.js +26 -0
  796. package/lib/simple-tree/mapNodeTypes.js.map +1 -0
  797. package/lib/simple-tree/objectNode.d.ts +10 -3
  798. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  799. package/lib/simple-tree/objectNode.js +12 -5
  800. package/lib/simple-tree/objectNode.js.map +1 -1
  801. package/lib/simple-tree/objectNodeTypes.d.ts +9 -5
  802. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  803. package/lib/simple-tree/objectNodeTypes.js +3 -0
  804. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  805. package/lib/simple-tree/proxies.js +2 -1
  806. package/lib/simple-tree/proxies.js.map +1 -1
  807. package/lib/simple-tree/schemaTypes.d.ts +81 -8
  808. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  809. package/lib/simple-tree/schemaTypes.js +91 -6
  810. package/lib/simple-tree/schemaTypes.js.map +1 -1
  811. package/lib/simple-tree/{api/simpleSchema.d.ts → simpleSchema.d.ts} +55 -28
  812. package/lib/simple-tree/simpleSchema.d.ts.map +1 -0
  813. package/lib/simple-tree/simpleSchema.js.map +1 -0
  814. package/lib/simple-tree/toMapTree.d.ts +4 -4
  815. package/lib/simple-tree/toMapTree.d.ts.map +1 -1
  816. package/lib/simple-tree/toMapTree.js +2 -2
  817. package/lib/simple-tree/toMapTree.js.map +1 -1
  818. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  819. package/lib/simple-tree/toStoredSchema.js +4 -8
  820. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  821. package/lib/simple-tree/treeNodeValid.d.ts +7 -1
  822. package/lib/simple-tree/treeNodeValid.d.ts.map +1 -1
  823. package/lib/simple-tree/treeNodeValid.js +14 -7
  824. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  825. package/lib/treeFactory.d.ts +0 -12
  826. package/lib/treeFactory.d.ts.map +1 -1
  827. package/lib/treeFactory.js +1 -17
  828. package/lib/treeFactory.js.map +1 -1
  829. package/lib/tsdoc-metadata.json +1 -1
  830. package/lib/util/cloneWithReplacements.d.ts +21 -0
  831. package/lib/util/cloneWithReplacements.d.ts.map +1 -0
  832. package/lib/util/cloneWithReplacements.js +34 -0
  833. package/lib/util/cloneWithReplacements.js.map +1 -0
  834. package/lib/util/idAllocator.d.ts.map +1 -1
  835. package/lib/util/idAllocator.js +1 -2
  836. package/lib/util/idAllocator.js.map +1 -1
  837. package/lib/util/index.d.ts +2 -1
  838. package/lib/util/index.d.ts.map +1 -1
  839. package/lib/util/index.js +2 -1
  840. package/lib/util/index.js.map +1 -1
  841. package/lib/util/referenceCounting.d.ts +18 -0
  842. package/lib/util/referenceCounting.d.ts.map +1 -1
  843. package/lib/util/referenceCounting.js.map +1 -1
  844. package/lib/util/typeCheck.d.ts +7 -0
  845. package/lib/util/typeCheck.d.ts.map +1 -1
  846. package/lib/util/typeCheck.js.map +1 -1
  847. package/lib/util/utils.d.ts +0 -1
  848. package/lib/util/utils.d.ts.map +1 -1
  849. package/lib/util/utils.js +0 -2
  850. package/lib/util/utils.js.map +1 -1
  851. package/package.json +37 -27
  852. package/src/codec/codec.ts +2 -2
  853. package/src/codec/discriminatedUnions.ts +2 -2
  854. package/src/core/forest/editableForest.ts +1 -52
  855. package/src/core/forest/forest.ts +17 -2
  856. package/src/core/forest/index.ts +0 -1
  857. package/src/core/index.ts +4 -2
  858. package/src/core/rebase/utils.ts +1 -1
  859. package/src/core/schema-stored/schema.ts +6 -2
  860. package/src/core/tree/anchorSet.ts +42 -12
  861. package/src/core/tree/delta.ts +8 -25
  862. package/src/core/tree/deltaUtil.ts +5 -5
  863. package/src/core/tree/index.ts +4 -1
  864. package/src/core/tree/pathTree.ts +72 -1
  865. package/src/core/tree/treeTextFormat.ts +1 -1
  866. package/src/core/tree/visitDelta.ts +38 -17
  867. package/src/core/tree/visitorUtils.ts +22 -36
  868. package/src/feature-libraries/chunked-forest/basicChunk.ts +3 -3
  869. package/src/feature-libraries/chunked-forest/chunkTree.ts +20 -9
  870. package/src/feature-libraries/chunked-forest/chunkedForest.ts +10 -6
  871. package/src/feature-libraries/chunked-forest/codec/README.md +3 -3
  872. package/src/feature-libraries/chunked-forest/codec/chunkEncodingGeneric.ts +1 -1
  873. package/src/feature-libraries/chunked-forest/codec/codecs.ts +1 -1
  874. package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
  875. package/src/feature-libraries/chunked-forest/codec/nodeShape.ts +2 -2
  876. package/src/feature-libraries/chunked-forest/codec/{schemaBasedEncoding.ts → schemaBasedEncode.ts} +1 -2
  877. package/src/feature-libraries/chunked-forest/emptyChunk.ts +1 -1
  878. package/src/feature-libraries/chunked-forest/uniformChunk.ts +5 -4
  879. package/src/feature-libraries/default-schema/defaultEditBuilder.ts +21 -38
  880. package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
  881. package/src/feature-libraries/default-schema/index.ts +2 -0
  882. package/src/feature-libraries/default-schema/mappedEditBuilder.ts +68 -0
  883. package/src/feature-libraries/default-schema/schemaChecker.ts +1 -2
  884. package/src/feature-libraries/deltaUtils.ts +1 -1
  885. package/src/feature-libraries/flex-tree/context.ts +4 -4
  886. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +2 -2
  887. package/src/feature-libraries/flex-tree/lazyField.ts +21 -12
  888. package/src/feature-libraries/flex-tree/lazyNode.ts +2 -2
  889. package/src/feature-libraries/forest-summary/forestSummarizer.ts +5 -9
  890. package/src/feature-libraries/index.ts +10 -8
  891. package/src/feature-libraries/indexing/anchorTreeIndex.ts +4 -4
  892. package/src/feature-libraries/initializeForest.ts +55 -0
  893. package/src/feature-libraries/modular-schema/comparison.ts +2 -2
  894. package/src/feature-libraries/modular-schema/isNeverTree.ts +1 -2
  895. package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -2
  896. package/src/feature-libraries/modular-schema/modularChangeFamily.ts +13 -30
  897. package/src/feature-libraries/node-identifier/README.md +11 -0
  898. package/src/feature-libraries/node-identifier/index.ts +17 -0
  899. package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +59 -0
  900. package/src/feature-libraries/node-identifier/nodeIdentifier.ts +50 -0
  901. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +95 -0
  902. package/src/feature-libraries/object-forest/objectForest.ts +11 -5
  903. package/src/feature-libraries/schema-index/codec.ts +2 -1
  904. package/src/feature-libraries/sequence-field/compose.ts +2 -2
  905. package/src/feature-libraries/sequence-field/invert.ts +2 -2
  906. package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +2 -2
  907. package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +2 -2
  908. package/src/feature-libraries/sequence-field/utils.ts +2 -2
  909. package/src/feature-libraries/treeCursorUtils.ts +2 -3
  910. package/src/index.ts +43 -13
  911. package/src/jsonDomainSchema.ts +30 -11
  912. package/src/packageVersion.ts +1 -1
  913. package/src/shared-tree/checkoutFlexTreeView.ts +2 -2
  914. package/src/shared-tree/independentView.ts +5 -29
  915. package/src/shared-tree/index.ts +1 -0
  916. package/src/shared-tree/schematizeTree.ts +5 -4
  917. package/src/shared-tree/schematizingTreeView.ts +3 -3
  918. package/src/shared-tree/sharedTree.ts +29 -19
  919. package/src/shared-tree/sharedTreeChangeFamily.ts +1 -3
  920. package/src/shared-tree/sharedTreeEditBuilder.ts +5 -11
  921. package/src/shared-tree/treeApiAlpha.ts +45 -85
  922. package/src/shared-tree/treeCheckout.ts +4 -10
  923. package/src/shared-tree-core/branch.ts +5 -3
  924. package/src/shared-tree-core/editManager.ts +37 -45
  925. package/src/sharedTreeAttributes.ts +25 -0
  926. package/src/simple-tree/api/conciseTree.ts +25 -8
  927. package/src/simple-tree/api/create.ts +3 -3
  928. package/src/simple-tree/api/customTree.ts +60 -17
  929. package/src/simple-tree/api/getJsonSchema.ts +10 -0
  930. package/src/simple-tree/api/getSimpleSchema.ts +14 -44
  931. package/src/simple-tree/api/index.ts +17 -12
  932. package/src/simple-tree/api/schemaCreationUtilities.ts +1 -2
  933. package/src/simple-tree/api/schemaFactory.ts +179 -118
  934. package/src/simple-tree/api/schemaFactoryAlpha.ts +74 -67
  935. package/src/simple-tree/api/schemaFactoryRecursive.ts +44 -12
  936. package/src/simple-tree/api/schemaFromSimple.ts +96 -0
  937. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +7 -7
  938. package/src/simple-tree/api/simpleTreeIndex.ts +2 -1
  939. package/src/simple-tree/api/tree.ts +16 -11
  940. package/src/simple-tree/api/treeNodeApi.ts +5 -18
  941. package/src/simple-tree/api/typesUnsafe.ts +166 -48
  942. package/src/simple-tree/api/verboseTree.ts +45 -57
  943. package/src/simple-tree/api/view.ts +1 -2
  944. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -185
  945. package/src/simple-tree/arrayNode.ts +20 -14
  946. package/src/simple-tree/arrayNodeTypes.ts +93 -0
  947. package/src/simple-tree/core/getOrCreateNode.ts +3 -13
  948. package/src/simple-tree/core/index.ts +1 -1
  949. package/src/simple-tree/core/treeNodeKernel.ts +32 -18
  950. package/src/simple-tree/core/treeNodeSchema.ts +14 -8
  951. package/src/simple-tree/core/unhydratedFlexTree.ts +4 -4
  952. package/src/simple-tree/flexList.ts +4 -14
  953. package/src/simple-tree/index.ts +36 -9
  954. package/src/simple-tree/leafNodeSchema.ts +28 -7
  955. package/src/simple-tree/mapNode.ts +13 -11
  956. package/src/simple-tree/mapNodeTypes.ts +90 -0
  957. package/src/simple-tree/objectNode.ts +40 -13
  958. package/src/simple-tree/objectNodeTypes.ts +21 -16
  959. package/src/simple-tree/proxies.ts +2 -2
  960. package/src/simple-tree/schemaTypes.ts +153 -23
  961. package/src/simple-tree/{api/simpleSchema.ts → simpleSchema.ts} +67 -28
  962. package/src/simple-tree/toMapTree.ts +8 -8
  963. package/src/simple-tree/toStoredSchema.ts +4 -7
  964. package/src/simple-tree/treeNodeValid.ts +17 -7
  965. package/src/treeFactory.ts +1 -19
  966. package/src/util/cloneWithReplacements.ts +41 -0
  967. package/src/util/idAllocator.ts +1 -3
  968. package/src/util/index.ts +2 -1
  969. package/src/util/referenceCounting.ts +18 -1
  970. package/src/util/typeCheck.ts +7 -0
  971. package/src/util/utils.ts +0 -3
  972. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  973. package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  974. package/dist/feature-libraries/node-key/index.d.ts +0 -8
  975. package/dist/feature-libraries/node-key/index.d.ts.map +0 -1
  976. package/dist/feature-libraries/node-key/index.js +0 -16
  977. package/dist/feature-libraries/node-key/index.js.map +0 -1
  978. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  979. package/dist/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  980. package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  981. package/dist/feature-libraries/node-key/nodeKey.d.ts +0 -38
  982. package/dist/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  983. package/dist/feature-libraries/node-key/nodeKey.js +0 -26
  984. package/dist/feature-libraries/node-key/nodeKey.js.map +0 -1
  985. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  986. package/dist/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  987. package/dist/feature-libraries/node-key/nodeKeyManager.js +0 -48
  988. package/dist/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  989. package/dist/simple-tree/api/simpleSchema.d.ts.map +0 -1
  990. package/dist/simple-tree/api/simpleSchema.js.map +0 -1
  991. package/dist/simple-tree/core/schemaCaching.d.ts +0 -16
  992. package/dist/simple-tree/core/schemaCaching.d.ts.map +0 -1
  993. package/dist/simple-tree/core/schemaCaching.js +0 -32
  994. package/dist/simple-tree/core/schemaCaching.js.map +0 -1
  995. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.d.ts.map +0 -1
  996. package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncoding.js.map +0 -1
  997. package/lib/feature-libraries/node-key/index.d.ts +0 -8
  998. package/lib/feature-libraries/node-key/index.d.ts.map +0 -1
  999. package/lib/feature-libraries/node-key/index.js +0 -8
  1000. package/lib/feature-libraries/node-key/index.js.map +0 -1
  1001. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts +0 -22
  1002. package/lib/feature-libraries/node-key/mockNodeKeyManager.d.ts.map +0 -1
  1003. package/lib/feature-libraries/node-key/mockNodeKeyManager.js +0 -45
  1004. package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +0 -1
  1005. package/lib/feature-libraries/node-key/nodeKey.d.ts +0 -38
  1006. package/lib/feature-libraries/node-key/nodeKey.d.ts.map +0 -1
  1007. package/lib/feature-libraries/node-key/nodeKey.js +0 -22
  1008. package/lib/feature-libraries/node-key/nodeKey.js.map +0 -1
  1009. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts +0 -37
  1010. package/lib/feature-libraries/node-key/nodeKeyManager.d.ts.map +0 -1
  1011. package/lib/feature-libraries/node-key/nodeKeyManager.js +0 -43
  1012. package/lib/feature-libraries/node-key/nodeKeyManager.js.map +0 -1
  1013. package/lib/simple-tree/api/simpleSchema.d.ts.map +0 -1
  1014. package/lib/simple-tree/api/simpleSchema.js.map +0 -1
  1015. package/lib/simple-tree/core/schemaCaching.d.ts +0 -16
  1016. package/lib/simple-tree/core/schemaCaching.d.ts.map +0 -1
  1017. package/lib/simple-tree/core/schemaCaching.js +0 -27
  1018. package/lib/simple-tree/core/schemaCaching.js.map +0 -1
  1019. package/prettier.config.cjs +0 -8
  1020. package/src/feature-libraries/node-key/README.md +0 -11
  1021. package/src/feature-libraries/node-key/index.ts +0 -17
  1022. package/src/feature-libraries/node-key/mockNodeKeyManager.ts +0 -54
  1023. package/src/feature-libraries/node-key/nodeKey.ts +0 -47
  1024. package/src/feature-libraries/node-key/nodeKeyManager.ts +0 -93
  1025. package/src/simple-tree/core/schemaCaching.ts +0 -35
  1026. /package/dist/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
  1027. /package/lib/simple-tree/{api/simpleSchema.js → simpleSchema.js} +0 -0
@@ -2,15 +2,16 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ScopedSchemaName, InsertableObjectFromSchemaRecord, TreeObjectNodeUnsafe, InsertableObjectFromSchemaRecordUnsafe } from "../../internalTypes.js";
5
+ import type { ScopedSchemaName, TreeObjectNodeUnsafe, InsertableObjectFromSchemaRecordUnsafe } from "../../internalTypes.js";
6
6
  import { SchemaFactory, type SchemaFactoryObjectOptions } from "./schemaFactory.js";
7
- import type { ImplicitAllowedTypes, ImplicitFieldSchema, InsertableTreeNodeFromImplicitAllowedTypes, NodeSchemaOptions } from "../schemaTypes.js";
8
- import { type TreeObjectNode } from "../objectNode.js";
7
+ import type { ImplicitAllowedTypes, ImplicitFieldSchema, NodeSchemaOptions } from "../schemaTypes.js";
9
8
  import type { RestrictiveStringRecord } from "../../util/index.js";
10
- import type { NodeKind, TreeNodeSchemaClass, WithType } from "../core/index.js";
11
- import type { InsertableTreeNodeFromImplicitAllowedTypesUnsafe, TreeArrayNodeUnsafe, TreeMapNodeUnsafe, Unenforced } from "./typesUnsafe.js";
12
- import { type MapNodeInsertableData, type TreeMapNode } from "../mapNode.js";
13
- import { type TreeArrayNode } from "../arrayNode.js";
9
+ import type { NodeKind, TreeNodeSchemaClass } from "../core/index.js";
10
+ import type { ImplicitAllowedTypesUnsafe, ImplicitFieldSchemaUnsafe, ArrayNodeCustomizableSchemaUnsafe, MapNodeCustomizableSchemaUnsafe } from "./typesUnsafe.js";
11
+ import type { ObjectNodeSchema } from "../objectNodeTypes.js";
12
+ import type { SimpleObjectNodeSchema } from "../simpleSchema.js";
13
+ import type { ArrayNodeCustomizableSchema } from "../arrayNodeTypes.js";
14
+ import type { MapNodeCustomizableSchema } from "../mapNodeTypes.js";
14
15
  /**
15
16
  * {@link SchemaFactory} with additional alpha APIs.
16
17
  *
@@ -29,11 +30,27 @@ export declare class SchemaFactoryAlpha<out TScope extends string | undefined =
29
30
  * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
30
31
  * @param options - Additional options for the schema.
31
32
  */
32
- object<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNode<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T, never, TCustomMetadata>;
33
+ object<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
33
34
  /**
34
35
  * {@inheritdoc SchemaFactory.objectRecursive}
35
36
  */
36
- objectRecursive<const Name extends TName, const T extends Unenforced<RestrictiveStringRecord<ImplicitFieldSchema>>, const TCustomMetadata = unknown>(name: Name, t: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordUnsafe<T>, false, T, never, TCustomMetadata>;
37
+ objectRecursive<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordUnsafe<T>, false, T, never, TCustomMetadata> & SimpleObjectNodeSchema<TCustomMetadata> & Pick<ObjectNodeSchema, "fields">;
38
+ /**
39
+ * {@inheritDoc SchemaStatics.optional}
40
+ */
41
+ static readonly optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<import("../schemaTypes.js").FieldProps<TCustomMetadata>, "defaultProvider"> | undefined) => import("../schemaTypes.js").FieldSchemaAlpha<import("../schemaTypes.js").FieldKind.Optional, T, TCustomMetadata>;
42
+ /**
43
+ * {@inheritDoc SchemaStatics.required}
44
+ */
45
+ static readonly required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(t: T, props?: Omit<import("../schemaTypes.js").FieldProps<TCustomMetadata>, "defaultProvider"> | undefined) => import("../schemaTypes.js").FieldSchemaAlpha<import("../schemaTypes.js").FieldKind.Required, T, TCustomMetadata>;
46
+ /**
47
+ * {@inheritDoc SchemaStatics.optionalRecursive}
48
+ */
49
+ static readonly optionalRecursive: <const T extends ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(t: T, props?: Omit<import("../schemaTypes.js").FieldProps<TCustomMetadata>, "defaultProvider"> | undefined) => import("./typesUnsafe.js").FieldSchemaAlphaUnsafe<import("../schemaTypes.js").FieldKind.Optional, T, TCustomMetadata>;
50
+ /**
51
+ * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.
52
+ */
53
+ static readonly identifier: <const TCustomMetadata = unknown>(props?: Omit<import("../schemaTypes.js").FieldProps<TCustomMetadata>, "defaultProvider"> | undefined) => import("../schemaTypes.js").FieldSchemaAlpha<import("../schemaTypes.js").FieldKind.Identifier, import("../leafNodeSchema.js").LeafSchema<"string", string> & import("../simpleSchema.js").SimpleLeafNodeSchema, TCustomMetadata>;
37
54
  /**
38
55
  * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.
39
56
  *
@@ -48,18 +65,11 @@ export declare class SchemaFactoryAlpha<out TScope extends string | undefined =
48
65
  * }) {}
49
66
  * ```
50
67
  */
51
- mapAlpha<Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>, MapNodeInsertableData<T>, true, T, undefined, TCustomMetadata>;
68
+ mapAlpha<Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
52
69
  /**
53
70
  * {@inheritDoc SchemaFactory.objectRecursive}
54
71
  */
55
- mapRecursive<Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map, unknown>, {
56
- [Symbol.iterator](): Iterator<[
57
- string,
58
- InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>
59
- ]>;
60
- } | {
61
- readonly [x: string]: InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;
62
- }, false, T, undefined, TCustomMetadata>;
72
+ mapRecursive<Name extends TName, const T extends ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): MapNodeCustomizableSchemaUnsafe<ScopedSchemaName<TScope, Name>, T, TCustomMetadata>;
63
73
  /**
64
74
  * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.
65
75
  *
@@ -69,15 +79,20 @@ export declare class SchemaFactoryAlpha<out TScope extends string | undefined =
69
79
  *
70
80
  * @example
71
81
  * ```typescript
72
- * class NamedArray extends factory.array("name", factory.number) {}
82
+ * class NamedArray extends factory.arrayAlpha("name", factory.number) {}
73
83
  * ```
74
84
  */
75
- arrayAlpha<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Array, TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, true, T, undefined, TCustomMetadata>;
85
+ arrayAlpha<const Name extends TName, const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
76
86
  /**
77
87
  * {@inheritDoc SchemaFactory.objectRecursive}
78
88
  */
79
- arrayRecursive<const Name extends TName, const T extends Unenforced<ImplicitAllowedTypes>, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Array, TreeArrayNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array, unknown>, {
80
- [Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;
81
- }, false, T, undefined, TCustomMetadata>;
89
+ arrayRecursive<const Name extends TName, const T extends ImplicitAllowedTypesUnsafe, const TCustomMetadata = unknown>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>): ArrayNodeCustomizableSchemaUnsafe<ScopedSchemaName<TScope, Name>, T, TCustomMetadata>;
90
+ /**
91
+ * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.
92
+ * @remarks
93
+ * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).
94
+ * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.
95
+ */
96
+ scopedFactory<const T extends TName, TNameInner extends number | string = string>(name: T): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner>;
82
97
  }
83
98
  //# sourceMappingURL=schemaFactoryAlpha.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,gBAAgB,EAChB,gCAAgC,EAChC,oBAAoB,EACpB,sCAAsC,EACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEN,aAAa,EACb,KAAK,0BAA0B,EAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACX,oBAAoB,EACpB,mBAAmB,EACnB,0CAA0C,EAC1C,iBAAiB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EACX,gDAAgD,EAChD,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAa,KAAK,qBAAqB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAElE;;;;;;;;GAQG;AACH,qBAAa,kBAAkB,C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,GAAG,OAAO,EAC9B,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,eAAe,CAAC;IAY3E;;;;;OAKG;IACI,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EACtF,IAAI,EAAE,CAAC,GACL,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC;CAG9D"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { defaultSchemaFactoryObjectOptions, SchemaFactory, } from "./schemaFactory.js";
5
+ import { defaultSchemaFactoryObjectOptions, SchemaFactory, schemaStatics, } from "./schemaFactory.js";
6
6
  import { objectSchema } from "../objectNode.js";
7
7
  import { mapSchema } from "../mapNode.js";
8
8
  import { arraySchema } from "../arrayNode.js";
@@ -69,7 +69,7 @@ export class SchemaFactoryAlpha extends SchemaFactory {
69
69
  *
70
70
  * @example
71
71
  * ```typescript
72
- * class NamedArray extends factory.array("name", factory.number) {}
72
+ * class NamedArray extends factory.arrayAlpha("name", factory.number) {}
73
73
  * ```
74
74
  */
75
75
  arrayAlpha(name, allowedTypes, options) {
@@ -82,5 +82,30 @@ export class SchemaFactoryAlpha extends SchemaFactory {
82
82
  arrayRecursive(name, allowedTypes, options) {
83
83
  return this.arrayAlpha(name, allowedTypes, options);
84
84
  }
85
+ /**
86
+ * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.
87
+ * @remarks
88
+ * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).
89
+ * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.
90
+ */
91
+ scopedFactory(name) {
92
+ return new SchemaFactoryAlpha(this.scoped2(name));
93
+ }
85
94
  }
95
+ /**
96
+ * {@inheritDoc SchemaStatics.optional}
97
+ */
98
+ SchemaFactoryAlpha.optional = schemaStatics.optional;
99
+ /**
100
+ * {@inheritDoc SchemaStatics.required}
101
+ */
102
+ SchemaFactoryAlpha.required = schemaStatics.required;
103
+ /**
104
+ * {@inheritDoc SchemaStatics.optionalRecursive}
105
+ */
106
+ SchemaFactoryAlpha.optionalRecursive = schemaStatics.optionalRecursive;
107
+ /**
108
+ * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.
109
+ */
110
+ SchemaFactoryAlpha.identifier = schemaStatics.identifier;
86
111
  //# sourceMappingURL=schemaFactoryAlpha.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACN,iCAAiC,EACjC,aAAa,GAEb,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAuB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AASrE,OAAO,EAAE,SAAS,EAAgD,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,WAAW,EAAsB,MAAM,iBAAiB,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAGX,SAAQ,aAA4B;IAC7B,OAAO,CAA8B,IAAU;QACtD,OAAO,CACN,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAC5B,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACa,MAAM,CAKrB,IAAU,EACV,MAAS,EACT,OAAqD;QAWrD,OAAO,YAAY,CAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAClB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,0BAA0B;YAClC,iCAAiC,CAAC,0BAA0B,EAC7D,OAAO,EAAE,QAAQ,CACjB,CAAC;IACH,CAAC;IAED;;OAEG;IACa,eAAe,CAK9B,IAAU,EACV,CAAI,EACJ,OAAqD;QAYrD,OAAO,IAAI,CAAC,MAAM,CACjB,IAAI,EACJ,CAAqD,EACrD,OAAO,CAUP,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,QAAQ,CAKd,IAAU,EACV,YAAe,EACf,OAA4C;QAW5C,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,4EAA4E;IAC5D,YAAY,CAI1B,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,OAAO,IAAI,CAAC,QAAQ,CACnB,IAAI,EACJ,YAAwC,EACxC,OAAO,CAiBP,CAAC;IACH,CAAC;IAED;;;;;;;;;;;OAWG;IACI,UAAU,CAKhB,IAAU,EACV,YAAe,EACf,OAA4C;QAW5C,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrF,CAAC;IAED;;OAEG;IACH,4EAA4E;IAC5D,cAAc,CAI5B,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,OAAO,IAAI,CAAC,UAAU,CACrB,IAAI,EACJ,YAAwC,EACxC,OAAO,CAYP,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tScopedSchemaName,\n\tInsertableObjectFromSchemaRecord,\n\tTreeObjectNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n} from \"../../internalTypes.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\ttype SchemaFactoryObjectOptions,\n} from \"./schemaFactory.js\";\nimport type {\n\tImplicitAllowedTypes,\n\tImplicitFieldSchema,\n\tInsertableTreeNodeFromImplicitAllowedTypes,\n\tNodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { type TreeObjectNode, objectSchema } from \"../objectNode.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { NodeKind, TreeNodeSchemaClass, WithType } from \"../core/index.js\";\nimport type {\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tUnenforced,\n} from \"./typesUnsafe.js\";\nimport { mapSchema, type MapNodeInsertableData, type TreeMapNode } from \"../mapNode.js\";\nimport { arraySchema, type TreeArrayNode } from \"../arrayNode.js\";\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNode<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecord<T>,\n\t\ttrue,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<RestrictiveStringRecord<ImplicitFieldSchema>>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> {\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Map,\n\t\tTreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\tMapNodeInsertableData<T>,\n\t\ttrue,\n\t\tT,\n\t\tundefined,\n\t\tTCustomMetadata\n\t> {\n\t\treturn mapSchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends Unenforced<ImplicitAllowedTypes>,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Map,\n\t\t\tTreeMapNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Map>,\n\t\t\t| {\n\t\t\t\t\t[Symbol.iterator](): Iterator<\n\t\t\t\t\t\t[string, InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>]\n\t\t\t\t\t>;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\treadonly [P in string]: InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;\n\t\t\t },\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.array(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Array,\n\t\tTreeArrayNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>,\n\t\tIterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,\n\t\ttrue,\n\t\tT,\n\t\tundefined,\n\t\tTCustomMetadata\n\t> {\n\t\treturn arraySchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends Unenforced<ImplicitAllowedTypes>,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tNodeKind.Array,\n\t\t\tTreeArrayNodeUnsafe<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Array>,\n\t\t\t{\n\t\t\t\t[Symbol.iterator](): Iterator<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>;\n\t\t\t},\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tundefined,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACN,iCAAiC,EACjC,aAAa,EACb,aAAa,GAEb,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAShD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9C;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAGX,SAAQ,aAA4B;IAC7B,OAAO,CAA8B,IAAU;QACtD,OAAO,CACN,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAC5B,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACa,MAAM,CAKrB,IAAU,EACV,MAAS,EACT,OAAqD;QAErD,OAAO,YAAY,CAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAClB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,0BAA0B;YAClC,iCAAiC,CAAC,0BAA0B,EAC7D,OAAO,EAAE,QAAQ,CACjB,CAAC;IACH,CAAC;IAED;;OAEG;IACa,eAAe,CAK9B,IAAU,EACV,CAAI,EACJ,OAAqD;QAwBrD,OAAO,IAAI,CAAC,MAAM,CACjB,IAAI,EACJ,CAAqD,EACrD,OAAO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ensed under the MIT License.\n */\n\nimport type {\n\tScopedSchemaName,\n\tTreeObjectNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n} from \"../../internalTypes.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tschemaStatics,\n\ttype SchemaFactoryObjectOptions,\n} from \"./schemaFactory.js\";\nimport type {\n\tImplicitAllowedTypes,\n\tImplicitFieldSchema,\n\tNodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { objectSchema } from \"../objectNode.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { NodeKind, TreeNodeSchemaClass } from \"../core/index.js\";\nimport type {\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\nimport { mapSchema } from \"../mapNode.js\";\nimport { arraySchema } from \"../arrayNode.js\";\nimport type { ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { ArrayNodeCustomizableSchema } from \"../arrayNodeTypes.js\";\nimport type { MapNodeCustomizableSchema } from \"../mapNodeTypes.js\";\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(this.scoped2(name));\n\t}\n}\n"]}
@@ -6,10 +6,11 @@ import type { RestrictiveStringRecord } from "../../util/index.js";
6
6
  import type { InsertableObjectFromSchemaRecord } from "../objectNode.js";
7
7
  import { type FieldKind, type FieldProps, type ImplicitAllowedTypes, type ImplicitFieldSchema, type InsertableTreeNodeFromImplicitAllowedTypes } from "../schemaTypes.js";
8
8
  import type { NodeKind, TreeNodeSchemaClass, TreeNodeSchema, WithType, TreeNode } from "../core/index.js";
9
- import type { FieldSchemaUnsafe, Unenforced } from "./typesUnsafe.js";
10
- export declare function createFieldSchemaUnsafe<Kind extends FieldKind, Types extends Unenforced<ImplicitAllowedTypes>>(kind: Kind, allowedTypes: Types, props: FieldProps | undefined): FieldSchemaUnsafe<Kind, Types>;
9
+ import type { FieldSchemaAlphaUnsafe, ImplicitAllowedTypesUnsafe } from "./typesUnsafe.js";
10
+ export declare function createFieldSchemaUnsafe<Kind extends FieldKind, Types extends ImplicitAllowedTypesUnsafe, TCustomMetadata = unknown>(kind: Kind, allowedTypes: Types, props?: FieldProps<TCustomMetadata>): FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata>;
11
11
  /**
12
12
  * Compile time check for validity of a recursive schema.
13
+ * This type also serves as a central location for documenting the requirements and issues related to recursive schema.
13
14
  *
14
15
  * @example
15
16
  * ```typescript
@@ -19,13 +20,37 @@ export declare function createFieldSchemaUnsafe<Kind extends FieldKind, Types ex
19
20
  * }
20
21
  * ```
21
22
  * @remarks
22
- * The type of a recursive schema can be passed to this, and a compile error will be produced for some of the cases of malformed schema.
23
+ * In this context recursive schema are defined as all {@link FieldSchema} and {@link TreeNodeSchema} schema which are part of a cycle such that walking down through each {@link TreeNodeSchemaCore.childTypes} the given starting schema can be reached again.
24
+ * Schema referencing the recursive schema and schema they reference that are not part of a cycle are not considered recursive.
25
+ *
26
+ * TypeScript puts a lot of limitations on the typing of recursive schema.
27
+ * To help avoid running into these limitations and thus getting schema that do not type check (or only type checks sometimes!),
28
+ * {@link SchemaFactory} provides APIs (postfixed with `Recursive`) for writing recursive schema.
29
+ * These APIs when combined with the patterns documented below should ensure that the schema provide robust type checking.
30
+ * These special patterns (other than {@link LazyItem} forward references which are not recursion specific)
31
+ * are not required for correct runtime behavior: they exist entirely to mitigate TypeScript type checking limitations and bugs.
32
+ * Ideally TypeScript's type checker would be able to handle all of these cases and more, removing the need for recursive type specific guidance, rules and APIs.
33
+ * Currently however there are open issues preventing this:
34
+ * {@link https://github.com/microsoft/TypeScript/issues/59550 | 1},
35
+ * {@link https://github.com/microsoft/TypeScript/issues/55832 | 2},
36
+ * {@link https://github.com/microsoft/TypeScript/issues/55758 | 3}.
37
+ * Note that the proposed resolution to some of these issues is for the compiler to error rather than allow the case,
38
+ * so even if these are all resolved the recursive type workarounds may still be needed.
39
+ *
40
+ * # Patterns
41
+ *
42
+ * Below are patterns for how to use recursive schema.
43
+ *
44
+ * ## General Patterns
45
+ *
46
+ * When defining a recursive {@link TreeNodeSchema}, use the `*Recursive` {@link SchemaFactory} methods.
47
+ * The returned class should be used as the base class for the recursive schema, which should then be passed to {@link ValidateRecursiveSchema}.
48
+ *
49
+ * Using {@link ValidateRecursiveSchema} will provide compile error for some of the cases of malformed schema.
23
50
  * This can be used to help mitigate the issue that recursive schema definitions are {@link Unenforced}.
24
51
  * If an issue is encountered where a mistake in a recursive schema is made which produces an invalid schema but is not rejected by this checker,
25
52
  * it should be considered a bug and this should be updated to handle that case (or have a disclaimer added to these docs that it misses that case).
26
53
  *
27
- * # Recursive Schema
28
- *
29
54
  * The non-recursive versions of the schema building methods will run into several issues when used recursively.
30
55
  * Consider the following example:
31
56
  *
@@ -79,12 +104,22 @@ export declare function createFieldSchemaUnsafe<Kind extends FieldKind, Types ex
79
104
  * }
80
105
  * ```
81
106
  *
107
+ * ## Object Schema
108
+ *
109
+ * When defining fields, if the fields is part of the recursive cycle, use the `*Recursive` {@link SchemaFactory} methods for defining the {@link FieldSchema}.
110
+ *
111
+ * ## Array Schema
112
+ *
113
+ * See {@link FixRecursiveArraySchema} for array specific details.
114
+ *
82
115
  * @privateRemarks
83
116
  * There are probably mistakes this misses: it's hard to guess all the wrong things people will accidentally do and defend against them.
84
117
  * Hopefully over time this can grow toward being robust, at least for common mistakes.
85
118
  *
86
119
  * This check duplicates logic that ideally would be entirely decided by the actual schema building methods.
87
120
  * Therefore changes to those methods may require updating `ValidateRecursiveSchema`.
121
+ *
122
+ * TODO: this currently does not reject `any`, but ideally should.
88
123
  * @public
89
124
  */
90
125
  export type ValidateRecursiveSchema<T extends TreeNodeSchemaClass<string, NodeKind.Array | NodeKind.Map | NodeKind.Object, TreeNode & WithType<T["identifier"], T["kind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AAC,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,oBAAoB,GACnD,QAAQ,CAAC,CAAC,MAAM,EAAE,0CAA0C,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GACzE,OAAO,CAAC;CACX,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAEZ,KAAK,EAEL;IACC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;IAChE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC;IACvC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,oBAAoB,CAAC;CACrC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CACZ,IACE,IAAI,CAAC;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryRecursive.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryRecursive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAGN,iBAAiB,GAIjB,MAAM,mBAAmB,CAAC;AAU3B,MAAM,UAAU,uBAAuB,CAItC,IAAU,EACV,YAAmB,EACnB,KAA6B;IAE7B,kJAAkJ;IAClJ,OAAO,iBAAiB,CACvB,IAAI,EACJ,YAAoC,EACpC,KAAK,CAC6B,CAAC;AACrC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { InsertableObjectFromSchemaRecord } from \"../objectNode.js\";\n\nimport {\n\ttype FieldKind,\n\ttype FieldProps,\n\tcreateFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n} from \"../schemaTypes.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchema,\n\tWithType,\n\tTreeNode,\n} from \"../core/index.js\";\nimport type { FieldSchemaUnsafe, Unenforced } from \"./typesUnsafe.js\";\n\nexport function createFieldSchemaUnsafe<\n\tKind extends FieldKind,\n\tTypes extends Unenforced<ImplicitAllowedTypes>,\n>(\n\tkind: Kind,\n\tallowedTypes: Types,\n\tprops: FieldProps | undefined,\n): FieldSchemaUnsafe<Kind, Types> {\n\t// At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe\n\treturn createFieldSchema(\n\t\tkind,\n\t\tallowedTypes as ImplicitAllowedTypes,\n\t\tprops,\n\t) as FieldSchemaUnsafe<Kind, Types>;\n}\n\n/**\n * Compile time check for validity of a recursive schema.\n *\n * @example\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {}\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>;\n * }\n * ```\n * @remarks\n * The type of a recursive schema can be passed to this, and a compile error will be produced for some of the cases of malformed schema.\n * This can be used to help mitigate the issue that recursive schema definitions are {@link Unenforced}.\n * If an issue is encountered where a mistake in a recursive schema is made which produces an invalid schema but is not rejected by this checker,\n * it should be considered a bug and this should be updated to handle that case (or have a disclaimer added to these docs that it misses that case).\n *\n * # Recursive Schema\n *\n * The non-recursive versions of the schema building methods will run into several issues when used recursively.\n * Consider the following example:\n *\n * ```typescript\n * const Test = sf.array(Test); // Bad\n * ```\n *\n * This has several issues:\n *\n * 1. It is a structurally named schema.\n * Structurally named schema derive their name from the names of their child types, which is not possible when the type is recursive since its name would include itself.\n * Instead a name must be explicitly provided.\n *\n * 2. The schema accesses itself before it's defined.\n * This would be a runtime error if the TypeScript compiler allowed it.\n * This can be fixed by wrapping the type in a function, which also requires explicitly listing the allowed types in an array (`[() => Test]`).\n *\n * 3. TypeScript fails to infer the recursive type and falls back to `any` with this warning or error (depending on the compiler configuration):\n * `'Test' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)`.\n * This issue is what the specialized recursive schema building methods fix.\n * This fix comes at a cost: to make the recursive cases work, the `extends` clauses had to be removed.\n * This means that mistakes declaring recursive schema often don't give compile errors in the schema.\n * Additionally support for implicit construction had to be disabled.\n * This means that new nested {@link Unhydrated} nodes can not be created like `new Test([[]])`.\n * Instead the nested nodes must be created explicitly using the construction like`new Test([new Test([])])`.\n *\n * 4. It is using \"POJO\" mode since it's not explicitly declaring a new class.\n * This means that the generated d.ts files for the schema replace recursive references with `any`, breaking use of recursive schema across compilation boundaries.\n * This is fixed by explicitly creating a class which extends the returned schema.\n *\n * All together, the fixed version looks like:\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {} // Good\n * ```\n *\n * Be very careful when declaring recursive schema.\n * Due to the removed extends clauses, subtle mistakes will compile just fine but cause strange errors when the schema is used.\n *\n * For example if the square brackets around the allowed types are forgotten:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", () => Test) {} // Bad\n * ```\n * This schema will still compile, and some (but not all) usages of it may look like they work correctly while other usages will produce generally unintelligible compile errors.\n * This issue can be partially mitigated using {@link ValidateRecursiveSchema}:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", () => Test) {} // Bad\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>; // Reports compile error due to invalid schema above.\n * }\n * ```\n *\n * @privateRemarks\n * There are probably mistakes this misses: it's hard to guess all the wrong things people will accidentally do and defend against them.\n * Hopefully over time this can grow toward being robust, at least for common mistakes.\n *\n * This check duplicates logic that ideally would be entirely decided by the actual schema building methods.\n * Therefore changes to those methods may require updating `ValidateRecursiveSchema`.\n * @public\n */\nexport type ValidateRecursiveSchema<\n\t// Recursive types should always be using TreeNodeSchemaClass (not TreeNodeSchemaNonClass) as thats part of the requirements for the type to work across compilation boundaries correctly.\n\tT extends TreeNodeSchemaClass<\n\t\t// Name: This validator places no restrictions on the name other than that it's a string (as required by TreeNodeSchemaClass).\n\t\tstring,\n\t\t// NodeKind: These are the NodeKinds which currently can be used recursively.\n\t\tNodeKind.Array | NodeKind.Map | NodeKind.Object,\n\t\t// TNode: The produced node API. This is pretty minimal validation: more could be added if similar to how TInsertable works below if needed.\n\t\tTreeNode & WithType<T[\"identifier\"], T[\"kind\"]>,\n\t\t// TInsertable: What can be passed to the constructor. This should be enough to catch most issues with incorrect schema.\n\t\t// These match whats defined in the recursive methods on `SchemaFactory` except they do not use `Unenforced`.\n\t\t{\n\t\t\t[NodeKind.Object]: T[\"info\"] extends RestrictiveStringRecord<ImplicitFieldSchema>\n\t\t\t\t? InsertableObjectFromSchemaRecord<T[\"info\"]>\n\t\t\t\t: unknown;\n\t\t\t[NodeKind.Array]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t\t? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>>\n\t\t\t\t: unknown;\n\t\t\t[NodeKind.Map]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t\t? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>]>\n\t\t\t\t: unknown;\n\t\t}[T[\"kind\"]],\n\t\t// ImplicitlyConstructable: recursive types are currently not implicitly constructable.\n\t\tfalse,\n\t\t// Info: What's passed to the method to create the schema. Constraining these here should be about as effective as if the actual constraints existed on the actual method itself.\n\t\t{\n\t\t\t[NodeKind.Object]: RestrictiveStringRecord<ImplicitFieldSchema>;\n\t\t\t[NodeKind.Array]: ImplicitAllowedTypes;\n\t\t\t[NodeKind.Map]: ImplicitAllowedTypes;\n\t\t}[T[\"kind\"]]\n\t>,\n> = true;\n\n/**\n * Workaround for fixing errors resulting from an issue with recursive ArrayNode schema exports.\n * @remarks\n * Importing a recursive ArrayNode schema via a d.ts file can produce an error like\n * `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.`\n * if using a tsconfig with `\"skipLibCheck\": false`.\n *\n * This error occurs due to the TypeScript compiler splitting the class definition into two separate declarations in the d.ts file (one for the base, and one for the actual class).\n * For unknown reasons, splitting the class declaration in this way breaks the recursive type handling, leading to the mentioned error.\n *\n * This type always evaluates to `undefined` to ensure the dummy export (which doesn't exist at runtime) is typed correctly.\n *\n * [TypeScript Issue 59550](https://github.com/microsoft/TypeScript/issues/59550) tracks a suggestion which would make this workaround unnecessary.\n *\n * @example Usage\n * Since recursive type handling in TypeScript is order dependent, putting just the right kind of usages of the type before the declarations can cause it to not hit this error.\n * For the case of ArrayNodes, this can be done via usage that looks like this:\n *\n * This example should use a doc comment to ensure the workaround comment shows up in the intellisense for the dummy export,\n * however doing so is impossible due to how this example is included in a doc comment.\n * ```typescript\n * // Workaround to avoid\n * // `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.` in the d.ts file.\n * export declare type _RecursiveArrayWorkaround = FixRecursiveArraySchema<typeof RecursiveArray>;\n * export class RecursiveArray extends schema.arrayRecursive(\"RA\", [() => RecursiveArray]) {}\n * {\n * \ttype _check = ValidateRecursiveSchema<typeof RecursiveArray>;\n * }\n * ```\n *\n * @alpha\n */\nexport type FixRecursiveArraySchema<T> = T extends TreeNodeSchema ? undefined : undefined;\n"]}
1
+ {"version":3,"file":"schemaFactoryRecursive.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryRecursive.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAGN,iBAAiB,GAIjB,MAAM,mBAAmB,CAAC;AAU3B,MAAM,UAAU,uBAAuB,CAKtC,IAAU,EACV,YAAmB,EACnB,KAAmC;IAEnC,kJAAkJ;IAClJ,OAAO,iBAAiB,CAAC,IAAI,EAAE,YAA4C,EAAE,KAAK,CAAC,CAAC;AACrF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { InsertableObjectFromSchemaRecord } from \"../objectNode.js\";\n\nimport {\n\ttype FieldKind,\n\ttype FieldProps,\n\tcreateFieldSchema,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n} from \"../schemaTypes.js\";\nimport type {\n\tNodeKind,\n\tTreeNodeSchemaClass,\n\tTreeNodeSchema,\n\tWithType,\n\tTreeNode,\n} from \"../core/index.js\";\nimport type { FieldSchemaAlphaUnsafe, ImplicitAllowedTypesUnsafe } from \"./typesUnsafe.js\";\n\nexport function createFieldSchemaUnsafe<\n\tKind extends FieldKind,\n\tTypes extends ImplicitAllowedTypesUnsafe,\n\tTCustomMetadata = unknown,\n>(\n\tkind: Kind,\n\tallowedTypes: Types,\n\tprops?: FieldProps<TCustomMetadata>,\n): FieldSchemaAlphaUnsafe<Kind, Types, TCustomMetadata> {\n\t// At runtime, we still want this to be a FieldSchema instance, but we can't satisfy its extends clause, so just return it as an FieldSchemaUnsafe\n\treturn createFieldSchema(kind, allowedTypes as ImplicitAllowedTypes & Types, props);\n}\n\n/**\n * Compile time check for validity of a recursive schema.\n * This type also serves as a central location for documenting the requirements and issues related to recursive schema.\n *\n * @example\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {}\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>;\n * }\n * ```\n * @remarks\n * In this context recursive schema are defined as all {@link FieldSchema} and {@link TreeNodeSchema} schema which are part of a cycle such that walking down through each {@link TreeNodeSchemaCore.childTypes} the given starting schema can be reached again.\n * Schema referencing the recursive schema and schema they reference that are not part of a cycle are not considered recursive.\n *\n * TypeScript puts a lot of limitations on the typing of recursive schema.\n * To help avoid running into these limitations and thus getting schema that do not type check (or only type checks sometimes!),\n * {@link SchemaFactory} provides APIs (postfixed with `Recursive`) for writing recursive schema.\n * These APIs when combined with the patterns documented below should ensure that the schema provide robust type checking.\n * These special patterns (other than {@link LazyItem} forward references which are not recursion specific)\n * are not required for correct runtime behavior: they exist entirely to mitigate TypeScript type checking limitations and bugs.\n * Ideally TypeScript's type checker would be able to handle all of these cases and more, removing the need for recursive type specific guidance, rules and APIs.\n * Currently however there are open issues preventing this:\n * {@link https://github.com/microsoft/TypeScript/issues/59550 | 1},\n * {@link https://github.com/microsoft/TypeScript/issues/55832 | 2},\n * {@link https://github.com/microsoft/TypeScript/issues/55758 | 3}.\n * Note that the proposed resolution to some of these issues is for the compiler to error rather than allow the case,\n * so even if these are all resolved the recursive type workarounds may still be needed.\n *\n * # Patterns\n *\n * Below are patterns for how to use recursive schema.\n *\n * ## General Patterns\n *\n * When defining a recursive {@link TreeNodeSchema}, use the `*Recursive` {@link SchemaFactory} methods.\n * The returned class should be used as the base class for the recursive schema, which should then be passed to {@link ValidateRecursiveSchema}.\n *\n * Using {@link ValidateRecursiveSchema} will provide compile error for some of the cases of malformed schema.\n * This can be used to help mitigate the issue that recursive schema definitions are {@link Unenforced}.\n * If an issue is encountered where a mistake in a recursive schema is made which produces an invalid schema but is not rejected by this checker,\n * it should be considered a bug and this should be updated to handle that case (or have a disclaimer added to these docs that it misses that case).\n *\n * The non-recursive versions of the schema building methods will run into several issues when used recursively.\n * Consider the following example:\n *\n * ```typescript\n * const Test = sf.array(Test); // Bad\n * ```\n *\n * This has several issues:\n *\n * 1. It is a structurally named schema.\n * Structurally named schema derive their name from the names of their child types, which is not possible when the type is recursive since its name would include itself.\n * Instead a name must be explicitly provided.\n *\n * 2. The schema accesses itself before it's defined.\n * This would be a runtime error if the TypeScript compiler allowed it.\n * This can be fixed by wrapping the type in a function, which also requires explicitly listing the allowed types in an array (`[() => Test]`).\n *\n * 3. TypeScript fails to infer the recursive type and falls back to `any` with this warning or error (depending on the compiler configuration):\n * `'Test' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)`.\n * This issue is what the specialized recursive schema building methods fix.\n * This fix comes at a cost: to make the recursive cases work, the `extends` clauses had to be removed.\n * This means that mistakes declaring recursive schema often don't give compile errors in the schema.\n * Additionally support for implicit construction had to be disabled.\n * This means that new nested {@link Unhydrated} nodes can not be created like `new Test([[]])`.\n * Instead the nested nodes must be created explicitly using the construction like`new Test([new Test([])])`.\n *\n * 4. It is using \"POJO\" mode since it's not explicitly declaring a new class.\n * This means that the generated d.ts files for the schema replace recursive references with `any`, breaking use of recursive schema across compilation boundaries.\n * This is fixed by explicitly creating a class which extends the returned schema.\n *\n * All together, the fixed version looks like:\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", [() => Test]) {} // Good\n * ```\n *\n * Be very careful when declaring recursive schema.\n * Due to the removed extends clauses, subtle mistakes will compile just fine but cause strange errors when the schema is used.\n *\n * For example if the square brackets around the allowed types are forgotten:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", () => Test) {} // Bad\n * ```\n * This schema will still compile, and some (but not all) usages of it may look like they work correctly while other usages will produce generally unintelligible compile errors.\n * This issue can be partially mitigated using {@link ValidateRecursiveSchema}:\n *\n * ```typescript\n * class Test extends sf.arrayRecursive(\"Test\", () => Test) {} // Bad\n * {\n * type _check = ValidateRecursiveSchema<typeof Test>; // Reports compile error due to invalid schema above.\n * }\n * ```\n *\n * ## Object Schema\n *\n * When defining fields, if the fields is part of the recursive cycle, use the `*Recursive` {@link SchemaFactory} methods for defining the {@link FieldSchema}.\n *\n * ## Array Schema\n *\n * See {@link FixRecursiveArraySchema} for array specific details.\n *\n * @privateRemarks\n * There are probably mistakes this misses: it's hard to guess all the wrong things people will accidentally do and defend against them.\n * Hopefully over time this can grow toward being robust, at least for common mistakes.\n *\n * This check duplicates logic that ideally would be entirely decided by the actual schema building methods.\n * Therefore changes to those methods may require updating `ValidateRecursiveSchema`.\n *\n * TODO: this currently does not reject `any`, but ideally should.\n * @public\n */\nexport type ValidateRecursiveSchema<\n\t// Recursive types should always be using TreeNodeSchemaClass (not TreeNodeSchemaNonClass) as thats part of the requirements for the type to work across compilation boundaries correctly.\n\tT extends TreeNodeSchemaClass<\n\t\t// Name: This validator places no restrictions on the name other than that it's a string (as required by TreeNodeSchemaClass).\n\t\tstring,\n\t\t// NodeKind: These are the NodeKinds which currently can be used recursively.\n\t\tNodeKind.Array | NodeKind.Map | NodeKind.Object,\n\t\t// TNode: The produced node API. This is pretty minimal validation: more could be added if similar to how TInsertable works below if needed.\n\t\tTreeNode & WithType<T[\"identifier\"], T[\"kind\"]>,\n\t\t// TInsertable: What can be passed to the constructor. This should be enough to catch most issues with incorrect schema.\n\t\t// These match whats defined in the recursive methods on `SchemaFactory` except they do not use `Unenforced`.\n\t\t{\n\t\t\t[NodeKind.Object]: T[\"info\"] extends RestrictiveStringRecord<ImplicitFieldSchema>\n\t\t\t\t? InsertableObjectFromSchemaRecord<T[\"info\"]>\n\t\t\t\t: unknown;\n\t\t\t[NodeKind.Array]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t\t? Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>>\n\t\t\t\t: unknown;\n\t\t\t[NodeKind.Map]: T[\"info\"] extends ImplicitAllowedTypes\n\t\t\t\t? Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T[\"info\"]>]>\n\t\t\t\t: unknown;\n\t\t}[T[\"kind\"]],\n\t\t// ImplicitlyConstructable: recursive types are currently not implicitly constructable.\n\t\tfalse,\n\t\t// Info: What's passed to the method to create the schema. Constraining these here should be about as effective as if the actual constraints existed on the actual method itself.\n\t\t{\n\t\t\t[NodeKind.Object]: RestrictiveStringRecord<ImplicitFieldSchema>;\n\t\t\t[NodeKind.Array]: ImplicitAllowedTypes;\n\t\t\t[NodeKind.Map]: ImplicitAllowedTypes;\n\t\t}[T[\"kind\"]]\n\t>,\n> = true;\n\n/**\n * Workaround for fixing errors resulting from an issue with recursive ArrayNode schema exports.\n * @remarks\n * Importing a recursive ArrayNode schema via a d.ts file can produce an error like\n * `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.`\n * if using a tsconfig with `\"skipLibCheck\": false`.\n *\n * This error occurs due to the TypeScript compiler splitting the class definition into two separate declarations in the d.ts file (one for the base, and one for the actual class).\n * For unknown reasons, splitting the class declaration in this way breaks the recursive type handling, leading to the mentioned error.\n *\n * This type always evaluates to `undefined` to ensure the dummy export (which doesn't exist at runtime) is typed correctly.\n *\n * [TypeScript Issue 59550](https://github.com/microsoft/TypeScript/issues/59550) tracks a suggestion which would make this workaround unnecessary.\n *\n * @example Usage\n * Since recursive type handling in TypeScript is order dependent, putting just the right kind of usages of the type before the declarations can cause it to not hit this error.\n * For the case of ArrayNodes, this can be done via usage that looks like this:\n *\n * This example should use a doc comment to ensure the workaround comment shows up in the intellisense for the dummy export,\n * however doing so is impossible due to how this example is included in a doc comment.\n * ```typescript\n * // Workaround to avoid\n * // `error TS2310: Type 'RecursiveArray' recursively references itself as a base type.` in the d.ts file.\n * export declare type _RecursiveArrayWorkaround = FixRecursiveArraySchema<typeof RecursiveArray>;\n * export class RecursiveArray extends schema.arrayRecursive(\"RA\", [() => RecursiveArray]) {}\n * {\n * \ttype _check = ValidateRecursiveSchema<typeof RecursiveArray>;\n * }\n * ```\n *\n * @alpha\n */\nexport type FixRecursiveArraySchema<T> = T extends TreeNodeSchema ? undefined : undefined;\n"]}
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type FieldSchemaAlpha } from "../schemaTypes.js";
6
+ import type { SimpleTreeSchema } from "../simpleSchema.js";
7
+ /**
8
+ * Create {@link FieldSchema} from a SimpleTreeSchema.
9
+ * @remarks
10
+ * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.
11
+ *
12
+ * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}
13
+ * will produce a poor TypeScript typing experience which is subject to change.
14
+ *
15
+ * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.
16
+ * @alpha
17
+ */
18
+ export declare function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): FieldSchemaAlpha;
19
+ //# sourceMappingURL=schemaFromSimple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaFromSimple.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,KAAK,gBAAgB,EAErB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAGX,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAK5B;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CASzF"}
@@ -0,0 +1,67 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { unreachableCase, fail } from "@fluidframework/core-utils/internal";
6
+ import { NodeKind } from "../core/index.js";
7
+ import { FieldKind, } from "../schemaTypes.js";
8
+ import { SchemaFactory } from "./schemaFactory.js";
9
+ import { SchemaFactoryAlpha } from "./schemaFactoryAlpha.js";
10
+ const factory = new SchemaFactoryAlpha(undefined);
11
+ /**
12
+ * Create {@link FieldSchema} from a SimpleTreeSchema.
13
+ * @remarks
14
+ * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.
15
+ *
16
+ * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}
17
+ * will produce a poor TypeScript typing experience which is subject to change.
18
+ *
19
+ * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.
20
+ * @alpha
21
+ */
22
+ export function generateSchemaFromSimpleSchema(simple) {
23
+ const context = new Map([...simple.definitions].map(([id, schema]) => [
24
+ id,
25
+ // This relies on the caching in evaluateLazySchema so that it only runs once.
26
+ () => generateNode(id, schema, context),
27
+ ]));
28
+ return generateFieldSchema(simple, context);
29
+ }
30
+ function generateFieldSchema(simple, context) {
31
+ const allowed = generateAllowedTypes(simple.allowedTypesIdentifiers, context);
32
+ // Using createFieldSchema could work, but would require setting up the default providers.
33
+ switch (simple.kind) {
34
+ case FieldKind.Identifier:
35
+ return SchemaFactoryAlpha.identifier({ metadata: simple.metadata });
36
+ case FieldKind.Optional:
37
+ return SchemaFactoryAlpha.optional(allowed, { metadata: simple.metadata });
38
+ case FieldKind.Required:
39
+ return SchemaFactoryAlpha.required(allowed, { metadata: simple.metadata });
40
+ default:
41
+ return unreachableCase(simple.kind);
42
+ }
43
+ }
44
+ function generateAllowedTypes(allowed, context) {
45
+ return [...allowed].map((id) => context.get(id) ?? fail(0xb5a /* Missing schema */));
46
+ }
47
+ function generateNode(id, schema, context) {
48
+ switch (schema.kind) {
49
+ case NodeKind.Object: {
50
+ const fields = {};
51
+ for (const [key, field] of schema.fields) {
52
+ fields[key] = generateFieldSchema(field, context);
53
+ }
54
+ return factory.object(id, fields, { metadata: schema.metadata });
55
+ }
56
+ case NodeKind.Array:
57
+ return factory.arrayAlpha(id, generateAllowedTypes(schema.allowedTypesIdentifiers, context), { metadata: schema.metadata });
58
+ case NodeKind.Map:
59
+ return factory.mapAlpha(id, generateAllowedTypes(schema.allowedTypesIdentifiers, context), { metadata: schema.metadata });
60
+ case NodeKind.Leaf:
61
+ return (SchemaFactory.leaves.find((leaf) => leaf.identifier === id) ??
62
+ fail(0xb5b /* Missing schema */));
63
+ default:
64
+ return unreachableCase(schema);
65
+ }
66
+ }
67
+ //# sourceMappingURL=schemaFromSimple.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaFromSimple.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAIN,SAAS,GACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa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AAI,CAAC,UAAU,KAAK,EAAE,CAAC;gBAC3D,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAChC,CAAC;QACH;YACC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype AllowedTypes,\n\ttype FieldSchemaAlpha,\n\tFieldKind,\n} from \"../schemaTypes.js\";\nimport { SchemaFactory } from \"./schemaFactory.js\";\nimport type {\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\n\nconst factory = new SchemaFactoryAlpha(undefined);\n\n/**\n * Create {@link FieldSchema} from a SimpleTreeSchema.\n * @remarks\n * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.\n *\n * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}\n * will produce a poor TypeScript typing experience which is subject to change.\n *\n * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.\n * @alpha\n */\nexport function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): FieldSchemaAlpha {\n\tconst context: Context = new Map(\n\t\t[...simple.definitions].map(([id, schema]): [string, () => TreeNodeSchema] => [\n\t\t\tid,\n\t\t\t// This relies on the caching in evaluateLazySchema so that it only runs once.\n\t\t\t() => generateNode(id, schema, context),\n\t\t]),\n\t);\n\treturn generateFieldSchema(simple, context);\n}\n\ntype Context = ReadonlyMap<string, () => TreeNodeSchema>;\n\nfunction generateFieldSchema(simple: SimpleFieldSchema, context: Context): FieldSchemaAlpha {\n\tconst allowed = generateAllowedTypes(simple.allowedTypesIdentifiers, context);\n\t// Using createFieldSchema could work, but would require setting up the default providers.\n\tswitch (simple.kind) {\n\t\tcase FieldKind.Identifier:\n\t\t\treturn SchemaFactoryAlpha.identifier({ metadata: simple.metadata });\n\t\tcase FieldKind.Optional:\n\t\t\treturn SchemaFactoryAlpha.optional(allowed, { metadata: simple.metadata });\n\t\tcase FieldKind.Required:\n\t\t\treturn SchemaFactoryAlpha.required(allowed, { metadata: simple.metadata });\n\t\tdefault:\n\t\t\treturn unreachableCase(simple.kind);\n\t}\n}\n\nfunction generateAllowedTypes(allowed: ReadonlySet<string>, context: Context): AllowedTypes {\n\treturn [...allowed].map((id) => context.get(id) ?? fail(0xb5a /* Missing schema */));\n}\n\nfunction generateNode(id: string, schema: SimpleNodeSchema, context: Context): TreeNodeSchema {\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Record<string, FieldSchema> = {};\n\t\t\tfor (const [key, field] of schema.fields) {\n\t\t\t\tfields[key] = generateFieldSchema(field, context);\n\t\t\t}\n\t\t\treturn factory.object(id, fields, { metadata: schema.metadata });\n\t\t}\n\t\tcase NodeKind.Array:\n\t\t\treturn factory.arrayAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Map:\n\t\t\treturn factory.mapAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Leaf:\n\t\t\treturn (\n\t\t\t\tSchemaFactory.leaves.find((leaf) => leaf.identifier === id) ??\n\t\t\t\tfail(0xb5b /* Missing schema */)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn unreachableCase(schema);\n\t}\n}\n"]}
@@ -2,11 +2,12 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { JsonTreeSchema } from "./jsonSchema.js";
6
- import type { SimpleTreeSchema } from "./simpleSchema.js";
5
+ import type { JsonObjectNodeSchema, JsonTreeSchema } from "./jsonSchema.js";
6
+ import type { SimpleObjectNodeSchema, SimpleTreeSchema } from "../simpleSchema.js";
7
7
  /**
8
8
  * Generates a JSON Schema representation from a simple tree schema.
9
9
  * @internal
10
10
  */
11
11
  export declare function toJsonSchema(schema: SimpleTreeSchema): JsonTreeSchema;
12
+ export declare function convertObjectNodeSchema(schema: SimpleObjectNodeSchema): JsonObjectNodeSchema;
12
13
  //# sourceMappingURL=simpleSchemaToJsonSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EASX,cAAc,EAEd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAMX,gBAAgB,EAChB,MAAM,mBAAmB,CAAC;AAG3B;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAiBrE"}
1
+ {"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAQX,oBAAoB,EACpB,cAAc,EAEd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAKX,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAG5B;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAiBrE;AAuFD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,sBAAsB,GAAG,oBAAoB,CAkC5F"}
@@ -15,7 +15,7 @@ import { NodeKind } from "../core/index.js";
15
15
  export function toJsonSchema(schema) {
16
16
  const definitions = convertDefinitions(schema.definitions);
17
17
  const allowedTypes = [];
18
- for (const allowedType of schema.allowedTypes) {
18
+ for (const allowedType of schema.allowedTypesIdentifiers) {
19
19
  allowedTypes.push(createSchemaRef(allowedType));
20
20
  }
21
21
  return hasSingle(allowedTypes)
@@ -62,7 +62,7 @@ function convertNodeSchema(schema) {
62
62
  }
63
63
  function convertArrayNodeSchema(schema) {
64
64
  const allowedTypes = [];
65
- schema.allowedTypes.forEach((type) => {
65
+ schema.allowedTypesIdentifiers.forEach((type) => {
66
66
  allowedTypes.push(createSchemaRef(type));
67
67
  });
68
68
  const items = hasSingle(allowedTypes)
@@ -101,12 +101,12 @@ function convertLeafNodeSchema(schema) {
101
101
  _treeNodeSchemaKind: NodeKind.Leaf,
102
102
  };
103
103
  }
104
- function convertObjectNodeSchema(schema) {
104
+ export function convertObjectNodeSchema(schema) {
105
105
  const properties = {};
106
106
  const required = [];
107
- for (const [key, fieldSchema] of Object.entries(schema.fields)) {
107
+ for (const [key, fieldSchema] of schema.fields) {
108
108
  const allowedTypes = [];
109
- for (const allowedType of fieldSchema.allowedTypes) {
109
+ for (const allowedType of fieldSchema.allowedTypesIdentifiers) {
110
110
  allowedTypes.push(createSchemaRef(allowedType));
111
111
  }
112
112
  const output = hasSingle(allowedTypes)
@@ -132,7 +132,7 @@ function convertObjectNodeSchema(schema) {
132
132
  }
133
133
  function convertMapNodeSchema(schema) {
134
134
  const allowedTypes = [];
135
- schema.allowedTypes.forEach((type) => {
135
+ schema.allowedTypesIdentifiers.forEach((type) => {
136
136
  allowedTypes.push(createSchemaRef(type));
137
137
  });
138
138
  const output = {
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,0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AM,eAAe,GAAkC;QACtD,IAAI,EAAE,QAAQ;QACd,mBAAmB,EAAE,QAAQ,CAAC,MAAM;QACpC,UAAU;QACV,QAAQ;QACR,oBAAoB,EAAE,KAAK;KAC3B,CAAC;IAEF,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;IAE9D,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA2B;IACxD,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAA+B;QAC1C,IAAI,EAAE,QAAQ;QACd,mBAAmB,EAAE,QAAQ,CAAC,GAAG;QACjC,iBAAiB,EAAE;YAClB,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC;gBAC9B,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;gBACjB,CAAC,CAAC;oBACA,KAAK,EAAE,YAAY;iBACnB;SACH;KACD,CAAC;IAEF,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,QAAgB;IACxC,OAAO;QACN,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, getOrCreate, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../schemaTypes.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { NodeKind } from \"../core/index.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @internal\n */\nexport function toJsonSchema(schema: SimpleTreeSchema): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.allowedTypes) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value);\n\t}\n\treturn result;\n}\n\n/**\n * Private symbol under which the results of {@link convertNodeSchema} are cached on an input {@link SimpleNodeSchema}.\n */\nconst nodeJsonSchemaCache = new WeakMap<SimpleNodeSchema, JsonNodeSchema>();\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(schema: SimpleNodeSchema): JsonNodeSchema {\n\treturn getOrCreate(nodeJsonSchemaCache, schema, () => {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array:\n\t\t\t\treturn convertArrayNodeSchema(schema);\n\t\t\tcase NodeKind.Leaf:\n\t\t\t\treturn convertLeafNodeSchema(schema);\n\t\t\tcase NodeKind.Map:\n\t\t\t\treturn convertMapNodeSchema(schema);\n\t\t\tcase NodeKind.Object:\n\t\t\t\treturn convertObjectNodeSchema(schema);\n\t\t\tdefault:\n\t\t\t\tthrow new TypeError(`Unknown node schema kind: ${(schema as SimpleNodeSchema).kind}`);\n\t\t}\n\t});\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypes.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String:\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Number:\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Boolean:\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Null:\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\tcase ValueSchema.FluidHandle:\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\tdefault:\n\t\t\tunreachableCase(schema.leafKind);\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nfunction convertObjectNodeSchema(schema: SimpleObjectNodeSchema): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [key, fieldSchema] of Object.entries(schema.fields)) {\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypes) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (fieldSchema.kind === FieldKind.Required) {\n\t\t\trequired.push(key);\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertMapNodeSchema(schema: SimpleMapNodeSchema): JsonMapNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypes.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output: Mutable<JsonMapNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Map,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}
1
+ {"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;AAazF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAS9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,MAAwB;IACpD,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE3D,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,uBAAuB,EAAE,CAAC;QAC1D,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,SAAS,CAAC,YAAY,CAAC;QAC7B,CAAC,CAAC;YACA,GAAG,YAAY,CAAC,CAAC,CAAC;YAClB,KAAK,EAAE,WAAW;SAClB;QACF,CAAC,CAAC;YACA,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,YAAY;SACnB,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CAC1B,WAAkD;IAElD,MAAM,MAAM,GAAmC,EAAE,CAAC;IAClD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK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C,QAAgB;IACxC,OAAO;QACN,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, getOrCreate, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../schemaTypes.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind } from \"../core/index.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @internal\n */\nexport function toJsonSchema(schema: SimpleTreeSchema): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.allowedTypesIdentifiers) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, SimpleNodeSchema>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value);\n\t}\n\treturn result;\n}\n\n/**\n * Private symbol under which the results of {@link convertNodeSchema} are cached on an input {@link SimpleNodeSchema}.\n */\nconst nodeJsonSchemaCache = new WeakMap<SimpleNodeSchema, JsonNodeSchema>();\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(schema: SimpleNodeSchema): JsonNodeSchema {\n\treturn getOrCreate(nodeJsonSchemaCache, schema, () => {\n\t\tswitch (schema.kind) {\n\t\t\tcase NodeKind.Array:\n\t\t\t\treturn convertArrayNodeSchema(schema);\n\t\t\tcase NodeKind.Leaf:\n\t\t\t\treturn convertLeafNodeSchema(schema);\n\t\t\tcase NodeKind.Map:\n\t\t\t\treturn convertMapNodeSchema(schema);\n\t\t\tcase NodeKind.Object:\n\t\t\t\treturn convertObjectNodeSchema(schema);\n\t\t\tdefault:\n\t\t\t\tthrow new TypeError(`Unknown node schema kind: ${(schema as SimpleNodeSchema).kind}`);\n\t\t}\n\t});\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String:\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Number:\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Boolean:\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Null:\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\tcase ValueSchema.FluidHandle:\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\tdefault:\n\t\t\tunreachableCase(schema.leafKind);\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nexport function convertObjectNodeSchema(schema: SimpleObjectNodeSchema): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [key, fieldSchema] of schema.fields) {\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypesIdentifiers) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (fieldSchema.kind === FieldKind.Required) {\n\t\t\trequired.push(key);\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertMapNodeSchema(schema: SimpleMapNodeSchema): JsonMapNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tschema.allowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output: Mutable<JsonMapNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Map,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}