@fluidframework/tree 2.50.0 → 2.51.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 (636) hide show
  1. package/.eslintrc.cjs +3 -2
  2. package/.vscode/Tree.code-workspace +14 -1
  3. package/.vscode/settings.json +16 -0
  4. package/CHANGELOG.md +51 -2
  5. package/api-report/tree.alpha.api.md +7 -7
  6. package/dist/core/schema-stored/schema.d.ts +14 -1
  7. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  8. package/dist/core/schema-stored/schema.js.map +1 -1
  9. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  10. package/dist/feature-libraries/default-schema/schemaChecker.js +3 -0
  11. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  12. package/dist/feature-libraries/flex-tree/context.d.ts +7 -2
  13. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  14. package/dist/feature-libraries/flex-tree/context.js +4 -4
  15. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  16. package/dist/feature-libraries/flex-tree/index.d.ts +1 -0
  17. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  18. package/dist/feature-libraries/flex-tree/index.js +3 -1
  19. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  20. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  21. package/dist/feature-libraries/flex-tree/lazyField.js +5 -5
  22. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  23. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +3 -1
  24. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  25. package/dist/feature-libraries/flex-tree/lazyNode.js +5 -3
  26. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  27. package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  28. package/dist/feature-libraries/forest-summary/forestSummarizer.js +3 -4
  29. package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  30. package/dist/feature-libraries/index.d.ts +2 -2
  31. package/dist/feature-libraries/index.d.ts.map +1 -1
  32. package/dist/feature-libraries/index.js +3 -8
  33. package/dist/feature-libraries/index.js.map +1 -1
  34. package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  35. package/dist/feature-libraries/modular-schema/comparison.js +0 -3
  36. package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
  37. package/dist/feature-libraries/modular-schema/index.d.ts +0 -1
  38. package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
  39. package/dist/feature-libraries/modular-schema/index.js +1 -8
  40. package/dist/feature-libraries/modular-schema/index.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/shared-tree/index.d.ts +0 -1
  45. package/dist/shared-tree/index.d.ts.map +1 -1
  46. package/dist/shared-tree/index.js +1 -3
  47. package/dist/shared-tree/index.js.map +1 -1
  48. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  49. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  50. package/dist/shared-tree/schematizeTree.js +7 -10
  51. package/dist/shared-tree/schematizeTree.js.map +1 -1
  52. package/dist/shared-tree/schematizingTreeView.d.ts +11 -13
  53. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  54. package/dist/shared-tree/schematizingTreeView.js +60 -83
  55. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  56. package/dist/shared-tree/sharedTreeChangeTypes.d.ts +1 -1
  57. package/dist/shared-tree/sharedTreeChangeTypes.js.map +1 -1
  58. package/dist/shared-tree/tree.d.ts.map +1 -1
  59. package/dist/shared-tree/tree.js +4 -3
  60. package/dist/shared-tree/tree.js.map +1 -1
  61. package/dist/shared-tree/treeAlpha.d.ts +7 -1
  62. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  63. package/dist/shared-tree/treeAlpha.js.map +1 -1
  64. package/dist/shared-tree/treeCheckout.d.ts +7 -2
  65. package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
  66. package/dist/shared-tree/treeCheckout.js +4 -1
  67. package/dist/shared-tree/treeCheckout.js.map +1 -1
  68. package/dist/simple-tree/api/conciseTree.d.ts +1 -1
  69. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  70. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  71. package/dist/simple-tree/api/configuration.d.ts +1 -1
  72. package/dist/simple-tree/api/configuration.d.ts.map +1 -1
  73. package/dist/simple-tree/api/configuration.js +5 -5
  74. package/dist/simple-tree/api/configuration.js.map +1 -1
  75. package/dist/simple-tree/api/create.d.ts +3 -1
  76. package/dist/simple-tree/api/create.d.ts.map +1 -1
  77. package/dist/simple-tree/api/create.js +2 -0
  78. package/dist/simple-tree/api/create.js.map +1 -1
  79. package/dist/simple-tree/api/customTree.d.ts +1 -2
  80. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  81. package/dist/simple-tree/api/customTree.js.map +1 -1
  82. package/dist/simple-tree/api/getJsonSchema.d.ts +1 -1
  83. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  84. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  85. package/dist/simple-tree/api/getSimpleSchema.d.ts +1 -1
  86. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  87. package/dist/simple-tree/api/identifierIndex.d.ts +1 -1
  88. package/dist/simple-tree/api/identifierIndex.js +2 -2
  89. package/dist/simple-tree/api/identifierIndex.js.map +1 -1
  90. package/dist/simple-tree/api/index.d.ts +1 -1
  91. package/dist/simple-tree/api/index.d.ts.map +1 -1
  92. package/dist/simple-tree/api/index.js.map +1 -1
  93. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +4 -19
  94. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  95. package/dist/simple-tree/api/schemaCompatibilityTester.js +31 -82
  96. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  97. package/dist/simple-tree/api/schemaCreationUtilities.d.ts +14 -2
  98. package/dist/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  99. package/dist/simple-tree/api/schemaCreationUtilities.js +41 -4
  100. package/dist/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  101. package/dist/simple-tree/api/schemaFactory.d.ts +36 -3
  102. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  103. package/dist/simple-tree/api/schemaFactory.js +18 -18
  104. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  105. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +16 -16
  106. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  107. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  108. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
  109. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  110. package/dist/simple-tree/api/schemaFactoryRecursive.js +2 -2
  111. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  112. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  113. package/dist/simple-tree/api/schemaFromSimple.js +4 -4
  114. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  115. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +2 -2
  116. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  117. package/dist/simple-tree/api/simpleTreeIndex.d.ts +2 -2
  118. package/dist/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  119. package/dist/simple-tree/api/simpleTreeIndex.js +1 -1
  120. package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
  121. package/dist/simple-tree/api/storedSchema.d.ts +1 -1
  122. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  123. package/dist/simple-tree/api/storedSchema.js +2 -2
  124. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  125. package/dist/simple-tree/api/tree.d.ts +2 -1
  126. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  127. package/dist/simple-tree/api/tree.js.map +1 -1
  128. package/dist/simple-tree/api/treeBeta.d.ts +4 -1
  129. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
  130. package/dist/simple-tree/api/treeBeta.js.map +1 -1
  131. package/dist/simple-tree/api/treeNodeApi.d.ts +1 -2
  132. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  133. package/dist/simple-tree/api/treeNodeApi.js +3 -3
  134. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  135. package/dist/simple-tree/api/typesUnsafe.d.ts +2 -3
  136. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  137. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  138. package/dist/simple-tree/api/verboseTree.d.ts +2 -1
  139. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  140. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  141. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +1 -1
  142. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +2 -2
  143. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  144. package/dist/simple-tree/core/allowedTypes.d.ts +316 -0
  145. package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -0
  146. package/dist/simple-tree/core/allowedTypes.js +173 -0
  147. package/dist/simple-tree/core/allowedTypes.js.map +1 -0
  148. package/dist/simple-tree/core/context.d.ts +3 -9
  149. package/dist/simple-tree/core/context.d.ts.map +1 -1
  150. package/dist/simple-tree/core/context.js +3 -11
  151. package/dist/simple-tree/core/context.js.map +1 -1
  152. package/dist/simple-tree/core/flexList.d.ts.map +1 -0
  153. package/dist/simple-tree/core/flexList.js.map +1 -0
  154. package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
  155. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  156. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  157. package/dist/simple-tree/core/index.d.ts +9 -3
  158. package/dist/simple-tree/core/index.d.ts.map +1 -1
  159. package/dist/simple-tree/core/index.js +19 -3
  160. package/dist/simple-tree/core/index.js.map +1 -1
  161. package/dist/simple-tree/core/treeNodeKernel.d.ts +8 -1
  162. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  163. package/dist/simple-tree/core/treeNodeKernel.js +24 -20
  164. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  165. package/dist/simple-tree/core/treeNodeSchema.d.ts +182 -39
  166. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  167. package/dist/simple-tree/core/treeNodeSchema.js +47 -17
  168. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  169. package/{lib/simple-tree → dist/simple-tree/core}/treeNodeValid.d.ts +18 -4
  170. package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -0
  171. package/dist/simple-tree/{treeNodeValid.js → core/treeNodeValid.js} +41 -11
  172. package/dist/simple-tree/core/treeNodeValid.js.map +1 -0
  173. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  174. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  175. package/dist/simple-tree/core/walkSchema.d.ts +2 -1
  176. package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
  177. package/dist/simple-tree/core/walkSchema.js +6 -2
  178. package/dist/simple-tree/core/walkSchema.js.map +1 -1
  179. package/dist/simple-tree/createContext.d.ts +6 -2
  180. package/dist/simple-tree/createContext.d.ts.map +1 -1
  181. package/dist/simple-tree/createContext.js +15 -3
  182. package/dist/simple-tree/createContext.js.map +1 -1
  183. package/dist/{feature-libraries/modular-schema → simple-tree}/discrepancies.d.ts +22 -29
  184. package/dist/simple-tree/discrepancies.d.ts.map +1 -0
  185. package/dist/simple-tree/discrepancies.js +382 -0
  186. package/dist/simple-tree/discrepancies.js.map +1 -0
  187. package/dist/simple-tree/fieldSchema.d.ts +423 -0
  188. package/dist/simple-tree/fieldSchema.d.ts.map +1 -0
  189. package/dist/simple-tree/{schemaTypes.js → fieldSchema.js} +5 -195
  190. package/dist/simple-tree/fieldSchema.js.map +1 -0
  191. package/dist/simple-tree/index.d.ts +7 -6
  192. package/dist/simple-tree/index.d.ts.map +1 -1
  193. package/dist/simple-tree/index.js +17 -11
  194. package/dist/simple-tree/index.js.map +1 -1
  195. package/dist/simple-tree/leafNodeSchema.d.ts +14 -5
  196. package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
  197. package/dist/simple-tree/leafNodeSchema.js +117 -2
  198. package/dist/simple-tree/leafNodeSchema.js.map +1 -1
  199. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
  200. package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  201. package/dist/simple-tree/node-kinds/array/arrayNode.js +97 -26
  202. package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  203. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +2 -2
  204. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  205. package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  206. package/dist/simple-tree/node-kinds/common.d.ts +16 -0
  207. package/dist/simple-tree/node-kinds/common.d.ts.map +1 -0
  208. package/dist/simple-tree/node-kinds/common.js +42 -0
  209. package/dist/simple-tree/node-kinds/common.js.map +1 -0
  210. package/dist/simple-tree/node-kinds/index.d.ts +1 -1
  211. package/dist/simple-tree/node-kinds/index.d.ts.map +1 -1
  212. package/dist/simple-tree/node-kinds/index.js.map +1 -1
  213. package/dist/simple-tree/node-kinds/map/mapNode.d.ts +2 -3
  214. package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  215. package/dist/simple-tree/node-kinds/map/mapNode.js +64 -26
  216. package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  217. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +2 -2
  218. package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  219. package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  220. package/dist/simple-tree/node-kinds/object/index.d.ts +2 -2
  221. package/dist/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  222. package/dist/simple-tree/node-kinds/object/index.js.map +1 -1
  223. package/dist/simple-tree/node-kinds/object/objectNode.d.ts +19 -5
  224. package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  225. package/dist/simple-tree/node-kinds/object/objectNode.js +131 -27
  226. package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  227. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +11 -4
  228. package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  229. package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  230. package/dist/simple-tree/node-kinds/record/recordNode.d.ts +2 -2
  231. package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  232. package/dist/simple-tree/node-kinds/record/recordNode.js +41 -13
  233. package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  234. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
  235. package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  236. package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  237. package/dist/simple-tree/prepareForInsertion.d.ts +2 -2
  238. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
  239. package/dist/simple-tree/prepareForInsertion.js +3 -3
  240. package/dist/simple-tree/prepareForInsertion.js.map +1 -1
  241. package/dist/simple-tree/simpleSchema.d.ts +2 -2
  242. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  243. package/dist/simple-tree/simpleSchema.js.map +1 -1
  244. package/dist/simple-tree/toStoredSchema.d.ts +1 -1
  245. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  246. package/dist/simple-tree/toStoredSchema.js +6 -7
  247. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  248. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +5 -11
  249. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  250. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js +25 -395
  251. package/dist/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  252. package/dist/simple-tree/unsafeUnknownSchema.d.ts +52 -0
  253. package/dist/simple-tree/unsafeUnknownSchema.d.ts.map +1 -0
  254. package/dist/simple-tree/unsafeUnknownSchema.js +13 -0
  255. package/dist/simple-tree/unsafeUnknownSchema.js.map +1 -0
  256. package/dist/simple-tree/walkFieldSchema.d.ts +1 -1
  257. package/dist/simple-tree/walkFieldSchema.js +2 -2
  258. package/dist/simple-tree/walkFieldSchema.js.map +1 -1
  259. package/dist/tableSchema.d.ts +12 -12
  260. package/dist/treeFactory.d.ts +0 -1
  261. package/dist/treeFactory.d.ts.map +1 -1
  262. package/dist/treeFactory.js +0 -1
  263. package/dist/treeFactory.js.map +1 -1
  264. package/lib/core/schema-stored/schema.d.ts +14 -1
  265. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  266. package/lib/core/schema-stored/schema.js.map +1 -1
  267. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  268. package/lib/feature-libraries/default-schema/schemaChecker.js +3 -0
  269. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  270. package/lib/feature-libraries/flex-tree/context.d.ts +7 -2
  271. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  272. package/lib/feature-libraries/flex-tree/context.js +4 -4
  273. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  274. package/lib/feature-libraries/flex-tree/index.d.ts +1 -0
  275. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  276. package/lib/feature-libraries/flex-tree/index.js +1 -0
  277. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  278. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  279. package/lib/feature-libraries/flex-tree/lazyField.js +6 -6
  280. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  281. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +3 -1
  282. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  283. package/lib/feature-libraries/flex-tree/lazyNode.js +3 -1
  284. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  285. package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
  286. package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -2
  287. package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
  288. package/lib/feature-libraries/index.d.ts +2 -2
  289. package/lib/feature-libraries/index.d.ts.map +1 -1
  290. package/lib/feature-libraries/index.js +2 -2
  291. package/lib/feature-libraries/index.js.map +1 -1
  292. package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
  293. package/lib/feature-libraries/modular-schema/comparison.js +0 -3
  294. package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
  295. package/lib/feature-libraries/modular-schema/index.d.ts +0 -1
  296. package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
  297. package/lib/feature-libraries/modular-schema/index.js +0 -1
  298. package/lib/feature-libraries/modular-schema/index.js.map +1 -1
  299. package/lib/packageVersion.d.ts +1 -1
  300. package/lib/packageVersion.js +1 -1
  301. package/lib/packageVersion.js.map +1 -1
  302. package/lib/shared-tree/index.d.ts +0 -1
  303. package/lib/shared-tree/index.d.ts.map +1 -1
  304. package/lib/shared-tree/index.js +0 -1
  305. package/lib/shared-tree/index.js.map +1 -1
  306. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  307. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  308. package/lib/shared-tree/schematizeTree.js +5 -8
  309. package/lib/shared-tree/schematizeTree.js.map +1 -1
  310. package/lib/shared-tree/schematizingTreeView.d.ts +11 -13
  311. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  312. package/lib/shared-tree/schematizingTreeView.js +61 -83
  313. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  314. package/lib/shared-tree/sharedTreeChangeTypes.d.ts +1 -1
  315. package/lib/shared-tree/sharedTreeChangeTypes.js.map +1 -1
  316. package/lib/shared-tree/tree.d.ts.map +1 -1
  317. package/lib/shared-tree/tree.js +4 -3
  318. package/lib/shared-tree/tree.js.map +1 -1
  319. package/lib/shared-tree/treeAlpha.d.ts +7 -1
  320. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  321. package/lib/shared-tree/treeAlpha.js.map +1 -1
  322. package/lib/shared-tree/treeCheckout.d.ts +7 -2
  323. package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
  324. package/lib/shared-tree/treeCheckout.js +5 -2
  325. package/lib/shared-tree/treeCheckout.js.map +1 -1
  326. package/lib/simple-tree/api/conciseTree.d.ts +1 -1
  327. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  328. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  329. package/lib/simple-tree/api/configuration.d.ts +1 -1
  330. package/lib/simple-tree/api/configuration.d.ts.map +1 -1
  331. package/lib/simple-tree/api/configuration.js +2 -2
  332. package/lib/simple-tree/api/configuration.js.map +1 -1
  333. package/lib/simple-tree/api/create.d.ts +3 -1
  334. package/lib/simple-tree/api/create.d.ts.map +1 -1
  335. package/lib/simple-tree/api/create.js +2 -0
  336. package/lib/simple-tree/api/create.js.map +1 -1
  337. package/lib/simple-tree/api/customTree.d.ts +1 -2
  338. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  339. package/lib/simple-tree/api/customTree.js.map +1 -1
  340. package/lib/simple-tree/api/getJsonSchema.d.ts +1 -1
  341. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  342. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  343. package/lib/simple-tree/api/getSimpleSchema.d.ts +1 -1
  344. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  345. package/lib/simple-tree/api/identifierIndex.d.ts +1 -1
  346. package/lib/simple-tree/api/identifierIndex.js +1 -1
  347. package/lib/simple-tree/api/identifierIndex.js.map +1 -1
  348. package/lib/simple-tree/api/index.d.ts +1 -1
  349. package/lib/simple-tree/api/index.d.ts.map +1 -1
  350. package/lib/simple-tree/api/index.js.map +1 -1
  351. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +4 -19
  352. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  353. package/lib/simple-tree/api/schemaCompatibilityTester.js +25 -76
  354. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  355. package/lib/simple-tree/api/schemaCreationUtilities.d.ts +14 -2
  356. package/lib/simple-tree/api/schemaCreationUtilities.d.ts.map +1 -1
  357. package/lib/simple-tree/api/schemaCreationUtilities.js +40 -4
  358. package/lib/simple-tree/api/schemaCreationUtilities.js.map +1 -1
  359. package/lib/simple-tree/api/schemaFactory.d.ts +36 -3
  360. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  361. package/lib/simple-tree/api/schemaFactory.js +2 -2
  362. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  363. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +16 -16
  364. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  365. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  366. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +2 -2
  367. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  368. package/lib/simple-tree/api/schemaFactoryRecursive.js +1 -1
  369. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  370. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  371. package/lib/simple-tree/api/schemaFromSimple.js +1 -1
  372. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  373. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +1 -1
  374. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  375. package/lib/simple-tree/api/simpleTreeIndex.d.ts +2 -2
  376. package/lib/simple-tree/api/simpleTreeIndex.d.ts.map +1 -1
  377. package/lib/simple-tree/api/simpleTreeIndex.js +2 -2
  378. package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
  379. package/lib/simple-tree/api/storedSchema.d.ts +1 -1
  380. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  381. package/lib/simple-tree/api/storedSchema.js +2 -2
  382. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  383. package/lib/simple-tree/api/tree.d.ts +2 -1
  384. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  385. package/lib/simple-tree/api/tree.js.map +1 -1
  386. package/lib/simple-tree/api/treeBeta.d.ts +4 -1
  387. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
  388. package/lib/simple-tree/api/treeBeta.js.map +1 -1
  389. package/lib/simple-tree/api/treeNodeApi.d.ts +1 -2
  390. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  391. package/lib/simple-tree/api/treeNodeApi.js +2 -2
  392. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  393. package/lib/simple-tree/api/typesUnsafe.d.ts +2 -3
  394. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  395. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  396. package/lib/simple-tree/api/verboseTree.d.ts +2 -1
  397. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  398. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  399. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +1 -1
  400. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +1 -1
  401. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  402. package/lib/simple-tree/core/allowedTypes.d.ts +316 -0
  403. package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -0
  404. package/lib/simple-tree/core/allowedTypes.js +162 -0
  405. package/lib/simple-tree/core/allowedTypes.js.map +1 -0
  406. package/lib/simple-tree/core/context.d.ts +3 -9
  407. package/lib/simple-tree/core/context.d.ts.map +1 -1
  408. package/lib/simple-tree/core/context.js +0 -8
  409. package/lib/simple-tree/core/context.js.map +1 -1
  410. package/lib/simple-tree/core/flexList.d.ts.map +1 -0
  411. package/lib/simple-tree/core/flexList.js.map +1 -0
  412. package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
  413. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  414. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  415. package/lib/simple-tree/core/index.d.ts +9 -3
  416. package/lib/simple-tree/core/index.d.ts.map +1 -1
  417. package/lib/simple-tree/core/index.js +6 -3
  418. package/lib/simple-tree/core/index.js.map +1 -1
  419. package/lib/simple-tree/core/treeNodeKernel.d.ts +8 -1
  420. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  421. package/lib/simple-tree/core/treeNodeKernel.js +10 -6
  422. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  423. package/lib/simple-tree/core/treeNodeSchema.d.ts +182 -39
  424. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  425. package/lib/simple-tree/core/treeNodeSchema.js +44 -14
  426. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  427. package/{dist/simple-tree → lib/simple-tree/core}/treeNodeValid.d.ts +18 -4
  428. package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -0
  429. package/lib/simple-tree/{treeNodeValid.js → core/treeNodeValid.js} +31 -3
  430. package/lib/simple-tree/core/treeNodeValid.js.map +1 -0
  431. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +1 -1
  432. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  433. package/lib/simple-tree/core/walkSchema.d.ts +2 -1
  434. package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
  435. package/lib/simple-tree/core/walkSchema.js +7 -3
  436. package/lib/simple-tree/core/walkSchema.js.map +1 -1
  437. package/lib/simple-tree/createContext.d.ts +6 -2
  438. package/lib/simple-tree/createContext.d.ts.map +1 -1
  439. package/lib/simple-tree/createContext.js +13 -2
  440. package/lib/simple-tree/createContext.js.map +1 -1
  441. package/lib/{feature-libraries/modular-schema → simple-tree}/discrepancies.d.ts +22 -29
  442. package/lib/simple-tree/discrepancies.d.ts.map +1 -0
  443. package/lib/simple-tree/discrepancies.js +376 -0
  444. package/lib/simple-tree/discrepancies.js.map +1 -0
  445. package/lib/simple-tree/fieldSchema.d.ts +423 -0
  446. package/lib/simple-tree/fieldSchema.d.ts.map +1 -0
  447. package/lib/simple-tree/{schemaTypes.js → fieldSchema.js} +3 -183
  448. package/lib/simple-tree/fieldSchema.js.map +1 -0
  449. package/lib/simple-tree/index.d.ts +7 -6
  450. package/lib/simple-tree/index.d.ts.map +1 -1
  451. package/lib/simple-tree/index.js +4 -3
  452. package/lib/simple-tree/index.js.map +1 -1
  453. package/lib/simple-tree/leafNodeSchema.d.ts +14 -5
  454. package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
  455. package/lib/simple-tree/leafNodeSchema.js +117 -3
  456. package/lib/simple-tree/leafNodeSchema.js.map +1 -1
  457. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
  458. package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
  459. package/lib/simple-tree/node-kinds/array/arrayNode.js +86 -15
  460. package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
  461. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +2 -2
  462. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
  463. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js +1 -1
  464. package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
  465. package/lib/simple-tree/node-kinds/common.d.ts +16 -0
  466. package/lib/simple-tree/node-kinds/common.d.ts.map +1 -0
  467. package/lib/simple-tree/node-kinds/common.js +38 -0
  468. package/lib/simple-tree/node-kinds/common.js.map +1 -0
  469. package/lib/simple-tree/node-kinds/index.d.ts +1 -1
  470. package/lib/simple-tree/node-kinds/index.d.ts.map +1 -1
  471. package/lib/simple-tree/node-kinds/index.js.map +1 -1
  472. package/lib/simple-tree/node-kinds/map/mapNode.d.ts +2 -3
  473. package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
  474. package/lib/simple-tree/node-kinds/map/mapNode.js +51 -13
  475. package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
  476. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +2 -2
  477. package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
  478. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js +1 -1
  479. package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
  480. package/lib/simple-tree/node-kinds/object/index.d.ts +2 -2
  481. package/lib/simple-tree/node-kinds/object/index.d.ts.map +1 -1
  482. package/lib/simple-tree/node-kinds/object/index.js.map +1 -1
  483. package/lib/simple-tree/node-kinds/object/objectNode.d.ts +19 -5
  484. package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
  485. package/lib/simple-tree/node-kinds/object/objectNode.js +116 -14
  486. package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
  487. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +11 -4
  488. package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
  489. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js +1 -1
  490. package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
  491. package/lib/simple-tree/node-kinds/record/recordNode.d.ts +2 -2
  492. package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
  493. package/lib/simple-tree/node-kinds/record/recordNode.js +40 -12
  494. package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
  495. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
  496. package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
  497. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js +1 -1
  498. package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
  499. package/lib/simple-tree/prepareForInsertion.d.ts +2 -2
  500. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
  501. package/lib/simple-tree/prepareForInsertion.js +2 -2
  502. package/lib/simple-tree/prepareForInsertion.js.map +1 -1
  503. package/lib/simple-tree/simpleSchema.d.ts +2 -2
  504. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  505. package/lib/simple-tree/simpleSchema.js.map +1 -1
  506. package/lib/simple-tree/toStoredSchema.d.ts +1 -1
  507. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  508. package/lib/simple-tree/toStoredSchema.js +2 -3
  509. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  510. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts +5 -11
  511. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.d.ts.map +1 -1
  512. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js +10 -381
  513. package/lib/simple-tree/unhydratedFlexTreeFromInsertable.js.map +1 -1
  514. package/lib/simple-tree/unsafeUnknownSchema.d.ts +52 -0
  515. package/lib/simple-tree/unsafeUnknownSchema.d.ts.map +1 -0
  516. package/lib/simple-tree/unsafeUnknownSchema.js +10 -0
  517. package/lib/simple-tree/unsafeUnknownSchema.js.map +1 -0
  518. package/lib/simple-tree/walkFieldSchema.d.ts +1 -1
  519. package/lib/simple-tree/walkFieldSchema.js +1 -1
  520. package/lib/simple-tree/walkFieldSchema.js.map +1 -1
  521. package/lib/tableSchema.d.ts +12 -12
  522. package/lib/treeFactory.d.ts +0 -1
  523. package/lib/treeFactory.d.ts.map +1 -1
  524. package/lib/treeFactory.js +0 -1
  525. package/lib/treeFactory.js.map +1 -1
  526. package/package.json +22 -23
  527. package/src/core/schema-stored/schema.ts +14 -1
  528. package/src/feature-libraries/default-schema/schemaChecker.ts +3 -0
  529. package/src/feature-libraries/flex-tree/context.ts +10 -5
  530. package/src/feature-libraries/flex-tree/index.ts +2 -0
  531. package/src/feature-libraries/flex-tree/lazyField.ts +10 -6
  532. package/src/feature-libraries/flex-tree/lazyNode.ts +6 -1
  533. package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -2
  534. package/src/feature-libraries/index.ts +1 -15
  535. package/src/feature-libraries/modular-schema/comparison.ts +0 -4
  536. package/src/feature-libraries/modular-schema/index.ts +0 -17
  537. package/src/packageVersion.ts +1 -1
  538. package/src/shared-tree/index.ts +0 -2
  539. package/src/shared-tree/schematizeTree.ts +5 -9
  540. package/src/shared-tree/schematizingTreeView.ts +75 -113
  541. package/src/shared-tree/sharedTreeChangeTypes.ts +1 -1
  542. package/src/shared-tree/tree.ts +4 -3
  543. package/src/shared-tree/treeAlpha.ts +7 -1
  544. package/src/shared-tree/treeCheckout.ts +15 -2
  545. package/src/simple-tree/api/conciseTree.ts +1 -2
  546. package/src/simple-tree/api/configuration.ts +7 -4
  547. package/src/simple-tree/api/create.ts +3 -1
  548. package/src/simple-tree/api/customTree.ts +1 -2
  549. package/src/simple-tree/api/getJsonSchema.ts +1 -1
  550. package/src/simple-tree/api/getSimpleSchema.ts +1 -1
  551. package/src/simple-tree/api/identifierIndex.ts +1 -1
  552. package/src/simple-tree/api/index.ts +2 -0
  553. package/src/simple-tree/api/schemaCompatibilityTester.ts +38 -128
  554. package/src/simple-tree/api/schemaCreationUtilities.ts +50 -5
  555. package/src/simple-tree/api/schemaFactory.ts +45 -10
  556. package/src/simple-tree/api/schemaFactoryAlpha.ts +4 -7
  557. package/src/simple-tree/api/schemaFactoryRecursive.ts +9 -4
  558. package/src/simple-tree/api/schemaFromSimple.ts +2 -3
  559. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  560. package/src/simple-tree/api/simpleTreeIndex.ts +8 -3
  561. package/src/simple-tree/api/storedSchema.ts +1 -2
  562. package/src/simple-tree/api/tree.ts +2 -2
  563. package/src/simple-tree/api/treeBeta.ts +4 -1
  564. package/src/simple-tree/api/treeNodeApi.ts +5 -8
  565. package/src/simple-tree/api/typesUnsafe.ts +5 -4
  566. package/src/simple-tree/api/verboseTree.ts +3 -6
  567. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +1 -1
  568. package/src/simple-tree/core/README.md +1 -1
  569. package/src/simple-tree/core/allowedTypes.ts +496 -0
  570. package/src/simple-tree/core/context.ts +3 -10
  571. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  572. package/src/simple-tree/core/index.ts +62 -9
  573. package/src/simple-tree/core/treeNodeKernel.ts +12 -6
  574. package/src/simple-tree/core/treeNodeSchema.ts +247 -63
  575. package/src/simple-tree/{treeNodeValid.ts → core/treeNodeValid.ts} +59 -15
  576. package/src/simple-tree/core/unhydratedFlexTree.ts +1 -1
  577. package/src/simple-tree/core/walkSchema.ts +9 -5
  578. package/src/simple-tree/createContext.ts +26 -2
  579. package/src/simple-tree/discrepancies.ts +648 -0
  580. package/src/simple-tree/fieldSchema.ts +734 -0
  581. package/src/simple-tree/index.ts +41 -31
  582. package/src/simple-tree/leafNodeSchema.ts +137 -5
  583. package/src/simple-tree/node-kinds/array/arrayNode.ts +141 -30
  584. package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +5 -7
  585. package/src/simple-tree/node-kinds/common.ts +60 -0
  586. package/src/simple-tree/node-kinds/index.ts +2 -0
  587. package/src/simple-tree/node-kinds/map/mapNode.ts +91 -33
  588. package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +5 -7
  589. package/src/simple-tree/node-kinds/object/index.ts +2 -0
  590. package/src/simple-tree/node-kinds/object/objectNode.ts +205 -25
  591. package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +22 -5
  592. package/src/simple-tree/node-kinds/record/recordNode.ts +68 -26
  593. package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +6 -8
  594. package/src/simple-tree/prepareForInsertion.ts +7 -6
  595. package/src/simple-tree/simpleSchema.ts +2 -2
  596. package/src/simple-tree/toStoredSchema.ts +2 -3
  597. package/src/simple-tree/unhydratedFlexTreeFromInsertable.ts +12 -494
  598. package/src/simple-tree/unsafeUnknownSchema.ts +70 -0
  599. package/src/simple-tree/walkFieldSchema.ts +1 -1
  600. package/src/treeFactory.ts +0 -1
  601. package/dist/feature-libraries/modular-schema/discrepancies.d.ts.map +0 -1
  602. package/dist/feature-libraries/modular-schema/discrepancies.js +0 -361
  603. package/dist/feature-libraries/modular-schema/discrepancies.js.map +0 -1
  604. package/dist/shared-tree/checkoutFlexTreeView.d.ts +0 -58
  605. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +0 -1
  606. package/dist/shared-tree/checkoutFlexTreeView.js +0 -77
  607. package/dist/shared-tree/checkoutFlexTreeView.js.map +0 -1
  608. package/dist/simple-tree/flexList.d.ts.map +0 -1
  609. package/dist/simple-tree/flexList.js.map +0 -1
  610. package/dist/simple-tree/schemaTypes.d.ts +0 -856
  611. package/dist/simple-tree/schemaTypes.d.ts.map +0 -1
  612. package/dist/simple-tree/schemaTypes.js.map +0 -1
  613. package/dist/simple-tree/treeNodeValid.d.ts.map +0 -1
  614. package/dist/simple-tree/treeNodeValid.js.map +0 -1
  615. package/lib/feature-libraries/modular-schema/discrepancies.d.ts.map +0 -1
  616. package/lib/feature-libraries/modular-schema/discrepancies.js +0 -354
  617. package/lib/feature-libraries/modular-schema/discrepancies.js.map +0 -1
  618. package/lib/shared-tree/checkoutFlexTreeView.d.ts +0 -58
  619. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +0 -1
  620. package/lib/shared-tree/checkoutFlexTreeView.js +0 -72
  621. package/lib/shared-tree/checkoutFlexTreeView.js.map +0 -1
  622. package/lib/simple-tree/flexList.d.ts.map +0 -1
  623. package/lib/simple-tree/flexList.js.map +0 -1
  624. package/lib/simple-tree/schemaTypes.d.ts +0 -856
  625. package/lib/simple-tree/schemaTypes.d.ts.map +0 -1
  626. package/lib/simple-tree/schemaTypes.js.map +0 -1
  627. package/lib/simple-tree/treeNodeValid.d.ts.map +0 -1
  628. package/lib/simple-tree/treeNodeValid.js.map +0 -1
  629. package/src/feature-libraries/modular-schema/discrepancies.ts +0 -567
  630. package/src/shared-tree/checkoutFlexTreeView.ts +0 -100
  631. package/src/simple-tree/schemaTypes.ts +0 -1420
  632. /package/dist/simple-tree/{flexList.d.ts → core/flexList.d.ts} +0 -0
  633. /package/dist/simple-tree/{flexList.js → core/flexList.js} +0 -0
  634. /package/lib/simple-tree/{flexList.d.ts → core/flexList.d.ts} +0 -0
  635. /package/lib/simple-tree/{flexList.js → core/flexList.js} +0 -0
  636. /package/src/simple-tree/{flexList.ts → core/flexList.ts} +0 -0
@@ -1,1420 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import type { ErasedType, IFluidHandle } from "@fluidframework/core-interfaces";
7
- import { Lazy } from "@fluidframework/core-utils/internal";
8
- import { UsageError } from "@fluidframework/telemetry-utils/internal";
9
-
10
- import type { FieldKey } from "../core/index.js";
11
- import type { FlexTreeHydratedContextMinimal } from "../feature-libraries/index.js";
12
- import {
13
- type MakeNominal,
14
- brand,
15
- isReadonlyArray,
16
- type UnionToIntersection,
17
- compareSets,
18
- type requireTrue,
19
- type areOnlyKeys,
20
- getOrCreate,
21
- type RestrictiveStringRecord,
22
- type IsUnion,
23
- type JsonCompatibleReadOnlyObject,
24
- } from "../util/index.js";
25
-
26
- import type {
27
- Unhydrated,
28
- NodeKind,
29
- TreeNodeSchema,
30
- TreeNodeSchemaClass,
31
- TreeNode,
32
- TreeNodeSchemaCore,
33
- TreeNodeSchemaNonClass,
34
- UnhydratedFlexTreeNode,
35
- AnnotatedAllowedType,
36
- NormalizedAnnotatedAllowedTypes,
37
- } from "./core/index.js";
38
- import { inPrototypeChain, isAnnotatedAllowedTypes } from "./core/index.js";
39
- import { isLazy, type FlexListToUnion, type LazyItem } from "./flexList.js";
40
- import { LeafNodeSchema } from "./leafNodeSchema.js";
41
- import type { SimpleFieldSchema, SimpleObjectFieldSchema } from "./simpleSchema.js";
42
- import type { InsertableContent } from "./unhydratedFlexTreeFromInsertable.js";
43
- import { TreeNodeValid } from "./treeNodeValid.js";
44
-
45
- /**
46
- * Returns true if the given schema is a {@link TreeNodeSchemaClass}, or otherwise false if it is a {@link TreeNodeSchemaNonClass}.
47
- * @internal
48
- */
49
- export function isTreeNodeSchemaClass<
50
- Name extends string,
51
- Kind extends NodeKind,
52
- TNode extends TreeNode | TreeLeafValue,
53
- TBuild,
54
- ImplicitlyConstructable extends boolean,
55
- Info,
56
- >(
57
- schema:
58
- | TreeNodeSchema<Name, Kind, TNode, TBuild, ImplicitlyConstructable, Info>
59
- | TreeNodeSchemaClass<Name, Kind, TNode & TreeNode, TBuild, ImplicitlyConstructable, Info>,
60
- ): schema is TreeNodeSchemaClass<
61
- Name,
62
- Kind,
63
- TNode & TreeNode,
64
- TBuild,
65
- ImplicitlyConstructable,
66
- Info
67
- > {
68
- return schema.constructor !== undefined;
69
- }
70
-
71
- /**
72
- * Types for use in fields.
73
- * @remarks
74
- * Type constraint used in schema declaration APIs.
75
- *
76
- * The order of types in the array is not significant.
77
- * Additionally, it is legal for users of this type to have the runtime and compile time order of items within this array not match.
78
- * Therefor to ensure type safety, these arrays should not be indexed, and instead just be iterated.
79
- *
80
- * Ideally this restriction would be modeled in the type itself, but it is not ergonomic to do so as there is no easy (when compared to arrays)
81
- * way to declare and manipulate unordered sets of types in TypeScript.
82
- *
83
- * Duplicate entries in this array are not allowed and will produce runtime errors.
84
- * Duplicate types are allowed,
85
- * but this must only be reflected in the type and not the runtime values.
86
- * This duplication can be used to encode the typing when the number of items in the array is not known at compile time
87
- * but some of the items are known to be present unconditionally.
88
- * For example, typing `[typeof A] | [typeof A, typeof B]` as `[typeof A, typeof B | typeof A]` is allowed,
89
- * and can produce more useful {@link Input} types.
90
- * @privateRemarks
91
- * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.
92
- * @system @public
93
- */
94
- export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
95
-
96
- /**
97
- * Stores annotations for a set of allowed types.
98
- * @alpha
99
- */
100
- export interface AnnotatedAllowedTypes {
101
- /**
102
- * Annotations that apply to a set of allowed types.
103
- */
104
- readonly metadata: AllowedTypesMetadata;
105
- /**
106
- * All the allowed types that the annotations apply to. The types themselves may also have individual annotations.
107
- */
108
- readonly types: readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];
109
- }
110
-
111
- /**
112
- * Annotations that apply to a set of allowed types.
113
- * @remarks
114
- * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.
115
- * @alpha
116
- */
117
- export interface AllowedTypesMetadata {
118
- /**
119
- * User defined metadata
120
- */
121
- readonly custom?: unknown;
122
- }
123
-
124
- /**
125
- * Checks if the given allowed type is annotated with {@link AllowedTypeMetadata}.
126
- */
127
- export function isAnnotatedAllowedType(
128
- allowedType: AnnotatedAllowedType | LazyItem<TreeNodeSchema>,
129
- ): allowedType is AnnotatedAllowedType {
130
- return "metadata" in allowedType && "type" in allowedType;
131
- }
132
-
133
- /**
134
- * Annotations that apply to an individual allowed type.
135
- * @remarks
136
- * Additional optionals may be added to this as non-breaking changes, so implementations of it should be simple object literals with no unlisted members.
137
- * @alpha
138
- */
139
- export interface AllowedTypeMetadata {
140
- /**
141
- * User defined metadata
142
- */
143
- readonly custom?: unknown;
144
-
145
- // TODO metadata for enablable types will be added here
146
- }
147
-
148
- /**
149
- * Kind of a field on an {@link TreeObjectNode}.
150
- * @remarks
151
- * More kinds may be added over time, so do not assume this is an exhaustive set.
152
- * See {@link FieldSchema} for where these are used, and {@link SchemaFactory} for how to create schema which use them.
153
- * @public
154
- */
155
- export enum FieldKind {
156
- /**
157
- * A field which can be empty or filled.
158
- * @remarks
159
- * Allows 0 or one child.
160
- */
161
- Optional,
162
- /**
163
- * A field which must always be filled.
164
- * @remarks
165
- * Only allows exactly one child.
166
- */
167
- Required,
168
- /**
169
- * A special readonly field used for node identifier strings.
170
- * @remarks
171
- * Only allows exactly one child.
172
- *
173
- * See {@link SchemaFactory.identifier} for more details.
174
- */
175
- Identifier,
176
- }
177
-
178
- /**
179
- * Maps from a property key to its corresponding {@link FieldProps.key | stored key} for the provided
180
- * {@link ImplicitFieldSchema | field schema}.
181
- *
182
- * @remarks
183
- * If an explicit stored key was specified in the schema, it will be used.
184
- * Otherwise, the stored key is the same as the property key.
185
- */
186
- export function getStoredKey(
187
- propertyKey: string,
188
- fieldSchema: ImplicitAnnotatedFieldSchema,
189
- ): FieldKey {
190
- return brand(getExplicitStoredKey(fieldSchema) ?? propertyKey);
191
- }
192
-
193
- /**
194
- * Gets the {@link FieldProps.key | stored key} specified by the schema, if one was explicitly specified.
195
- * Otherwise, returns undefined.
196
- */
197
- export function getExplicitStoredKey(
198
- fieldSchema: ImplicitAnnotatedFieldSchema,
199
- ): string | undefined {
200
- return fieldSchema instanceof FieldSchema ? fieldSchema.props?.key : undefined;
201
- }
202
-
203
- /**
204
- * Additional information to provide to a {@link FieldSchema}.
205
- *
206
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
207
- * See {@link FieldSchemaMetadata.custom}.
208
- *
209
- * @public
210
- */
211
- export interface FieldProps<TCustomMetadata = unknown> {
212
- /**
213
- * The unique identifier of a field, used in the persisted form of the tree.
214
- *
215
- * @remarks
216
- * If not explicitly set via the schema, this is the same as the schema's property key.
217
- *
218
- * Specifying a stored key that differs from the property key is particularly useful in refactoring scenarios.
219
- * To update the developer-facing API, while maintaining backwards compatibility with existing SharedTree data,
220
- * you can change the property key and specify the previous property key as the stored key.
221
- *
222
- * Notes:
223
- *
224
- * - Stored keys have no impact on standard JavaScript behavior, on tree nodes. For example, `Object.keys`
225
- * will always return the property keys specified in the schema, ignoring any stored keys that differ from
226
- * the property keys.
227
- *
228
- * - When specifying stored keys in an object schema, you must ensure that the final set of stored keys
229
- * (accounting for those implicitly derived from property keys) contains no duplicates.
230
- * This is validated at runtime.
231
- *
232
- * @example Refactoring code without breaking compatibility with existing data
233
- *
234
- * Consider some existing object schema:
235
- *
236
- * ```TypeScript
237
- * class Point extends schemaFactory.object("Point", {
238
- * xPosition: schemaFactory.number,
239
- * yPosition: schemaFactory.number,
240
- * zPosition: schemaFactory.optional(schemaFactory.number),
241
- * });
242
- * ```
243
- *
244
- * Developers using nodes of this type would access the the `xPosition` property as `point.xPosition`.
245
- *
246
- * We would like to refactor the schema to omit "Position" from the property keys, but application data has
247
- * already been persisted using the original property keys. To maintain compatibility with existing data,
248
- * we can refactor the schema as follows:
249
- *
250
- * ```TypeScript
251
- * class Point extends schemaFactory.object("Point", {
252
- * x: schemaFactory.required(schemaFactory.number, { key: "xPosition" }),
253
- * y: schemaFactory.required(schemaFactory.number, { key: "yPosition" }),
254
- * z: schemaFactory.optional(schemaFactory.number, { key: "zPosition" }),
255
- * });
256
- * ```
257
- *
258
- * Now, developers can access the `x` property as `point.x`, while existing data can still be collaborated on.
259
- *
260
- * @defaultValue If not specified, the key that is persisted is the property key that was specified in the schema.
261
- */
262
- readonly key?: string;
263
-
264
- /**
265
- * A default provider used for fields which were not provided any values.
266
- * @privateRemarks
267
- * We are using an erased type here, as we want to expose this API but `InsertableContent` and `NodeKeyManager` are not public.
268
- */
269
- readonly defaultProvider?: DefaultProvider;
270
-
271
- /**
272
- * Optional metadata to associate with the field.
273
- *
274
- * @remarks
275
- * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.
276
- * Different clients in the same collaborative session may see different metadata for the same field.
277
- */
278
- readonly metadata?: FieldSchemaMetadata<TCustomMetadata>;
279
- }
280
-
281
- /**
282
- * {@link FieldProps} extended with additional `alpha` options.
283
- *
284
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
285
- * See {@link FieldSchemaMetadata.custom}.
286
- *
287
- * @alpha @input
288
- */
289
- export interface FieldPropsAlpha<TCustomMetadata = unknown>
290
- extends FieldProps<TCustomMetadata> {
291
- /**
292
- * The persisted metadata for this schema element.
293
- */
294
- readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
295
- }
296
-
297
- /**
298
- * A {@link FieldProvider} which requires additional context in order to produce its content
299
- */
300
- export type ContextualFieldProvider = (
301
- context: FlexTreeHydratedContextMinimal | "UseGlobalContext",
302
- ) => UnhydratedFlexTreeNode[];
303
- /**
304
- * A {@link FieldProvider} which can produce its content in a vacuum.
305
- */
306
- export type ConstantFieldProvider = () => UnhydratedFlexTreeNode[];
307
- /**
308
- * A function which produces content for a field every time that it is called.
309
- */
310
- export type FieldProvider = ContextualFieldProvider | ConstantFieldProvider;
311
- /**
312
- * Returns true if the given {@link FieldProvider} is a {@link ConstantFieldProvider}
313
- */
314
- export function isConstant(
315
- fieldProvider: FieldProvider,
316
- ): fieldProvider is ConstantFieldProvider {
317
- return fieldProvider.length === 0;
318
- }
319
-
320
- /**
321
- * Provides a default value for a field.
322
- * @remarks
323
- * If present in a `FieldSchema`, when constructing new tree content that field can be omitted, and a default will be provided.
324
- * @system @sealed @public
325
- */
326
- export interface DefaultProvider extends ErasedType<"@fluidframework/tree.FieldProvider"> {}
327
-
328
- export function extractFieldProvider(input: DefaultProvider): FieldProvider {
329
- return input as unknown as FieldProvider;
330
- }
331
-
332
- export function getDefaultProvider(input: FieldProvider): DefaultProvider {
333
- return input as unknown as DefaultProvider;
334
- }
335
-
336
- /**
337
- * Metadata associated with a {@link FieldSchema}.
338
- *
339
- * @remarks Specified via {@link FieldProps.metadata}.
340
- *
341
- * @sealed
342
- * @public
343
- */
344
- export interface FieldSchemaMetadata<TCustomMetadata = unknown> {
345
- /**
346
- * User-defined metadata.
347
- */
348
- readonly custom?: TCustomMetadata;
349
-
350
- /**
351
- * The description of the field.
352
- *
353
- * @remarks
354
- *
355
- * If provided, will be used by the system in scenarios where a description of the field is useful.
356
- * E.g., when converting a field schema to {@link https://json-schema.org/ | JSON Schema}, this description will be
357
- * used as the `description` field.
358
- */
359
- readonly description?: string | undefined;
360
- }
361
-
362
- /**
363
- * Metadata associated with a {@link FieldSchema}. Includes fields used by alpha features.
364
- *
365
- * @remarks Specified via {@link FieldProps.metadata}.
366
- *
367
- * @sealed
368
- * @alpha
369
- */
370
- export interface FieldSchemaMetadataAlpha<TCustomMetadata = unknown>
371
- extends FieldSchemaMetadata<TCustomMetadata> {
372
- /**
373
- * The persisted metadata for this schema element.
374
- */
375
- readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
376
- }
377
-
378
- /**
379
- * Package internal construction API.
380
- */
381
- export function createFieldSchema<
382
- Kind extends FieldKind,
383
- Types extends ImplicitAllowedTypes,
384
- TCustomMetadata = unknown,
385
- >(
386
- kind: Kind,
387
- annotatedTypes: Types,
388
- props?: FieldProps<TCustomMetadata>,
389
- ): FieldSchemaAlpha<Kind, Types, TCustomMetadata>;
390
-
391
- /**
392
- * Package internal construction API that supports annotations for allowed types.
393
- */
394
- export function createFieldSchema<
395
- Kind extends FieldKind,
396
- Types extends ImplicitAnnotatedAllowedTypes,
397
- TCustomMetadata = unknown,
398
- >(
399
- kind: Kind,
400
- annotatedTypes: Types,
401
- props?: FieldProps<TCustomMetadata>,
402
- ): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;
403
-
404
- export function createFieldSchema<
405
- Kind extends FieldKind,
406
- Types extends ImplicitAnnotatedAllowedTypes,
407
- TCustomMetadata = unknown,
408
- >(
409
- kind: Kind,
410
- annotatedTypes: Types,
411
- props?: FieldProps<TCustomMetadata>,
412
- ): FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata> {
413
- return createFieldSchemaPrivate(kind, annotatedTypes, props);
414
- }
415
-
416
- /**
417
- * Implementation for {@link createFieldSchema}
418
- */
419
- let createFieldSchemaPrivate: <
420
- Kind extends FieldKind,
421
- Types extends ImplicitAnnotatedAllowedTypes,
422
- TCustomMetadata,
423
- >(
424
- kind: Kind,
425
- annotatedTypes: Types,
426
- props?: FieldProps<TCustomMetadata>,
427
- ) => FieldSchemaAlpha<Kind, UnannotateImplicitAllowedTypes<Types>, TCustomMetadata>;
428
-
429
- /**
430
- * All policy for a specific field,
431
- * including functionality that does not have to be kept consistent across versions or deterministic.
432
- *
433
- * This can include policy for how to use this schema for "view" purposes, and well as how to expose editing APIs.
434
- * Use {@link SchemaFactory} to create the FieldSchema instances, for example {@link SchemaStatics.optional}.
435
- * @privateRemarks
436
- * Public access to the constructor is removed to prevent creating expressible but unsupported (or not stable) configurations.
437
- * {@link createFieldSchema} can be used internally to create instances.
438
- *
439
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
440
- * See {@link FieldSchemaMetadata.custom}.
441
- *
442
- * @remarks
443
- * All implementations of this are actually {@link FieldSchemaAlpha} which exposes some additional alpha APIs.
444
- *
445
- * @sealed @public
446
- */
447
- export class FieldSchema<
448
- out Kind extends FieldKind = FieldKind,
449
- out Types extends ImplicitAllowedTypes = ImplicitAllowedTypes,
450
- out TCustomMetadata = unknown,
451
- > {
452
- /**
453
- * This class is used with instanceof, and therefore should have nominal typing.
454
- * This field enforces that.
455
- */
456
- protected _typeCheck!: MakeNominal;
457
-
458
- private readonly lazyTypes: Lazy<ReadonlySet<TreeNodeSchema>>;
459
-
460
- /**
461
- * What types of tree nodes are allowed in this field.
462
- * @remarks Counterpart to {@link FieldSchema.allowedTypes}, with any lazy definitions evaluated.
463
- */
464
- public get allowedTypeSet(): ReadonlySet<TreeNodeSchema> {
465
- return this.lazyTypes.value;
466
- }
467
-
468
- /**
469
- * True if and only if, when constructing a node with this field, a value must be provided for it.
470
- */
471
- public readonly requiresValue: boolean;
472
-
473
- /**
474
- * {@inheritDoc FieldProps.metadata}
475
- */
476
- public get metadata(): FieldSchemaMetadata<TCustomMetadata> {
477
- return this.props?.metadata ?? {};
478
- }
479
-
480
- /**
481
- * This class is `@sealed`: protected members like this constructor are for internal use only.
482
- * Use {@link SchemaFactory} to create the FieldSchema instances.
483
- */
484
- protected constructor(
485
- /**
486
- * The {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind } of this field.
487
- * Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.
488
- */
489
- public readonly kind: Kind,
490
- /**
491
- * What types of tree nodes are allowed in this field.
492
- */
493
- public readonly allowedTypes: Types,
494
- /**
495
- * Optional properties associated with the field.
496
- */
497
- public readonly props?: FieldProps<TCustomMetadata>,
498
- ) {
499
- if (!(this instanceof FieldSchemaAlpha)) {
500
- throw new UsageError("FieldSchema is @sealed: sub-classing is not allowed.");
501
- }
502
-
503
- this.lazyTypes = new Lazy(() => normalizeAllowedTypes(this.allowedTypes));
504
- // TODO: optional fields should (by default) get a default provider that returns undefined, removing the need to special case them here:
505
- this.requiresValue =
506
- this.props?.defaultProvider === undefined && this.kind !== FieldKind.Optional;
507
- }
508
- }
509
-
510
- /**
511
- * {@link FieldSchema} including alpha APIs (currently {@link SimpleFieldSchema}).
512
- * @remarks
513
- * This class will go away once the alpha APIs are stable and implemented by {@link FieldSchema}.
514
- * @sealed @alpha
515
- */
516
- export class FieldSchemaAlpha<
517
- Kind extends FieldKind = FieldKind,
518
- Types extends ImplicitAllowedTypes = ImplicitAllowedTypes,
519
- TCustomMetadata = unknown,
520
- >
521
- extends FieldSchema<Kind, Types, TCustomMetadata>
522
- implements SimpleFieldSchema
523
- {
524
- private readonly lazyIdentifiers: Lazy<ReadonlySet<string>>;
525
- private readonly lazyAnnotatedTypes: Lazy<NormalizedAnnotatedAllowedTypes>;
526
- private readonly propsAlpha: FieldPropsAlpha<TCustomMetadata> | undefined;
527
-
528
- /**
529
- * Metadata on the types of tree nodes allowed on this field.
530
- */
531
- public readonly allowedTypesMetadata: AllowedTypesMetadata;
532
-
533
- /**
534
- * Persisted metadata for this field schema.
535
- */
536
- public get persistedMetadata(): JsonCompatibleReadOnlyObject | undefined {
537
- return this.propsAlpha?.persistedMetadata;
538
- }
539
-
540
- static {
541
- createFieldSchemaPrivate = <
542
- Kind2 extends FieldKind,
543
- Types2 extends ImplicitAnnotatedAllowedTypes,
544
- TCustomMetadata2,
545
- >(
546
- kind: Kind2,
547
- annotatedAllowedTypes: Types2,
548
- props?: FieldPropsAlpha<TCustomMetadata2>,
549
- ) =>
550
- new FieldSchemaAlpha(
551
- kind,
552
- unannotateImplicitAllowedTypes(annotatedAllowedTypes),
553
- annotatedAllowedTypes,
554
- props,
555
- );
556
- }
557
-
558
- protected constructor(
559
- kind: Kind,
560
- types: Types,
561
- public readonly annotatedAllowedTypes: ImplicitAnnotatedAllowedTypes,
562
- props?: FieldPropsAlpha<TCustomMetadata>,
563
- ) {
564
- super(kind, types, props);
565
-
566
- this.allowedTypesMetadata = isAnnotatedAllowedTypes(annotatedAllowedTypes)
567
- ? annotatedAllowedTypes.metadata
568
- : {};
569
- this.lazyAnnotatedTypes = new Lazy(() =>
570
- normalizeAnnotatedAllowedTypes(annotatedAllowedTypes),
571
- );
572
- this.lazyIdentifiers = new Lazy(
573
- () => new Set([...this.allowedTypeSet].map((t) => t.identifier)),
574
- );
575
- this.propsAlpha = props;
576
- }
577
-
578
- public get allowedTypesIdentifiers(): ReadonlySet<string> {
579
- return this.lazyIdentifiers.value;
580
- }
581
-
582
- /**
583
- * What types of tree nodes are allowed in this field and their annotations.
584
- * @remarks Counterpart to {@link FieldSchemaAlpha.annotatedAllowedTypes}, with any lazy definitions evaluated.
585
- */
586
- public get annotatedAllowedTypesNormalized(): NormalizedAnnotatedAllowedTypes {
587
- return this.lazyAnnotatedTypes.value;
588
- }
589
- }
590
-
591
- /**
592
- * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.
593
- */
594
- export class ObjectFieldSchema<
595
- Kind extends FieldKind = FieldKind,
596
- Types extends ImplicitAllowedTypes = ImplicitAllowedTypes,
597
- TCustomMetadata = unknown,
598
- >
599
- extends FieldSchemaAlpha<Kind, Types, TCustomMetadata>
600
- implements SimpleObjectFieldSchema
601
- {
602
- public readonly storedKey: string;
603
-
604
- public constructor(
605
- kind: Kind,
606
- allowedTypes: Types,
607
- annotatedTypes: ImplicitAnnotatedAllowedTypes,
608
- props: FieldProps<TCustomMetadata> & { readonly key: string },
609
- ) {
610
- super(kind, allowedTypes, annotatedTypes, props);
611
- this.storedKey = props.key;
612
- }
613
- }
614
-
615
- /**
616
- * Normalizes a {@link ImplicitFieldSchema} or {@link ImplicitAnnotatedFieldSchema} to a {@link FieldSchema}.
617
- */
618
- export function normalizeFieldSchema(
619
- schema: ImplicitFieldSchema | ImplicitAnnotatedFieldSchema,
620
- ): FieldSchemaAlpha {
621
- return schema instanceof FieldSchema
622
- ? (schema as FieldSchemaAlpha)
623
- : createFieldSchema(FieldKind.Required, schema);
624
- }
625
-
626
- /**
627
- * Normalizes a {@link ImplicitAllowedTypes} to a set of {@link TreeNodeSchema}s, by eagerly evaluating any
628
- * lazy schema declarations.
629
- *
630
- * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of
631
- * recursive schemas may fail.
632
- *
633
- * @internal
634
- */
635
- export function normalizeAllowedTypes(
636
- types: ImplicitAllowedTypes,
637
- ): ReadonlySet<TreeNodeSchema> {
638
- const normalized = new Set<TreeNodeSchema>();
639
- if (isReadonlyArray(types)) {
640
- // Types array must not be modified after it is normalized since that would result in the user of the normalized data having wrong (out of date) content.
641
- Object.freeze(types);
642
- for (const lazyType of types) {
643
- normalized.add(evaluateLazySchema(lazyType));
644
- }
645
- } else {
646
- normalized.add(evaluateLazySchema(types));
647
- }
648
- return normalized;
649
- }
650
-
651
- /**
652
- * Normalizes an allowed type to an {@link AnnotatedAllowedType}, by adding empty annotations if they don't already exist.
653
- */
654
- export function normalizeToAnnotatedAllowedType<T extends TreeNodeSchema>(
655
- type: T | AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>>,
656
- ): AnnotatedAllowedType<T> | AnnotatedAllowedType<LazyItem<T>> {
657
- return isAnnotatedAllowedType(type)
658
- ? type
659
- : {
660
- metadata: {},
661
- type,
662
- };
663
- }
664
-
665
- /**
666
- * Normalizes a {@link ImplicitAnnotatedAllowedTypes} to a set of {@link AnnotatedAllowedSchema}s, by eagerly evaluating any
667
- * lazy schema declarations and adding empty metadata if it doesn't already exist.
668
- *
669
- * @remarks Note: this must only be called after all required schemas have been declared, otherwise evaluation of
670
- * recursive schemas may fail.
671
- */
672
- export function normalizeAnnotatedAllowedTypes(
673
- types: ImplicitAnnotatedAllowedTypes,
674
- ): NormalizedAnnotatedAllowedTypes {
675
- const typesWithoutAnnotation = isAnnotatedAllowedTypes(types) ? types.types : types;
676
- const annotatedTypes: AnnotatedAllowedType<TreeNodeSchema>[] = [];
677
- if (isReadonlyArray(typesWithoutAnnotation)) {
678
- for (const annotatedType of typesWithoutAnnotation) {
679
- if (isAnnotatedAllowedType(annotatedType)) {
680
- annotatedTypes.push({
681
- type: evaluateLazySchema(annotatedType.type),
682
- metadata: annotatedType.metadata,
683
- });
684
- } else {
685
- annotatedTypes.push({ type: evaluateLazySchema(annotatedType), metadata: {} });
686
- }
687
- }
688
- } else {
689
- if (isAnnotatedAllowedType(typesWithoutAnnotation)) {
690
- annotatedTypes.push({
691
- type: evaluateLazySchema(typesWithoutAnnotation.type),
692
- metadata: typesWithoutAnnotation.metadata,
693
- });
694
- } else {
695
- annotatedTypes.push({ type: evaluateLazySchema(typesWithoutAnnotation), metadata: {} });
696
- }
697
- }
698
-
699
- return {
700
- metadata: isAnnotatedAllowedTypes(types) ? types.metadata : {},
701
- types: annotatedTypes,
702
- };
703
- }
704
-
705
- /**
706
- * Converts an {@link ImplicitAnnotatedAllowedTypes} to an {@link ImplicitAllowedTypes}s, by removing
707
- * any annotations.
708
- * @remarks
709
- * This does not evaluate any lazy schemas.
710
- */
711
- export function unannotateImplicitAllowedTypes<Types extends ImplicitAnnotatedAllowedTypes>(
712
- types: Types,
713
- ): UnannotateImplicitAllowedTypes<Types> {
714
- return (
715
- isAnnotatedAllowedTypes(types)
716
- ? types.types.map((allowedType) =>
717
- isAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType,
718
- )
719
- : isReadonlyArray(types)
720
- ? types.map((allowedType) =>
721
- isAnnotatedAllowedType(allowedType) ? allowedType.type : allowedType,
722
- )
723
- : isAnnotatedAllowedType(types)
724
- ? (types.type as UnannotateImplicitAllowedTypes<Types>)
725
- : types
726
- ) as UnannotateImplicitAllowedTypes<Types>;
727
- }
728
-
729
- /**
730
- * Removes annotations from a schema record.
731
- */
732
- export function unannotateSchemaRecord<
733
- Schema extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,
734
- >(schemaRecord: Schema): UnannotateSchemaRecord<Schema> {
735
- return Object.fromEntries(
736
- Object.entries(schemaRecord).map(([key, schema]) => [
737
- key,
738
- schema instanceof FieldSchema ? schema : unannotateImplicitAllowedTypes(schema),
739
- ]),
740
- ) as UnannotateSchemaRecord<Schema>;
741
- }
742
-
743
- /**
744
- * Returns true if the given {@link ImplicitFieldSchema} are equivalent, otherwise false.
745
- * @remarks Two ImplicitFieldSchema are considered equivalent if all of the following are true:
746
- * 1. They have the same {@link FieldKind | kinds}.
747
- * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.
748
- * 3. They have the same exact set of allowed types. The allowed types must be (respectively) reference equal.
749
- *
750
- * For example, comparing an ImplicitFieldSchema that is a {@link TreeNodeSchema} to an ImplicitFieldSchema that is a {@link FieldSchema}
751
- * will return true if they are the same kind, the FieldSchema has exactly one allowed type (the TreeNodeSchema), and they have equivalent FieldProps.
752
- */
753
- export function areImplicitFieldSchemaEqual(
754
- a: ImplicitFieldSchema,
755
- b: ImplicitFieldSchema,
756
- ): boolean {
757
- return areFieldSchemaEqual(normalizeFieldSchema(a), normalizeFieldSchema(b));
758
- }
759
-
760
- /**
761
- * Returns true if the given {@link FieldSchema} are equivalent, otherwise false.
762
- * @remarks Two FieldSchema are considered equivalent if all of the following are true:
763
- * 1. They have the same {@link FieldKind | kinds}.
764
- * 2. They have {@link areFieldPropsEqual | equivalent FieldProps}.
765
- * 3. They have the same exact set of allowed types. The allowed types must be reference equal.
766
- */
767
- export function areFieldSchemaEqual(a: FieldSchema, b: FieldSchema): boolean {
768
- if (a === b) {
769
- return true;
770
- }
771
-
772
- if (a.kind !== b.kind) {
773
- return false;
774
- }
775
-
776
- if (!areFieldPropsEqual(a.props, b.props)) {
777
- return false;
778
- }
779
-
780
- return compareSets({ a: a.allowedTypeSet, b: b.allowedTypeSet });
781
- }
782
-
783
- /**
784
- * Returns true if the given {@link FieldProps} are equivalent, otherwise false.
785
- * @remarks FieldProps are considered equivalent if their keys and default providers are reference equal, and their metadata are {@link areMetadataEqual | equivalent}.
786
- */
787
- function areFieldPropsEqual(a: FieldProps | undefined, b: FieldProps | undefined): boolean {
788
- // If any new fields are added to FieldProps, this check will stop compiling as a reminder that this function needs to be updated.
789
- type _keys = requireTrue<areOnlyKeys<FieldProps, "key" | "defaultProvider" | "metadata">>;
790
-
791
- if (a === b) {
792
- return true;
793
- }
794
-
795
- if (a?.key !== b?.key || a?.defaultProvider !== b?.defaultProvider) {
796
- return false;
797
- }
798
-
799
- if (!areMetadataEqual(a?.metadata, b?.metadata)) {
800
- return false;
801
- }
802
-
803
- return true;
804
- }
805
-
806
- /**
807
- * Returns true if the given {@link FieldSchemaMetadata} are equivalent, otherwise false.
808
- * @remarks FieldSchemaMetadata are considered equivalent if their custom data and descriptions are (respectively) reference equal.
809
- */
810
- function areMetadataEqual(
811
- a: FieldSchemaMetadataAlpha | undefined,
812
- b: FieldSchemaMetadataAlpha | undefined,
813
- ): boolean {
814
- // If any new fields are added to FieldSchemaMetadata, this check will stop compiling as a reminder that this function needs to be updated.
815
- type _keys = requireTrue<
816
- areOnlyKeys<FieldSchemaMetadataAlpha, "custom" | "description" | "persistedMetadata">
817
- >;
818
-
819
- if (a === b) {
820
- return true;
821
- }
822
-
823
- return (
824
- Object.is(a?.custom, b?.custom) &&
825
- a?.description === b?.description &&
826
- arePersistedMetadataEqual(a?.persistedMetadata, b?.persistedMetadata)
827
- );
828
- }
829
-
830
- /**
831
- * Returns true if the given persisted metadata fields are equivalent, otherwise false.
832
- * @remarks
833
- * Currently only handles shallow equality in the case where the keys are in the same order. This is acceptable for current use cases.
834
- */
835
- function arePersistedMetadataEqual(
836
- a: JsonCompatibleReadOnlyObject | undefined,
837
- b: JsonCompatibleReadOnlyObject | undefined,
838
- ): boolean {
839
- if (Object.is(a, b)) {
840
- return true;
841
- }
842
-
843
- if (a === undefined || b === undefined) {
844
- return false;
845
- }
846
-
847
- // Note that the key order matters. If `a` and `b` have the same content but the keys are in a different order,
848
- // this method will return false.
849
- const aStringified = JSON.stringify(a);
850
- const bStringified = JSON.stringify(b);
851
-
852
- return aStringified === bStringified;
853
- }
854
-
855
- const cachedLazyItem = new WeakMap<() => unknown, unknown>();
856
-
857
- /**
858
- * Returns the schema referenced by the {@link LazyItem}.
859
- * @remarks
860
- * Caches results to handle {@link LazyItem}s which compute their resulting schema.
861
- * @alpha
862
- */
863
- export function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T {
864
- const evaluatedSchema = isLazy(value)
865
- ? (getOrCreate(cachedLazyItem, value, value) as T)
866
- : value;
867
- if (evaluatedSchema === undefined) {
868
- throw new UsageError(
869
- `Encountered an undefined schema. This could indicate that some referenced schema has not yet been instantiated.`,
870
- );
871
- }
872
- markSchemaMostDerived(evaluatedSchema);
873
- return evaluatedSchema;
874
- }
875
-
876
- /**
877
- * Indicates that the provided schema is the "most derived" version in its class hierarchy.
878
- *
879
- * @param oneTimeInitialize - If true this runs {@link TreeNodeValid.oneTimeInitialize} which does even more initialization and validation.
880
- * `oneTimeInitialize` can't safely be run until all transitively referenced schema are defined, so which cases can safely use it are more limited.
881
- * When legal for the caller to set this to true, it is preferred, but it is often not safe due to possible forward references.
882
- * @remarks
883
- * See {@link MostDerivedData} and {@link SchemaFactory} for details on what a "most derived" schema is and why it matters.
884
- *
885
- * This is a helper for invoking {@link TreeNodeValid.markMostDerived} for {@link TreeNodeSchema}.
886
- *
887
- * Calling this helps with error messages about invalid schema usage (See {@link SchemaFactory} for the rules, some of which this helps validate).
888
- * Typically this should be called for each schema as early as practical to improve error reporting for invalid usages of schema
889
- * (using two different schema derived from the same {@link SchemaFactory} produced base class).
890
- *
891
- * Note that construction of actual {@link TreeNode} instances or use of a schema transitively in a {@link TreeViewConfiguration} already do this,
892
- * so any calls to this that is unconditionally after that point for the given schema is not needed.
893
- * Instead most usages of this should be from those cases, and from miscellaneous cases where a schema is passed into an public API where theoretically someone could accidentally
894
- * pass in a base class of a schema instead of the most derived one.
895
- */
896
- export function markSchemaMostDerived(
897
- schema: TreeNodeSchema,
898
- oneTimeInitialize = false,
899
- ): void {
900
- if (schema instanceof LeafNodeSchema) {
901
- return;
902
- }
903
-
904
- if (!inPrototypeChain(schema, TreeNodeValid)) {
905
- // Use JSON.stringify to quote and escape identifier string.
906
- throw new UsageError(
907
- `Schema for ${JSON.stringify(
908
- schema.identifier,
909
- )} does not extend a SchemaFactory generated class. This is invalid.`,
910
- );
911
- }
912
-
913
- const schemaValid = schema as typeof TreeNodeValid & TreeNodeSchema;
914
- if (oneTimeInitialize) {
915
- schemaValid.oneTimeInitialize();
916
- } else {
917
- schemaValid.markMostDerived();
918
- }
919
- }
920
-
921
- /**
922
- * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree.
923
- * @remarks
924
- * Used by {@link TreeViewConfiguration} for the root and various kinds of {@link TreeNodeSchema} to specify their allowed child types.
925
- *
926
- * Use {@link SchemaFactory} to access leaf schema or declare new composite schema.
927
- *
928
- * Implicitly treats a single type as an array of one type.
929
- *
930
- * Arrays of schema can be used to specify multiple types are allowed, which result in unions of those types in the Tree APIs.
931
- *
932
- * When saved into variables, avoid type-erasing the details, as doing so loses the compile time schema awareness of APIs derived from the types.
933
- *
934
- * When referring to types that are declared after the definition of the `ImplicitAllowedTypes`, the schema can be wrapped in a lambda to allow the forward reference.
935
- * See {@link ValidateRecursiveSchema} for details on how to structure the `ImplicitAllowedTypes` instances when constructing recursive schema.
936
- *
937
- * @example Explicit use with strong typing
938
- * ```typescript
939
- * const sf = new SchemaFactory("myScope");
940
- * const childTypes = [sf.number, sf.string] as const satisfies ImplicitAllowedTypes;
941
- * const config = new TreeViewConfiguration({ schema: childTypes });
942
- * ```
943
- *
944
- * @example Forward reference
945
- * ```typescript
946
- * const sf = new SchemaFactory("myScope");
947
- * class A extends sf.array("example", [() => B]) {}
948
- * class B extends sf.array("Inner", sf.number) {}
949
- * ```
950
- * @privateRemarks
951
- * Code reading data from this should use `normalizeAllowedTypes` to ensure consistent handling, caching, nice errors etc.
952
- * @public
953
- */
954
- export type ImplicitAllowedTypes = AllowedTypes | TreeNodeSchema;
955
-
956
- /**
957
- * Types of {@link TreeNode|TreeNodes} or {@link TreeLeafValue|TreeLeafValues} allowed at a location in a tree with
958
- * additional metadata associated with the location they're allowed at.
959
- * @alpha
960
- */
961
- export type ImplicitAnnotatedAllowedTypes =
962
- | TreeNodeSchema
963
- | AnnotatedAllowedType
964
- | AnnotatedAllowedTypes
965
- | readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[];
966
-
967
- /**
968
- * Returns an {@link ImplicitAllowedTypes} that is equivalent to the input without annotations.
969
- * @system @alpha
970
- */
971
- export type UnannotateImplicitAllowedTypes<T extends ImplicitAnnotatedAllowedTypes> =
972
- T extends AnnotatedAllowedTypes
973
- ? UnannotateAllowedTypes<T>
974
- : T extends AnnotatedAllowedType
975
- ? UnannotateAllowedType<T>
976
- : T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[]
977
- ? UnannotateAllowedTypesList<T>
978
- : T extends TreeNodeSchema
979
- ? T
980
- : never;
981
-
982
- /**
983
- * Removes annotations from a list of allowed types that may contain annotations.
984
- * @system @alpha
985
- */
986
- export type UnannotateAllowedTypesList<
987
- T extends readonly (AnnotatedAllowedType | LazyItem<TreeNodeSchema>)[],
988
- > = {
989
- [I in keyof T]: UnannotateAllowedTypeOrLazyItem<T[I]>;
990
- };
991
-
992
- /**
993
- * Removes annotations from an allowed type that may contain annotations.
994
- * @system @alpha
995
- */
996
- export type UnannotateAllowedTypeOrLazyItem<
997
- T extends AnnotatedAllowedType | LazyItem<TreeNodeSchema>,
998
- > = T extends AnnotatedAllowedType<infer X> ? X : T;
999
-
1000
- /**
1001
- * Removes all annotations from a set of allowed types.
1002
- * @system @alpha
1003
- */
1004
- export type UnannotateAllowedTypes<T extends AnnotatedAllowedTypes> =
1005
- UnannotateAllowedTypesList<T["types"]>;
1006
-
1007
- /**
1008
- * Removes annotations from an allowed type.
1009
- * @system @alpha
1010
- */
1011
- export type UnannotateAllowedType<T extends AnnotatedAllowedType> =
1012
- T extends AnnotatedAllowedType<infer X> ? [X] : T;
1013
-
1014
- /**
1015
- * Schema for a field of a tree node.
1016
- * @remarks
1017
- * Implicitly treats {@link ImplicitAllowedTypes} as a Required field of that type.
1018
- * @public
1019
- */
1020
- export type ImplicitFieldSchema = FieldSchema | ImplicitAllowedTypes;
1021
-
1022
- /**
1023
- * Annotated schema for a field of a tree node.
1024
- * @alpha
1025
- */
1026
- export type ImplicitAnnotatedFieldSchema = FieldSchema | ImplicitAnnotatedAllowedTypes;
1027
-
1028
- /**
1029
- * Removes annotations from an annotated field schema.
1030
- * @system @alpha
1031
- */
1032
- export type UnannotateImplicitFieldSchema<T extends ImplicitAnnotatedFieldSchema> =
1033
- T extends ImplicitAnnotatedAllowedTypes ? UnannotateImplicitAllowedTypes<T> : T;
1034
-
1035
- /**
1036
- * Removes annotations from field schemas in a schema record.
1037
- * @system @alpha
1038
- */
1039
- export type UnannotateSchemaRecord<
1040
- T extends RestrictiveStringRecord<ImplicitAnnotatedFieldSchema>,
1041
- > = {
1042
- readonly [P in Extract<keyof T, string>]: UnannotateImplicitFieldSchema<T[P]>;
1043
- };
1044
-
1045
- /**
1046
- * Converts an `ImplicitFieldSchema` to a property type suitable for reading a field with this that schema.
1047
- *
1048
- * @typeparam TSchema - When non-exact schema are provided this errors on the side of returning too general of a type (a conservative union of all possibilities).
1049
- * This is ideal for "output APIs" - i.e. it converts the schema type to the runtime type that a user will _read_ from the tree.
1050
- * Examples of such "non-exact" schema include `ImplicitFieldSchema`, `ImplicitAllowedTypes`, and TypeScript unions of schema types.
1051
- * @public
1052
- */
1053
- export type TreeFieldFromImplicitField<TSchema extends ImplicitFieldSchema = FieldSchema> =
1054
- TSchema extends FieldSchema<infer Kind, infer Types>
1055
- ? ApplyKind<TreeNodeFromImplicitAllowedTypes<Types>, Kind>
1056
- : TSchema extends ImplicitAllowedTypes
1057
- ? TreeNodeFromImplicitAllowedTypes<TSchema>
1058
- : TreeNode | TreeLeafValue | undefined;
1059
-
1060
- /**
1061
- * Type of content that can be inserted into the tree for a field of the given schema.
1062
- *
1063
- * @see {@link Input}
1064
- *
1065
- * @typeparam TSchemaInput - Schema to process.
1066
- * @typeparam TSchema - Do not specify: default value used as implementation detail.
1067
- * @public
1068
- */
1069
- export type InsertableTreeFieldFromImplicitField<
1070
- TSchemaInput extends ImplicitFieldSchema,
1071
- TSchema = UnionToIntersection<TSchemaInput>,
1072
- > = [TSchema] extends [FieldSchema<infer Kind, infer Types>]
1073
- ? ApplyKindInput<InsertableTreeNodeFromImplicitAllowedTypes<Types>, Kind, true>
1074
- : [TSchema] extends [ImplicitAllowedTypes]
1075
- ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>
1076
- : never;
1077
-
1078
- /**
1079
- * {@inheritdoc (UnsafeUnknownSchema:type)}
1080
- * @alpha
1081
- */
1082
- export const UnsafeUnknownSchema: unique symbol = Symbol("UnsafeUnknownSchema");
1083
-
1084
- /**
1085
- * A special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.
1086
- * @remarks
1087
- * When used, this means the TypeScript typing should err on the side of completeness (allow all inputs that could be valid).
1088
- * This introduces the risk that out-of-schema data could be allowed at compile time, and only error at runtime.
1089
- *
1090
- * @privateRemarks
1091
- * This only applies to APIs which input data which is expected to be in schema, since APIs outputting have easy mechanisms to do so in a type safe way even when the schema is unknown.
1092
- * In most cases that amounts to returning `TreeNode | TreeLeafValue`.
1093
- *
1094
- * This can be contrasted with the default behavior of TypeScript, which is to require the intersection of the possible types for input APIs,
1095
- * which for unknown schema defining input trees results in the `never` type.
1096
- *
1097
- * Any APIs which use this must produce UsageErrors when out of schema data is encountered, and never produce unrecoverable errors,
1098
- * or silently accept invalid data.
1099
- * This is currently only type exported from the package: the symbol is just used as a way to get a named type.
1100
- * @alpha
1101
- */
1102
- export type UnsafeUnknownSchema = typeof UnsafeUnknownSchema;
1103
-
1104
- /**
1105
- * Content which could be inserted into a tree.
1106
- *
1107
- * @see {@link Input}
1108
- * @remarks
1109
- * Extended version of {@link InsertableTreeNodeFromImplicitAllowedTypes} that also allows {@link (UnsafeUnknownSchema:type)}.
1110
- * @alpha
1111
- */
1112
- export type Insertable<TSchema extends ImplicitAllowedTypes | UnsafeUnknownSchema> =
1113
- TSchema extends ImplicitAllowedTypes
1114
- ? InsertableTreeNodeFromImplicitAllowedTypes<TSchema>
1115
- : InsertableContent;
1116
-
1117
- /**
1118
- * Content which could be inserted into a field within a tree.
1119
- *
1120
- * @see {@link Input}
1121
- * @remarks
1122
- * Extended version of {@link InsertableTreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.
1123
- * @alpha
1124
- */
1125
- export type InsertableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [
1126
- TSchema,
1127
- ] extends [ImplicitFieldSchema]
1128
- ? InsertableTreeFieldFromImplicitField<TSchema>
1129
- : [TSchema] extends [UnsafeUnknownSchema]
1130
- ? InsertableContent | undefined
1131
- : never;
1132
-
1133
- /**
1134
- * Content which could be read from a field within a tree.
1135
- *
1136
- * @remarks
1137
- * Extended version of {@link TreeFieldFromImplicitField} that also allows {@link (UnsafeUnknownSchema:type)}.
1138
- * Since reading from fields with non-exact schema is still safe, this is only useful (compared to {@link TreeFieldFromImplicitField}) when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}
1139
- * for use
1140
- * @system @alpha
1141
- */
1142
- export type ReadableField<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> =
1143
- TreeFieldFromImplicitField<ReadSchema<TSchema>>;
1144
-
1145
- /**
1146
- * Adapter to remove {@link (UnsafeUnknownSchema:type)} from a schema type so it can be used with types for generating APIs for reading data.
1147
- *
1148
- * @remarks
1149
- * Since reading with non-exact schema is still safe, this is mainly useful when the schema is also used as input and thus allows {@link (UnsafeUnknownSchema:type)}.
1150
- * @system @alpha
1151
- */
1152
- export type ReadSchema<TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema> = [
1153
- TSchema,
1154
- ] extends [ImplicitFieldSchema]
1155
- ? TSchema
1156
- : ImplicitFieldSchema;
1157
-
1158
- /**
1159
- * Suitable for output.
1160
- * For input must error on side of excluding undefined instead.
1161
- * @system @public
1162
- */
1163
- export type ApplyKind<T, Kind extends FieldKind> = {
1164
- [FieldKind.Required]: T;
1165
- [FieldKind.Optional]: T | undefined;
1166
- [FieldKind.Identifier]: T;
1167
- }[Kind];
1168
-
1169
- /**
1170
- * Suitable for input.
1171
- *
1172
- * @see {@link Input}
1173
- * @system @public
1174
- */
1175
- export type ApplyKindInput<T, Kind extends FieldKind, DefaultsAreOptional extends boolean> = [
1176
- Kind,
1177
- ] extends [FieldKind.Required]
1178
- ? T
1179
- : [Kind] extends [FieldKind.Optional]
1180
- ? T | undefined
1181
- : [Kind] extends [FieldKind.Identifier]
1182
- ? DefaultsAreOptional extends true
1183
- ? T | undefined
1184
- : T
1185
- : never;
1186
-
1187
- /**
1188
- * Type of tree node for a field of the given schema.
1189
- * @public
1190
- */
1191
- export type TreeNodeFromImplicitAllowedTypes<
1192
- TSchema extends ImplicitAllowedTypes = TreeNodeSchema,
1193
- > = TSchema extends TreeNodeSchema
1194
- ? NodeFromSchema<TSchema>
1195
- : TSchema extends AllowedTypes
1196
- ? NodeFromSchema<FlexListToUnion<TSchema>>
1197
- : unknown;
1198
-
1199
- /**
1200
- * This type exists only to be linked from documentation to provide a single linkable place to document some details of
1201
- * "Input" types and how they handle schema.
1202
- *
1203
- * When a schema is used to describe data which is an input into an API, the API is [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) over the schema.
1204
- * (See also, [TypeScript Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations)).
1205
- *
1206
- * Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.
1207
- *
1208
- * Consider a field with schema type of `A | B` (where A and B are types of schema).
1209
- *
1210
- * - Reading the field behaves covariantly so {@link NodeFromSchema} of `<A | B>` is the same as `NodeFromSchema<A> | NodeFromSchema<B>`, indicating that either type of node can be read from the field.
1211
- *
1212
- * - Writing to the field behaves contravariantly. Since it is unknown if the node actually has a schema `A` or a schema `B`, the only legal values (known to be in schema regardless of which schema the underlying node has) are values which are legal for both `A & B`.
1213
- *
1214
- * Note that this is distinct from the case where the schema is `[A, B]`.
1215
- * In this case it is known that the field allows both A and B (the field can be set to an A or a B value).
1216
- * When `A | B` is used, the field might allow
1217
- * A but not B (so assigning a B value would be out of schema),
1218
- * B but not A (so assigning an A value would be out of schema)
1219
- * or both A and B.
1220
- *
1221
- * This gets more extreme when given completely unspecified schema.
1222
- * For example if a field is just provided {@link ImplicitFieldSchema}, nothing is known about the content of the field.
1223
- * This means that reading the field (via {@link TreeFieldFromImplicitField}) can give any valid tree field content,
1224
- * but there are no safe values which could be written to the field (since it is unknown what values would be out of schema) so {@link InsertableTreeFieldFromImplicitField} gives `never`.
1225
- *
1226
- * To implement this variance correctly, the computation of types for input and output have to use separate utilities
1227
- * which take very different approaches when encountering non-exact schema like unions or `ImplicitFieldSchema`.
1228
- * The utilities which behave contravariantly (as required to handle input correctly) link this documentation to indicate that this is how they behave.
1229
- *
1230
- * In addition to behaving contravariantly, these input type computation utilities often have further limitations.
1231
- * This is due to TypeScript making it difficult to implement this contravariance exactly.
1232
- * When faced with these implementation limitations these contravariant type computation utilities error on the side of producing overly strict requirements.
1233
- * For example in the above case of `A | B`, the utilities might compute an allowed insertable type as `never` even if there happens to be a common value accepted by both `A` and `B`.
1234
- * Future versions of the API can relax these requirements as the type computations are made more accurate.
1235
- *
1236
- * For a more concrete example: if {@link InsertableTreeFieldFromImplicitField} produced `never` for a schema `A | OptionalField<A>`,
1237
- * a future version could instead return a more flexible but still safe type, like `A`.
1238
- *
1239
- * More generally: try to avoid providing non-exact schema, especially for the fields of other schema.
1240
- * While these APIs attempt to handle such cases correctly, there are limitations and known bugs in this handling.
1241
- * Code using non-exact schema is much more likely to have its compilation break due to updates of this package or even TypeScript,
1242
- * and thus compilation breaks due to edge cases of non-exact schema handling, especially with recursive schema, are not considered breaking changes.
1243
- * This may change as the API become more stable.
1244
- *
1245
- * @privateRemarks
1246
- * There likely is a better way to share this documentation, but none was found at the time of writing.
1247
- *
1248
- * TODO: Once {@link InsertableField} is public, consider using it in the examples above.
1249
- * @system @public
1250
- */
1251
- export type Input<T extends never> = T;
1252
-
1253
- /**
1254
- * Type of content that can be inserted into the tree for a node of the given schema.
1255
- *
1256
- * @see {@link Input}
1257
- *
1258
- * @typeparam TSchema - Schema to process.
1259
- *
1260
- * @privateRemarks
1261
- * This is a bit overly conservative, since cases like `A | [A]` give never and could give `A`.
1262
- * @public
1263
- */
1264
- export type InsertableTreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes> =
1265
- [TSchema] extends [TreeNodeSchema]
1266
- ? InsertableTypedNode<TSchema>
1267
- : [TSchema] extends [AllowedTypes]
1268
- ? InsertableTreeNodeFromAllowedTypes<TSchema>
1269
- : never;
1270
-
1271
- /**
1272
- * Type of content that can be inserted into the tree for a node of the given schema.
1273
- *
1274
- * @see {@link Input}
1275
- *
1276
- * @typeparam TList - AllowedTypes to process
1277
- *
1278
- * @privateRemarks
1279
- * This loop is manually unrolled to allow larger unions before hitting the recursion limit in TypeScript.
1280
- * @system @public
1281
- */
1282
- export type InsertableTreeNodeFromAllowedTypes<TList extends AllowedTypes> =
1283
- IsUnion<TList> extends true
1284
- ? never
1285
- : {
1286
- readonly [Property in keyof TList]: TList[Property] extends LazyItem<
1287
- infer TSchema extends TreeNodeSchema
1288
- >
1289
- ? InsertableTypedNode<TSchema>
1290
- : never;
1291
- }[number];
1292
-
1293
- /**
1294
- * Takes in `TreeNodeSchema[]` and returns a TypedNode union.
1295
- * @privateRemarks
1296
- * If a schema is both TreeNodeSchemaClass and TreeNodeSchemaNonClass, prefer TreeNodeSchemaClass since that includes subclasses properly.
1297
- * @public
1298
- */
1299
- export type NodeFromSchema<T extends TreeNodeSchema> = T extends TreeNodeSchemaClass<
1300
- string,
1301
- NodeKind,
1302
- infer TNode
1303
- >
1304
- ? TNode
1305
- : T extends TreeNodeSchemaNonClass<string, NodeKind, infer TNode>
1306
- ? TNode
1307
- : never;
1308
-
1309
- /**
1310
- * Data which can be used as a node to be inserted.
1311
- * Either an unhydrated node, or content to build a new node.
1312
- *
1313
- * @see {@link Input}
1314
- *
1315
- * @typeparam TSchemaInput - Schema to process.
1316
- * @typeparam T - Do not specify: default value used as implementation detail.
1317
- * @privateRemarks
1318
- * This can't really be fully correct, since TreeNodeSchema's TNode is generally use covariantly but this code uses it contravariantly.
1319
- * That makes this TreeNodeSchema actually invariant with respect to TNode, but doing that would break all `extends TreeNodeSchema` clauses.
1320
- * As is, this works correctly in most realistic use-cases.
1321
- *
1322
- * One special case this makes is if the result of NodeFromSchema contains TreeNode, this must be an under constrained schema, so the result is set to never.
1323
- * Note that applying UnionToIntersection on the result of NodeFromSchema<T> does not work since it breaks booleans.
1324
- *
1325
- * @public
1326
- */
1327
- export type InsertableTypedNode<
1328
- TSchema extends TreeNodeSchema,
1329
- T = UnionToIntersection<TSchema>,
1330
- > =
1331
- | (T extends TreeNodeSchema<string, NodeKind, TreeNode | TreeLeafValue, never, true>
1332
- ? NodeBuilderData<T>
1333
- : never)
1334
- | (T extends TreeNodeSchema
1335
- ? Unhydrated<TreeNode extends NodeFromSchema<T> ? never : NodeFromSchema<T>>
1336
- : never);
1337
-
1338
- /**
1339
- * Given a node's schema, return the corresponding object from which the node could be built.
1340
- * @privateRemarks
1341
- * This uses TreeNodeSchemaCore, and thus depends on TreeNodeSchemaCore.createFromInsertable for the typing.
1342
- * This works almost the same as using TreeNodeSchema,
1343
- * except that the more complex typing in TreeNodeSchema case breaks for non-class schema and leaks in `undefined` from optional crete parameters.
1344
- * @system @public
1345
- */
1346
- export type NodeBuilderData<T extends TreeNodeSchemaCore<string, NodeKind, boolean>> =
1347
- T extends TreeNodeSchemaCore<string, NodeKind, boolean, unknown, infer TBuild>
1348
- ? TBuild
1349
- : never;
1350
-
1351
- /**
1352
- * Value that may be stored as a leaf node.
1353
- * @remarks
1354
- * Some limitations apply, see the documentation for {@link SchemaStatics.number} and {@link SchemaStatics.string} for those restrictions.
1355
- * @public
1356
- */
1357
- // eslint-disable-next-line @rushstack/no-new-null
1358
- export type TreeLeafValue = number | string | boolean | IFluidHandle | null;
1359
-
1360
- /**
1361
- * Additional information to provide to Node Schema creation.
1362
- *
1363
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the Node Schema.
1364
- * See {@link NodeSchemaMetadata.custom}.
1365
- *
1366
- * @sealed
1367
- * @public
1368
- */
1369
- export interface NodeSchemaOptions<out TCustomMetadata = unknown> {
1370
- /**
1371
- * Optional metadata to associate with the Node Schema.
1372
- *
1373
- * @remarks
1374
- * Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local.
1375
- * Different clients in the same collaborative session may see different metadata for the same field.
1376
- */
1377
- readonly metadata?: NodeSchemaMetadata<TCustomMetadata> | undefined;
1378
- }
1379
-
1380
- /**
1381
- * Additional information to provide to Node Schema creation. Includes fields for alpha features.
1382
- *
1383
- * @typeParam TCustomMetadata - Custom metadata properties to associate with the Node Schema.
1384
- * See {@link NodeSchemaMetadata.custom}.
1385
- *
1386
- * @alpha
1387
- */
1388
- export interface NodeSchemaOptionsAlpha<out TCustomMetadata = unknown>
1389
- extends NodeSchemaOptions<TCustomMetadata> {
1390
- /**
1391
- * The persisted metadata for this schema element.
1392
- */
1393
- readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
1394
- }
1395
-
1396
- /**
1397
- * Metadata associated with a Node Schema.
1398
- *
1399
- * @remarks Specified via {@link NodeSchemaOptions.metadata}.
1400
- *
1401
- * @sealed
1402
- * @public
1403
- */
1404
- export interface NodeSchemaMetadata<out TCustomMetadata = unknown> {
1405
- /**
1406
- * User-defined metadata.
1407
- */
1408
- readonly custom?: TCustomMetadata | undefined;
1409
-
1410
- /**
1411
- * The description of the Node Schema.
1412
- *
1413
- * @remarks
1414
- *
1415
- * If provided, will be used by the system in scenarios where a description of the kind of node is useful.
1416
- * E.g., when converting a Node Schema to {@link https://json-schema.org/ | JSON Schema}, this description will be
1417
- * used as the `description` property.
1418
- */
1419
- readonly description?: string | undefined;
1420
- }