@fluidframework/tree 2.31.1 → 2.33.0-333010

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 (280) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/CHANGELOG.md +44 -0
  3. package/api-extractor/api-extractor.current.json +5 -1
  4. package/api-report/tree.alpha.api.md +44 -20
  5. package/dist/alpha.d.ts +6 -2
  6. package/dist/feature-libraries/flex-tree/context.d.ts +6 -1
  7. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  8. package/dist/feature-libraries/flex-tree/context.js +5 -2
  9. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  10. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  11. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  12. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  13. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  14. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  15. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  16. package/dist/feature-libraries/flex-tree/index.js +1 -2
  17. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  18. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  19. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  20. package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -18
  21. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  22. package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  23. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  24. package/dist/feature-libraries/flex-tree/lazyField.js +14 -14
  25. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  26. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  27. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  28. package/dist/feature-libraries/flex-tree/lazyNode.js +12 -12
  29. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  30. package/dist/feature-libraries/index.d.ts +1 -1
  31. package/dist/feature-libraries/index.d.ts.map +1 -1
  32. package/dist/feature-libraries/index.js +1 -2
  33. package/dist/feature-libraries/index.js.map +1 -1
  34. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  35. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  36. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  37. package/dist/index.d.ts +2 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +5 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.d.ts.map +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  46. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  47. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  48. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  49. package/dist/shared-tree/sharedTree.js +2 -2
  50. package/dist/shared-tree/sharedTree.js.map +1 -1
  51. package/dist/shared-tree/treeApiAlpha.d.ts +6 -6
  52. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  53. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  54. package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -6
  55. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  56. package/dist/shared-tree-core/sharedTreeCore.js +0 -17
  57. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  58. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  59. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  60. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  61. package/dist/simple-tree/api/customTree.d.ts +14 -12
  62. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  63. package/dist/simple-tree/api/customTree.js.map +1 -1
  64. package/dist/simple-tree/api/getJsonSchema.d.ts +21 -7
  65. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  66. package/dist/simple-tree/api/getJsonSchema.js +8 -16
  67. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  68. package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -10
  69. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  70. package/dist/simple-tree/api/getSimpleSchema.js +4 -16
  71. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  72. package/dist/simple-tree/api/index.d.ts +4 -3
  73. package/dist/simple-tree/api/index.d.ts.map +1 -1
  74. package/dist/simple-tree/api/index.js +2 -1
  75. package/dist/simple-tree/api/index.js.map +1 -1
  76. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  77. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  78. package/dist/simple-tree/api/schemaFactoryAlpha.js +4 -0
  79. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  80. package/dist/simple-tree/api/schemaFromSimple.d.ts +5 -2
  81. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  82. package/dist/simple-tree/api/schemaFromSimple.js +24 -8
  83. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  84. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  85. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  86. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +40 -28
  87. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  88. package/dist/simple-tree/api/tree.d.ts +32 -5
  89. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  90. package/dist/simple-tree/api/tree.js +17 -1
  91. package/dist/simple-tree/api/tree.js.map +1 -1
  92. package/dist/simple-tree/api/verboseTree.d.ts +4 -28
  93. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  94. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  95. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  96. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  97. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  98. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  99. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  100. package/dist/simple-tree/core/treeNodeKernel.js +46 -30
  101. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  102. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  103. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  104. package/dist/simple-tree/core/unhydratedFlexTree.js +15 -1
  105. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  106. package/dist/simple-tree/index.d.ts +1 -1
  107. package/dist/simple-tree/index.d.ts.map +1 -1
  108. package/dist/simple-tree/index.js +3 -2
  109. package/dist/simple-tree/index.js.map +1 -1
  110. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  111. package/dist/simple-tree/objectNode.js +3 -0
  112. package/dist/simple-tree/objectNode.js.map +1 -1
  113. package/dist/simple-tree/simpleSchema.d.ts +4 -11
  114. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  115. package/dist/simple-tree/simpleSchema.js.map +1 -1
  116. package/dist/tableSchema.d.ts +241 -0
  117. package/dist/tableSchema.d.ts.map +1 -0
  118. package/dist/tableSchema.js +238 -0
  119. package/dist/tableSchema.js.map +1 -0
  120. package/dist/treeFactory.d.ts +4 -4
  121. package/dist/treeFactory.d.ts.map +1 -1
  122. package/dist/treeFactory.js.map +1 -1
  123. package/dist/util/breakable.d.ts.map +1 -1
  124. package/dist/util/breakable.js +9 -7
  125. package/dist/util/breakable.js.map +1 -1
  126. package/lib/alpha.d.ts +6 -2
  127. package/lib/feature-libraries/flex-tree/context.d.ts +6 -1
  128. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  129. package/lib/feature-libraries/flex-tree/context.js +6 -3
  130. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  131. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  132. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  133. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  134. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  135. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  136. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  137. package/lib/feature-libraries/flex-tree/index.js +1 -1
  138. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  139. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  140. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  141. package/lib/feature-libraries/flex-tree/lazyEntity.js +8 -17
  142. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  143. package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  144. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  145. package/lib/feature-libraries/flex-tree/lazyField.js +15 -15
  146. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  147. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  148. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  149. package/lib/feature-libraries/flex-tree/lazyNode.js +13 -13
  150. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  151. package/lib/feature-libraries/index.d.ts +1 -1
  152. package/lib/feature-libraries/index.d.ts.map +1 -1
  153. package/lib/feature-libraries/index.js +1 -1
  154. package/lib/feature-libraries/index.js.map +1 -1
  155. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  156. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  157. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  158. package/lib/index.d.ts +2 -1
  159. package/lib/index.d.ts.map +1 -1
  160. package/lib/index.js +2 -1
  161. package/lib/index.js.map +1 -1
  162. package/lib/packageVersion.d.ts +1 -1
  163. package/lib/packageVersion.d.ts.map +1 -1
  164. package/lib/packageVersion.js +1 -1
  165. package/lib/packageVersion.js.map +1 -1
  166. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  167. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  168. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  169. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  170. package/lib/shared-tree/sharedTree.js +2 -2
  171. package/lib/shared-tree/sharedTree.js.map +1 -1
  172. package/lib/shared-tree/treeApiAlpha.d.ts +6 -6
  173. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  174. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  175. package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -6
  176. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  177. package/lib/shared-tree-core/sharedTreeCore.js +0 -17
  178. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  179. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  180. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  181. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  182. package/lib/simple-tree/api/customTree.d.ts +14 -12
  183. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  184. package/lib/simple-tree/api/customTree.js.map +1 -1
  185. package/lib/simple-tree/api/getJsonSchema.d.ts +21 -7
  186. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  187. package/lib/simple-tree/api/getJsonSchema.js +8 -16
  188. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  189. package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -10
  190. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  191. package/lib/simple-tree/api/getSimpleSchema.js +4 -16
  192. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  193. package/lib/simple-tree/api/index.d.ts +4 -3
  194. package/lib/simple-tree/api/index.d.ts.map +1 -1
  195. package/lib/simple-tree/api/index.js +1 -1
  196. package/lib/simple-tree/api/index.js.map +1 -1
  197. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  198. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  199. package/lib/simple-tree/api/schemaFactoryAlpha.js +4 -0
  200. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  201. package/lib/simple-tree/api/schemaFromSimple.d.ts +5 -2
  202. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  203. package/lib/simple-tree/api/schemaFromSimple.js +24 -8
  204. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  205. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  206. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  207. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +41 -29
  208. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  209. package/lib/simple-tree/api/tree.d.ts +32 -5
  210. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  211. package/lib/simple-tree/api/tree.js +16 -1
  212. package/lib/simple-tree/api/tree.js.map +1 -1
  213. package/lib/simple-tree/api/verboseTree.d.ts +4 -28
  214. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  215. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  216. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  217. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  218. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  219. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  220. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  221. package/lib/simple-tree/core/treeNodeKernel.js +48 -32
  222. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  223. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  224. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  225. package/lib/simple-tree/core/unhydratedFlexTree.js +15 -1
  226. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  227. package/lib/simple-tree/index.d.ts +1 -1
  228. package/lib/simple-tree/index.d.ts.map +1 -1
  229. package/lib/simple-tree/index.js +1 -1
  230. package/lib/simple-tree/index.js.map +1 -1
  231. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  232. package/lib/simple-tree/objectNode.js +4 -1
  233. package/lib/simple-tree/objectNode.js.map +1 -1
  234. package/lib/simple-tree/simpleSchema.d.ts +4 -11
  235. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  236. package/lib/simple-tree/simpleSchema.js.map +1 -1
  237. package/lib/tableSchema.d.ts +241 -0
  238. package/lib/tableSchema.d.ts.map +1 -0
  239. package/lib/tableSchema.js +235 -0
  240. package/lib/tableSchema.js.map +1 -0
  241. package/lib/treeFactory.d.ts +4 -4
  242. package/lib/treeFactory.d.ts.map +1 -1
  243. package/lib/treeFactory.js.map +1 -1
  244. package/lib/util/breakable.d.ts.map +1 -1
  245. package/lib/util/breakable.js +9 -7
  246. package/lib/util/breakable.js.map +1 -1
  247. package/package.json +23 -22
  248. package/src/feature-libraries/flex-tree/context.ts +13 -3
  249. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  250. package/src/feature-libraries/flex-tree/index.ts +0 -1
  251. package/src/feature-libraries/flex-tree/lazyEntity.ts +11 -21
  252. package/src/feature-libraries/flex-tree/lazyField.ts +17 -26
  253. package/src/feature-libraries/flex-tree/lazyNode.ts +13 -19
  254. package/src/feature-libraries/index.ts +0 -1
  255. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  256. package/src/index.ts +6 -2
  257. package/src/packageVersion.ts +1 -1
  258. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  259. package/src/shared-tree/sharedTree.ts +2 -2
  260. package/src/shared-tree/treeApiAlpha.ts +17 -15
  261. package/src/shared-tree-core/sharedTreeCore.ts +0 -23
  262. package/src/simple-tree/api/conciseTree.ts +4 -4
  263. package/src/simple-tree/api/customTree.ts +16 -14
  264. package/src/simple-tree/api/getJsonSchema.ts +25 -16
  265. package/src/simple-tree/api/getSimpleSchema.ts +4 -18
  266. package/src/simple-tree/api/index.ts +4 -2
  267. package/src/simple-tree/api/schemaFactoryAlpha.ts +18 -1
  268. package/src/simple-tree/api/schemaFromSimple.ts +45 -16
  269. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +53 -34
  270. package/src/simple-tree/api/tree.ts +51 -4
  271. package/src/simple-tree/api/verboseTree.ts +7 -32
  272. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +8 -3
  273. package/src/simple-tree/core/treeNodeKernel.ts +57 -35
  274. package/src/simple-tree/core/unhydratedFlexTree.ts +22 -5
  275. package/src/simple-tree/index.ts +4 -2
  276. package/src/simple-tree/objectNode.ts +4 -2
  277. package/src/simple-tree/simpleSchema.ts +4 -12
  278. package/src/tableSchema.ts +668 -0
  279. package/src/treeFactory.ts +4 -3
  280. package/src/util/breakable.ts +9 -6
@@ -5,26 +5,19 @@
5
5
  import type { ImplicitFieldSchema } from "../schemaTypes.js";
6
6
  import type { SimpleTreeSchema } from "../simpleSchema.js";
7
7
  /**
8
- * Creates a {@link SimpleTreeSchema} from the provided {@link ImplicitFieldSchema}.
8
+ * Copies data from {@link ImplicitFieldSchema} to create a {@link SimpleTreeSchema} out of new plain JavaScript objects, Sets and Maps.
9
9
  *
10
10
  * @remarks
11
- * This provides easy access by identifier to any schema transitively referenced by the input schema via {@link SimpleTreeSchema.definitions}.
12
- *
13
- * Caches the result on the input schema for future calls.
11
+ * See also {@link TreeViewConfigurationAlpha} which implements {@link SimpleTreeSchema} as a way to get a `SimpleTreeSchema` without copying the node and field schema and without losing as much type information.
14
12
  *
15
13
  * @privateRemarks
16
14
  * In the future, we may wish to move this to a more discoverable API location.
17
15
  * For now, while still an experimental API, it is surfaced as a free function.
18
16
  *
19
- * If the main use for this is the "definitions" map, we should provide a better way to access it (that doesn't type erase the TreeNodeSchema down to SimpleNodeSchema).
20
- * TODO: Having TreeViewConfiguration implement SimpleTreeSchema directly but with more specific types would be a good way to do this.
21
- *
22
17
  * Note that all TreeNodeSchema get a {@link Context} cached on them as part of one time initialization which contains a map from identifier to all transitively referenced schema.
23
18
  * Perhaps exposing access to that would cover this use-case as well.
24
19
  *
25
- * TODO: does having this caching layer add value? Maybe this wrapper around toSimpleTreeSchema should be removed.
26
- *
27
- * @internal
20
+ * @alpha
28
21
  */
29
22
  export declare function getSimpleSchema(schema: ImplicitFieldSchema): SimpleTreeSchema;
30
23
  //# sourceMappingURL=getSimpleSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,CAE7E"}
1
+ {"version":3,"file":"getSimpleSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,CAE7E"}
@@ -2,35 +2,23 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { getOrCreate } from "../../util/index.js";
6
5
  import { toSimpleTreeSchema } from "./viewSchemaToSimpleSchema.js";
7
6
  /**
8
- * Cache in which the results of {@link getSimpleSchema} saved.
9
- */
10
- const simpleSchemaCache = new WeakMap();
11
- /**
12
- * Creates a {@link SimpleTreeSchema} from the provided {@link ImplicitFieldSchema}.
7
+ * Copies data from {@link ImplicitFieldSchema} to create a {@link SimpleTreeSchema} out of new plain JavaScript objects, Sets and Maps.
13
8
  *
14
9
  * @remarks
15
- * This provides easy access by identifier to any schema transitively referenced by the input schema via {@link SimpleTreeSchema.definitions}.
16
- *
17
- * Caches the result on the input schema for future calls.
10
+ * See also {@link TreeViewConfigurationAlpha} which implements {@link SimpleTreeSchema} as a way to get a `SimpleTreeSchema` without copying the node and field schema and without losing as much type information.
18
11
  *
19
12
  * @privateRemarks
20
13
  * In the future, we may wish to move this to a more discoverable API location.
21
14
  * For now, while still an experimental API, it is surfaced as a free function.
22
15
  *
23
- * If the main use for this is the "definitions" map, we should provide a better way to access it (that doesn't type erase the TreeNodeSchema down to SimpleNodeSchema).
24
- * TODO: Having TreeViewConfiguration implement SimpleTreeSchema directly but with more specific types would be a good way to do this.
25
- *
26
16
  * Note that all TreeNodeSchema get a {@link Context} cached on them as part of one time initialization which contains a map from identifier to all transitively referenced schema.
27
17
  * Perhaps exposing access to that would cover this use-case as well.
28
18
  *
29
- * TODO: does having this caching layer add value? Maybe this wrapper around toSimpleTreeSchema should be removed.
30
- *
31
- * @internal
19
+ * @alpha
32
20
  */
33
21
  export function getSimpleSchema(schema) {
34
- return getOrCreate(simpleSchemaCache, schema, () => toSimpleTreeSchema(schema, false));
22
+ return toSimpleTreeSchema(schema, true);
35
23
  }
36
24
  //# sourceMappingURL=getSimpleSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSimpleSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/getSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;GAEG;AACH,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAoC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,eAAe,CAAC,MAA2B;IAC1D,OAAO,WAAW,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACxF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\nimport type { ImplicitFieldSchema } from \"../schemaTypes.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport { toSimpleTreeSchema } from \"./viewSchemaToSimpleSchema.js\";\n\n/**\n * Cache in which the results of {@link getSimpleSchema} saved.\n */\nconst simpleSchemaCache = new WeakMap<TreeNodeSchema, SimpleTreeSchema>();\n\n/**\n * Creates a {@link SimpleTreeSchema} from the provided {@link ImplicitFieldSchema}.\n *\n * @remarks\n * This provides easy access by identifier to any schema transitively referenced by the input schema via {@link SimpleTreeSchema.definitions}.\n *\n * Caches the result on the input schema for future calls.\n *\n * @privateRemarks\n * In the future, we may wish to move this to a more discoverable API location.\n * For now, while still an experimental API, it is surfaced as a free function.\n *\n * If the main use for this is the \"definitions\" map, we should provide a better way to access it (that doesn't type erase the TreeNodeSchema down to SimpleNodeSchema).\n * TODO: Having TreeViewConfiguration implement SimpleTreeSchema directly but with more specific types would be a good way to do this.\n *\n * Note that all TreeNodeSchema get a {@link Context} cached on them as part of one time initialization which contains a map from identifier to all transitively referenced schema.\n * Perhaps exposing access to that would cover this use-case as well.\n *\n * TODO: does having this caching layer add value? Maybe this wrapper around toSimpleTreeSchema should be removed.\n *\n * @internal\n */\nexport function getSimpleSchema(schema: ImplicitFieldSchema): SimpleTreeSchema {\n\treturn getOrCreate(simpleSchemaCache, schema, () => toSimpleTreeSchema(schema, false));\n}\n"]}
1
+ {"version":3,"file":"getSimpleSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/getSimpleSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,MAA2B;IAC1D,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ImplicitFieldSchema } from \"../schemaTypes.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport { toSimpleTreeSchema } from \"./viewSchemaToSimpleSchema.js\";\n\n/**\n * Copies data from {@link ImplicitFieldSchema} to create a {@link SimpleTreeSchema} out of new plain JavaScript objects, Sets and Maps.\n *\n * @remarks\n * See also {@link TreeViewConfigurationAlpha} which implements {@link SimpleTreeSchema} as a way to get a `SimpleTreeSchema` without copying the node and field schema and without losing as much type information.\n *\n * @privateRemarks\n * In the future, we may wish to move this to a more discoverable API location.\n * For now, while still an experimental API, it is surfaced as a free function.\n *\n * Note that all TreeNodeSchema get a {@link Context} cached on them as part of one time initialization which contains a map from identifier to all transitively referenced schema.\n * Perhaps exposing access to that would cover this use-case as well.\n *\n * @alpha\n */\nexport function getSimpleSchema(schema: ImplicitFieldSchema): SimpleTreeSchema {\n\treturn toSimpleTreeSchema(schema, true);\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, type TreeViewAlpha, type TreeBranch, type TreeBranchEvents, type ITreeAlpha, asTreeViewAlpha, } from "./tree.js";
5
+ export { type ITree, type TreeView, type ViewableTree, type TreeViewEvents, TreeViewConfiguration, TreeViewConfigurationAlpha, type TreeSchema, type ITreeViewConfiguration, type SchemaCompatibilityStatus, type ITreeConfigurationOptions, type TreeViewAlpha, type TreeBranch, type TreeBranchEvents, type ITreeAlpha, asTreeViewAlpha, } from "./tree.js";
6
6
  export { SchemaFactory, type ScopedSchemaName, type SchemaFactoryObjectOptions, type SchemaStatics, } from "./schemaFactory.js";
7
7
  export { SchemaFactoryAlpha } from "./schemaFactoryAlpha.js";
8
8
  export type { ValidateRecursiveSchema, FixRecursiveArraySchema, } from "./schemaFactoryRecursive.js";
@@ -10,12 +10,13 @@ export { adaptEnum, enumFromStrings, singletonSchema, } from "./schemaCreationUt
10
10
  export { treeNodeApi, type TreeNodeApi, tryGetSchema } from "./treeNodeApi.js";
11
11
  export { createFromInsertable, cursorFromInsertable, createFromCursor } from "./create.js";
12
12
  export { type JsonSchemaId, type JsonSchemaType, type JsonObjectNodeSchema, type JsonArrayNodeSchema, type JsonMapNodeSchema, type JsonLeafNodeSchema, type JsonSchemaRef, type JsonRefPath, type JsonNodeSchema, type JsonNodeSchemaBase, type JsonTreeSchema, type JsonFieldSchema, type JsonLeafSchemaType, } from "./jsonSchema.js";
13
+ export type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
13
14
  export { getJsonSchema } from "./getJsonSchema.js";
14
15
  export { getSimpleSchema } from "./getSimpleSchema.js";
15
16
  export { ViewSchema } from "./view.js";
16
17
  export type { Unenforced, FieldHasDefaultUnsafe, ObjectFromSchemaRecordUnsafe, TreeObjectNodeUnsafe, TreeFieldFromImplicitFieldUnsafe, TreeNodeFromImplicitAllowedTypesUnsafe, FieldSchemaUnsafe, InsertableTreeNodeFromImplicitAllowedTypesUnsafe, TreeArrayNodeUnsafe, TreeMapNodeUnsafe, InsertableObjectFromSchemaRecordUnsafe, InsertableTreeFieldFromImplicitFieldUnsafe, InsertableTypedNodeUnsafe, NodeBuilderDataUnsafe, NodeFromSchemaUnsafe, ReadonlyMapInlined, TreeNodeSchemaClassUnsafe, TreeNodeSchemaUnsafe, AllowedTypesUnsafe, ImplicitAllowedTypesUnsafe, ImplicitFieldSchemaUnsafe, TreeNodeSchemaNonClassUnsafe, InsertableTreeNodeFromAllowedTypesUnsafe, FieldSchemaAlphaUnsafe, ArrayNodeCustomizableSchemaUnsafe, MapNodeCustomizableSchemaUnsafe, } from "./typesUnsafe.js";
17
- export { type VerboseTreeNode, type ParseOptions, type VerboseTree, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, replaceVerboseTreeHandles, } from "./verboseTree.js";
18
- export { type EncodeOptions, customFromCursorStored, type CustomTreeNode, type CustomTreeValue, tryStoredSchemaAsArray, replaceHandles, type HandleConverter, } from "./customTree.js";
18
+ export { type VerboseTreeNode, type VerboseTree, applySchemaToParserOptions, cursorFromVerbose, verboseFromCursor, replaceVerboseTreeHandles, } from "./verboseTree.js";
19
+ export { type TreeEncodingOptions, customFromCursorStored, type CustomTreeNode, type CustomTreeValue, tryStoredSchemaAsArray, replaceHandles, type HandleConverter, } from "./customTree.js";
19
20
  export { type ConciseTree, conciseFromCursor, replaceConciseTreeHandles, } from "./conciseTree.js";
20
21
  export { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from "./treeApiBeta.js";
21
22
  export { createSimpleTreeIndex, type SimpleTreeIndex } from "./simpleTreeIndex.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GA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Ae,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EACN,qBAAqB,EACrB,KAAK,eAAe,GACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EACN,eAAe,IAAI,oBAAoB,EACvC,IAAI,IAAI,yBAAyB,EACjC,uBAAuB,IAAI,4BAA4B,GACvD,MAAM,0BAA0B,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { TreeViewConfiguration, asTreeViewAlpha, } from "./tree.js";
5
+ export { TreeViewConfiguration, TreeViewConfigurationAlpha, asTreeViewAlpha, } from "./tree.js";
6
6
  export { SchemaFactory, } from "./schemaFactory.js";
7
7
  export { SchemaFactoryAlpha } from "./schemaFactoryAlpha.js";
8
8
  export { adaptEnum, enumFromStrings, singletonSchema, } from "./schemaCreationUtilities.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAKN,qBAAqB,EAQrB,eAAe,GACf,MAAM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,EACjC,uBAAuB,IAAI,4BAA4B,GACvD,MAAM,0BAA0B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\ttype ITreeAlpha,\n\tasTreeViewAlpha,\n} from \"./tree.js\";\nexport {\n\tSchemaFactory,\n\ttype ScopedSchemaName,\n\ttype SchemaFactoryObjectOptions,\n\ttype SchemaStatics,\n} from \"./schemaFactory.js\";\nexport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n} from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n} from \"./schemaCreationUtilities.js\";\nexport { treeNodeApi, type TreeNodeApi, tryGetSchema } from \"./treeNodeApi.js\";\nexport { createFromInsertable, cursorFromInsertable, createFromCursor } from \"./create.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { ViewSchema } from \"./view.js\";\nexport type {\n\tUnenforced,\n\tFieldHasDefaultUnsafe,\n\tObjectFromSchemaRecordUnsafe,\n\tTreeObjectNodeUnsafe,\n\tTreeFieldFromImplicitFieldUnsafe,\n\tTreeNodeFromImplicitAllowedTypesUnsafe,\n\tFieldSchemaUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableTypedNodeUnsafe,\n\tNodeBuilderDataUnsafe,\n\tNodeFromSchemaUnsafe,\n\tReadonlyMapInlined,\n\tTreeNodeSchemaClassUnsafe,\n\tTreeNodeSchemaUnsafe,\n\tAllowedTypesUnsafe,\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tTreeNodeSchemaNonClassUnsafe,\n\tInsertableTreeNodeFromAllowedTypesUnsafe,\n\tFieldSchemaAlphaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\n\nexport {\n\ttype VerboseTreeNode,\n\ttype ParseOptions,\n\ttype VerboseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\treplaceVerboseTreeHandles,\n} from \"./verboseTree.js\";\n\nexport {\n\ttype EncodeOptions,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\treplaceHandles,\n\ttype HandleConverter,\n} from \"./customTree.js\";\n\nexport {\n\ttype ConciseTree,\n\tconciseFromCursor,\n\treplaceConciseTreeHandles,\n} from \"./conciseTree.js\";\n\nexport { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from \"./treeApiBeta.js\";\nexport { createSimpleTreeIndex, type SimpleTreeIndex } from \"./simpleTreeIndex.js\";\nexport {\n\tcreateIdentifierIndex,\n\ttype IdentifierIndex,\n} from \"./identifierIndex.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchemaInternal,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\nexport {\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n} from \"./transactionTypes.js\";\n\nexport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nexport { toSimpleTreeSchema } from \"./viewSchemaToSimpleSchema.js\";\n\n// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.\n// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639\nexport {\n\tRecursiveObject as test_RecursiveObject,\n\tbase as test_RecursiveObject_base,\n\tRecursiveObjectPojoMode as test_RecursiveObjectPojoMode,\n} from \"./testRecursiveDomain.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/simple-tree/api/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAKN,qBAAqB,EACrB,0BAA0B,EAS1B,eAAe,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,aAAa,GAIb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,OAAO,EACN,SAAS,EACT,eAAe,EACf,eAAe,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAoB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAiB3F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA8BvC,OAAO,EAGN,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEN,sBAAsB,EAGtB,sBAAsB,EACtB,cAAc,GAEd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEN,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAmD,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAwB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EACN,qBAAqB,GAErB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAUN,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,6FAA6F;AAC7F,4IAA4I;AAC5I,OAAO,EACN,eAAe,IAAI,oBAAoB,EACvC,IAAI,IAAI,yBAAyB,EACjC,uBAAuB,IAAI,4BAA4B,GACvD,MAAM,0BAA0B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype ViewableTree,\n\ttype TreeViewEvents,\n\tTreeViewConfiguration,\n\tTreeViewConfigurationAlpha,\n\ttype TreeSchema,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n\ttype TreeViewAlpha,\n\ttype TreeBranch,\n\ttype TreeBranchEvents,\n\ttype ITreeAlpha,\n\tasTreeViewAlpha,\n} from \"./tree.js\";\nexport {\n\tSchemaFactory,\n\ttype ScopedSchemaName,\n\ttype SchemaFactoryObjectOptions,\n\ttype SchemaStatics,\n} from \"./schemaFactory.js\";\nexport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nexport type {\n\tValidateRecursiveSchema,\n\tFixRecursiveArraySchema,\n} from \"./schemaFactoryRecursive.js\";\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n} from \"./schemaCreationUtilities.js\";\nexport { treeNodeApi, type TreeNodeApi, tryGetSchema } from \"./treeNodeApi.js\";\nexport { createFromInsertable, cursorFromInsertable, createFromCursor } from \"./create.js\";\nexport {\n\ttype JsonSchemaId,\n\ttype JsonSchemaType,\n\ttype JsonObjectNodeSchema,\n\ttype JsonArrayNodeSchema,\n\ttype JsonMapNodeSchema,\n\ttype JsonLeafNodeSchema,\n\ttype JsonSchemaRef,\n\ttype JsonRefPath,\n\ttype JsonNodeSchema,\n\ttype JsonNodeSchemaBase,\n\ttype JsonTreeSchema,\n\ttype JsonFieldSchema,\n\ttype JsonLeafSchemaType,\n} from \"./jsonSchema.js\";\nexport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nexport { getJsonSchema } from \"./getJsonSchema.js\";\nexport { getSimpleSchema } from \"./getSimpleSchema.js\";\nexport { ViewSchema } from \"./view.js\";\nexport type {\n\tUnenforced,\n\tFieldHasDefaultUnsafe,\n\tObjectFromSchemaRecordUnsafe,\n\tTreeObjectNodeUnsafe,\n\tTreeFieldFromImplicitFieldUnsafe,\n\tTreeNodeFromImplicitAllowedTypesUnsafe,\n\tFieldSchemaUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableTypedNodeUnsafe,\n\tNodeBuilderDataUnsafe,\n\tNodeFromSchemaUnsafe,\n\tReadonlyMapInlined,\n\tTreeNodeSchemaClassUnsafe,\n\tTreeNodeSchemaUnsafe,\n\tAllowedTypesUnsafe,\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tTreeNodeSchemaNonClassUnsafe,\n\tInsertableTreeNodeFromAllowedTypesUnsafe,\n\tFieldSchemaAlphaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\n\nexport {\n\ttype VerboseTreeNode,\n\ttype VerboseTree,\n\tapplySchemaToParserOptions,\n\tcursorFromVerbose,\n\tverboseFromCursor,\n\treplaceVerboseTreeHandles,\n} from \"./verboseTree.js\";\n\nexport {\n\ttype TreeEncodingOptions,\n\tcustomFromCursorStored,\n\ttype CustomTreeNode,\n\ttype CustomTreeValue,\n\ttryStoredSchemaAsArray,\n\treplaceHandles,\n\ttype HandleConverter,\n} from \"./customTree.js\";\n\nexport {\n\ttype ConciseTree,\n\tconciseFromCursor,\n\treplaceConciseTreeHandles,\n} from \"./conciseTree.js\";\n\nexport { TreeBeta, type NodeChangedData, type TreeChangeEventsBeta } from \"./treeApiBeta.js\";\nexport { createSimpleTreeIndex, type SimpleTreeIndex } from \"./simpleTreeIndex.js\";\nexport {\n\tcreateIdentifierIndex,\n\ttype IdentifierIndex,\n} from \"./identifierIndex.js\";\n\nexport {\n\textractPersistedSchema,\n\tcomparePersistedSchemaInternal,\n\tcomparePersistedSchema,\n} from \"./storedSchema.js\";\n\nexport {\n\ttype TransactionConstraint,\n\ttype NodeInDocumentConstraint,\n\ttype RunTransactionParams,\n\ttype VoidTransactionCallbackStatus,\n\ttype TransactionCallbackStatus,\n\ttype TransactionResult,\n\ttype TransactionResultExt,\n\ttype TransactionResultSuccess,\n\ttype TransactionResultFailed,\n\trollback,\n} from \"./transactionTypes.js\";\n\nexport { generateSchemaFromSimpleSchema } from \"./schemaFromSimple.js\";\nexport { toSimpleTreeSchema } from \"./viewSchemaToSimpleSchema.js\";\n\n// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.\n// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639\nexport {\n\tRecursiveObject as test_RecursiveObject,\n\tbase as test_RecursiveObject_base,\n\tRecursiveObjectPojoMode as test_RecursiveObjectPojoMode,\n} from \"./testRecursiveDomain.js\";\n"]}
@@ -30,11 +30,27 @@ export declare class SchemaFactoryAlpha<out TScope extends string | undefined =
30
30
  * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.
31
31
  * @param options - Additional options for the schema.
32
32
  */
33
- object<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata>;
33
+ object<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchema>, const TCustomMetadata = unknown>(name: Name, fields: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {
34
+ /**
35
+ * Typing checking workaround: not for for actual use.
36
+ * @remarks
37
+ * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.
38
+ * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.
39
+ * @privateRemarks
40
+ * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,
41
+ * See the above link and the tests in objectNode.spec.ts which reference it.
42
+ * @system
43
+ */
44
+ readonly createFromInsertable: unknown;
45
+ };
34
46
  /**
35
47
  * {@inheritdoc SchemaFactory.objectRecursive}
36
48
  */
37
49
  objectRecursive<const Name extends TName, const T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>, const TCustomMetadata = unknown>(name: Name, t: T, options?: SchemaFactoryObjectOptions<TCustomMetadata>): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecordUnsafe<T>, false, T, never, TCustomMetadata> & SimpleObjectNodeSchema<TCustomMetadata> & Pick<ObjectNodeSchema, "fields">;
50
+ /**
51
+ * {@inheritDoc SchemaStatics.optional}
52
+ */
53
+ static readonly leaves: readonly [import("../leafNodeSchema.js").LeafSchema<"string", string> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"number", number> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"boolean", boolean> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"null", null> & import("../simpleSchema.js").SimpleLeafNodeSchema, import("../leafNodeSchema.js").LeafSchema<"handle", import("@fluidframework/core-interfaces").IFluidHandle<unknown>> & import("../simpleSchema.js").SimpleLeafNodeSchema];
38
54
  /**
39
55
  * {@inheritDoc SchemaStatics.optional}
40
56
  */
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,gBAAgB,EAChB,oBAAoB,EACpB,sCAAsC,EACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEN,aAAa,EAEb,KAAK,0BAA0B,EAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACX,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EACX,0BAA0B,EAC1B,yBAAyB,EACzB,iCAAiC,EACjC,+BAA+B,EAC/B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,K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I,EAAE,eAAe,CAAC;IAIxF;;OAEG;IAEa,cAAc,CAC7B,KAAK,CAAC,IAAI,SAAS,KAAK,EACxB,KAAK,CAAC,CAAC,SAAS,0BAA0B,EAC1C,KAAK,CAAC,eAAe,GAAG,OAAO,EAC9B,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,eAAe,CAAC;IAY3E;;;;;OAKG;IACI,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,UAAU,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EACtF,IAAI,EAAE,CAAC,GACL,kBAAkB,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC;CAG9D"}
@@ -92,6 +92,10 @@ export class SchemaFactoryAlpha extends SchemaFactory {
92
92
  return new SchemaFactoryAlpha(this.scoped2(name));
93
93
  }
94
94
  }
95
+ /**
96
+ * {@inheritDoc SchemaStatics.optional}
97
+ */
98
+ SchemaFactoryAlpha.leaves = schemaStatics.leaves;
95
99
  /**
96
100
  * {@inheritDoc SchemaStatics.optional}
97
101
  */
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACN,iCAAiC,EACjC,aAAa,EACb,aAAa,GAEb,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAShD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9C;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAGX,SAAQ,aAA4B;IAC7B,OAAO,CAA8B,IAAU;QACtD,OAAO,CACN,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,IAA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,YAAwC,EACxC,OAAO,CAKP,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,aAAa,CACnB,IAAO;QAEP,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;;AAxHD;;GAEG;AAC6B,2BAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,2BAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,aAAa,CAAC,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tScopedSchemaName,\n\tTreeObjectNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n} from \"../../internalTypes.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tschemaStatics,\n\ttype SchemaFactoryObjectOptions,\n} from \"./schemaFactory.js\";\nimport type {\n\tImplicitAllowedTypes,\n\tImplicitFieldSchema,\n\tNodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { objectSchema } from \"../objectNode.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { NodeKind, TreeNodeSchemaClass } from \"../core/index.js\";\nimport type {\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\nimport { mapSchema } from \"../mapNode.js\";\nimport { arraySchema } from \"../arrayNode.js\";\nimport type { ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { ArrayNodeCustomizableSchema } from \"../arrayNodeTypes.js\";\nimport type { MapNodeCustomizableSchema } from \"../mapNodeTypes.js\";\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(this.scoped2(name));\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFactoryAlpha.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFactoryAlpha.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACN,iCAAiC,EACjC,aAAa,EACb,aAAa,GAEb,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAShD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9C;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAGX,SAAQ,aAA4B;IAC7B,OAAO,CAA8B,IAAU;QACtD,OAAO,CACN,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAC5B,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACa,MAAM,CAKrB,IAAU,EACV,MAAS,EACT,OAAqD;QAcrD,OAAO,YAAY,CAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAClB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,0BAA0B;YAClC,iCAAiC,CAAC,0BAA0B,EAC7D,OAAO,EAAE,QAAQ,CACjB,CAAC;IACH,CAAC;IAED;;OAEG;IACa,eAAe,CAK9B,IAAU,EACV,CAAI,EACJ,OAAqD;QAwBrD,OAAO,IAAI,CAAC,MAAM,CACjB,IAAI,EACJ,CAAqD,EACrD,OAAO,CAgBN,CAAC;IACJ,CAAC;IA2BD;;;;;;;;;;;;;OAaG;IACI,QAAQ,CAKd,IAAU,EACV,YAAe,EACf,OAA4C;QAE5C,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,4EAA4E;IAC5D,YAAY,CAI1B,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,OAAO,IAAI,CAAC,QAAQ,CACnB,IAAI,EACJ,YAAwC,EACxC,OAAO,CAKP,CAAC;IACH,CAAC;IAED;;;;;;;;;;;OAWG;IACI,UAAU,CAKhB,IAAU,EACV,YAAe,EACf,OAA4C;QAE5C,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrF,CAAC;IAED;;OAEG;IACH,4EAA4E;IAC5D,cAAc,CAI5B,IAAU,EAAE,YAAe,EAAE,OAA4C;QAC1E,OAAO,IAAI,CAAC,UAAU,CACrB,IAAI,EACJ,YAAwC,EACxC,OAAO,CAKP,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,aAAa,CACnB,IAAO;QAEP,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;;AA7HD;;GAEG;AAC6B,yBAAM,GAAG,aAAa,CAAC,MAAM,CAAC;AAE9D;;GAEG;AAC6B,2BAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,2BAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AAElE;;GAEG;AAC6B,oCAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC;AAEpF;;GAEG;AACoB,6BAAU,GAAG,aAAa,CAAC,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tScopedSchemaName,\n\tTreeObjectNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n} from \"../../internalTypes.js\";\nimport {\n\tdefaultSchemaFactoryObjectOptions,\n\tSchemaFactory,\n\tschemaStatics,\n\ttype SchemaFactoryObjectOptions,\n} from \"./schemaFactory.js\";\nimport type {\n\tImplicitAllowedTypes,\n\tImplicitFieldSchema,\n\tNodeSchemaOptions,\n} from \"../schemaTypes.js\";\nimport { objectSchema } from \"../objectNode.js\";\nimport type { RestrictiveStringRecord } from \"../../util/index.js\";\nimport type { NodeKind, TreeNodeSchemaClass } from \"../core/index.js\";\nimport type {\n\tImplicitAllowedTypesUnsafe,\n\tImplicitFieldSchemaUnsafe,\n\tArrayNodeCustomizableSchemaUnsafe,\n\tMapNodeCustomizableSchemaUnsafe,\n} from \"./typesUnsafe.js\";\nimport { mapSchema } from \"../mapNode.js\";\nimport { arraySchema } from \"../arrayNode.js\";\nimport type { ObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport type { SimpleObjectNodeSchema } from \"../simpleSchema.js\";\nimport type { ArrayNodeCustomizableSchema } from \"../arrayNodeTypes.js\";\nimport type { MapNodeCustomizableSchema } from \"../mapNodeTypes.js\";\n\n/**\n * {@link SchemaFactory} with additional alpha APIs.\n *\n * @alpha\n * @privateRemarks\n *\n * Some private methods on `SchemaFactory` are intentionally duplicated here to avoid increasing their exposure to `protected`.\n * If we were to do so, they would be exposed on the public API surface of `SchemaFactory`.\n */\nexport class SchemaFactoryAlpha<\n\tout TScope extends string | undefined = string | undefined,\n\tTName extends number | string = string,\n> extends SchemaFactory<TScope, TName> {\n\tprivate scoped2<Name extends TName | string>(name: Name): ScopedSchemaName<TScope, Name> {\n\t\treturn (\n\t\t\tthis.scope === undefined ? `${name}` : `${this.scope}.${name}`\n\t\t) as ScopedSchemaName<TScope, Name>;\n\t}\n\n\t/**\n\t * Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n\t * @param options - Additional options for the schema.\n\t */\n\tpublic override object<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tfields: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): ObjectNodeSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> & {\n\t\t/**\n\t\t * Typing checking workaround: not for for actual use.\n\t\t * @remarks\n\t\t * This API collides with {@link TreeNodeSchemaCore.createFromInsertable} to disable a type checking optimization which produces different and undesired results.\n\t\t * See {@link https://github.com/microsoft/TypeScript/issues/59049#issuecomment-2773459693} for more details.\n\t\t * @privateRemarks\n\t\t * The specific issue here is non-empty POJO mode object schema not being assignable to `ObjectNodeSchema`,\n\t\t * See the above link and the tests in objectNode.spec.ts which reference it.\n\t\t * @system\n\t\t */\n\t\treadonly createFromInsertable: unknown;\n\t} {\n\t\treturn objectSchema(\n\t\t\tthis.scoped2(name),\n\t\t\tfields,\n\t\t\ttrue,\n\t\t\toptions?.allowUnknownOptionalFields ??\n\t\t\t\tdefaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,\n\t\t\toptions?.metadata,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc SchemaFactory.objectRecursive}\n\t */\n\tpublic override objectRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends RestrictiveStringRecord<ImplicitFieldSchemaUnsafe>,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tt: T,\n\t\toptions?: SchemaFactoryObjectOptions<TCustomMetadata>,\n\t): TreeNodeSchemaClass<\n\t\tScopedSchemaName<TScope, Name>,\n\t\tNodeKind.Object,\n\t\tTreeObjectNodeUnsafe<T, ScopedSchemaName<TScope, Name>>,\n\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\tfalse,\n\t\tT,\n\t\tnever,\n\t\tTCustomMetadata\n\t> &\n\t\tSimpleObjectNodeSchema<TCustomMetadata> &\n\t\t// We can't just use non generic `ObjectNodeSchema` here since \"Base constructors must all have the same return type\".\n\t\t// We also can't just use generic `ObjectNodeSchema` here and not `TreeNodeSchemaClass` since that doesn't work with unsafe recursive types.\n\t\t// ObjectNodeSchema<\n\t\t// \tScopedSchemaName<TScope, Name>,\n\t\t// \t// T & RestrictiveStringRecord<ImplicitFieldSchema> would be nice to use here, but it breaks the recursive type self references.\n\t\t// \tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t// \tfalse,\n\t\t// \tTCustomMetadata\n\t\t// >\n\t\tPick<ObjectNodeSchema, \"fields\"> {\n\t\t// TODO: syntax highting is vs code is broken here. Don't trust it. Use the compiler instead.\n\t\ttype TScopedName = ScopedSchemaName<TScope, Name>;\n\t\treturn this.object(\n\t\t\tname,\n\t\t\tt as T & RestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\toptions,\n\t\t) as unknown as TreeNodeSchemaClass<\n\t\t\tTScopedName,\n\t\t\tNodeKind.Object,\n\t\t\tTreeObjectNodeUnsafe<T, TScopedName>,\n\t\t\tobject & InsertableObjectFromSchemaRecordUnsafe<T>,\n\t\t\tfalse,\n\t\t\tT,\n\t\t\tnever,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\t\tObjectNodeSchema<\n\t\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\t\tRestrictiveStringRecord<ImplicitFieldSchema>,\n\t\t\t\tfalse,\n\t\t\t\tTCustomMetadata\n\t\t\t>;\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly leaves = schemaStatics.leaves;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optional}\n\t */\n\tpublic static override readonly optional = schemaStatics.optional;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.required}\n\t */\n\tpublic static override readonly required = schemaStatics.required;\n\n\t/**\n\t * {@inheritDoc SchemaStatics.optionalRecursive}\n\t */\n\tpublic static override readonly optionalRecursive = schemaStatics.optionalRecursive;\n\n\t/**\n\t * Like {@link SchemaFactory.identifier} but static and a factory function that can be provided {@link FieldProps}.\n\t */\n\tpublic static readonly identifier = schemaStatics.identifier;\n\n\t/**\n\t * Define a {@link TreeNodeSchema} for a {@link TreeMapNode}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear as values in the map.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedMap extends factory.map(\"name\", factory.number, {\n\t * \tmetadata: { description: \"A map of numbers\" }\n\t * }) {}\n\t * ```\n\t */\n\tpublic mapAlpha<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): MapNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn mapSchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override mapRecursive<\n\t\tName extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.mapAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as MapNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeArrayNode:interface)}.\n\t *\n\t * @param name - Unique identifier for this schema within this factory's scope.\n\t * @param allowedTypes - The types that may appear in the array.\n\t * @param options - Additional options for the schema.\n\t *\n\t * @example\n\t * ```typescript\n\t * class NamedArray extends factory.arrayAlpha(\"name\", factory.number) {}\n\t * ```\n\t */\n\tpublic arrayAlpha<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypes,\n\t\tconst TCustomMetadata = unknown,\n\t>(\n\t\tname: Name,\n\t\tallowedTypes: T,\n\t\toptions?: NodeSchemaOptions<TCustomMetadata>,\n\t): ArrayNodeCustomizableSchema<ScopedSchemaName<TScope, Name>, T, true, TCustomMetadata> {\n\t\treturn arraySchema(this.scoped2(name), allowedTypes, true, true, options?.metadata);\n\t}\n\n\t/**\n\t * {@inheritDoc SchemaFactory.objectRecursive}\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\tpublic override arrayRecursive<\n\t\tconst Name extends TName,\n\t\tconst T extends ImplicitAllowedTypesUnsafe,\n\t\tconst TCustomMetadata = unknown,\n\t>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {\n\t\treturn this.arrayAlpha(\n\t\t\tname,\n\t\t\tallowedTypes as T & ImplicitAllowedTypes,\n\t\t\toptions,\n\t\t) as unknown as ArrayNodeCustomizableSchemaUnsafe<\n\t\t\tScopedSchemaName<TScope, Name>,\n\t\t\tT,\n\t\t\tTCustomMetadata\n\t\t>;\n\t}\n\n\t/**\n\t * Create a {@link SchemaFactory} with a {@link SchemaFactory.scope|scope} which is a combination of this factory's scope and the provided name.\n\t * @remarks\n\t * The main use-case for this is when creating a collection of related schema (for example using a function that creates multiple schema).\n\t * Creating such related schema using a sub-scope helps ensure they won't collide with other schema in the parent scope.\n\t */\n\tpublic scopedFactory<const T extends TName, TNameInner extends number | string = string>(\n\t\tname: T,\n\t): SchemaFactoryAlpha<ScopedSchemaName<TScope, T>, TNameInner> {\n\t\treturn new SchemaFactoryAlpha(this.scoped2(name));\n\t}\n}\n"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type FieldSchemaAlpha } from "../schemaTypes.js";
6
5
  import type { SimpleTreeSchema } from "../simpleSchema.js";
6
+ import type { TreeSchema } from "./tree.js";
7
7
  /**
8
8
  * Create {@link FieldSchema} from a SimpleTreeSchema.
9
9
  * @remarks
@@ -13,7 +13,10 @@ import type { SimpleTreeSchema } from "../simpleSchema.js";
13
13
  * will produce a poor TypeScript typing experience which is subject to change.
14
14
  *
15
15
  * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.
16
+ *
17
+ * This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.
18
+ * If any particular choice is required for such cases, this API should not be used.
16
19
  * @alpha
17
20
  */
18
- export declare function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): FieldSchemaAlpha;
21
+ export declare function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema;
19
22
  //# sourceMappingURL=schemaFromSimple.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFromSimple.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,KAAK,gBAAgB,EAErB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAGX,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAK5B;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CASzF"}
1
+ {"version":3,"file":"schemaFromSimple.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,KAAK,EAGX,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAmBnF"}
@@ -5,7 +5,6 @@
5
5
  import { unreachableCase, fail } from "@fluidframework/core-utils/internal";
6
6
  import { NodeKind } from "../core/index.js";
7
7
  import { FieldKind, } from "../schemaTypes.js";
8
- import { SchemaFactory } from "./schemaFactory.js";
9
8
  import { SchemaFactoryAlpha } from "./schemaFactoryAlpha.js";
10
9
  const factory = new SchemaFactoryAlpha(undefined);
11
10
  /**
@@ -17,6 +16,9 @@ const factory = new SchemaFactoryAlpha(undefined);
17
16
  * will produce a poor TypeScript typing experience which is subject to change.
18
17
  *
19
18
  * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.
19
+ *
20
+ * This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.
21
+ * If any particular choice is required for such cases, this API should not be used.
20
22
  * @alpha
21
23
  */
22
24
  export function generateSchemaFromSimpleSchema(simple) {
@@ -25,18 +27,30 @@ export function generateSchemaFromSimpleSchema(simple) {
25
27
  // This relies on the caching in evaluateLazySchema so that it only runs once.
26
28
  () => generateNode(id, schema, context),
27
29
  ]));
28
- return generateFieldSchema(simple, context);
30
+ const root = generateFieldSchema(simple.root, context, undefined);
31
+ const definitions = new Map();
32
+ for (const [id, lazy] of context) {
33
+ definitions.set(id, lazy());
34
+ }
35
+ return {
36
+ root,
37
+ definitions,
38
+ };
29
39
  }
30
- function generateFieldSchema(simple, context) {
40
+ function generateFieldSchema(simple, context, storedKey) {
31
41
  const allowed = generateAllowedTypes(simple.allowedTypesIdentifiers, context);
42
+ const props = {
43
+ metadata: simple.metadata,
44
+ key: storedKey,
45
+ };
32
46
  // Using createFieldSchema could work, but would require setting up the default providers.
33
47
  switch (simple.kind) {
34
48
  case FieldKind.Identifier:
35
- return SchemaFactoryAlpha.identifier({ metadata: simple.metadata });
49
+ return SchemaFactoryAlpha.identifier(props);
36
50
  case FieldKind.Optional:
37
- return SchemaFactoryAlpha.optional(allowed, { metadata: simple.metadata });
51
+ return SchemaFactoryAlpha.optional(allowed, props);
38
52
  case FieldKind.Required:
39
- return SchemaFactoryAlpha.required(allowed, { metadata: simple.metadata });
53
+ return SchemaFactoryAlpha.required(allowed, props);
40
54
  default:
41
55
  return unreachableCase(simple.kind);
42
56
  }
@@ -49,8 +63,10 @@ function generateNode(id, schema, context) {
49
63
  case NodeKind.Object: {
50
64
  const fields = {};
51
65
  for (const [key, field] of schema.fields) {
52
- fields[key] = generateFieldSchema(field, context);
66
+ fields[key] = generateFieldSchema(field, context, field.storedKey);
53
67
  }
68
+ // Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:
69
+ // users of this code are expected to handle what ever choice this code makes for cases like this.
54
70
  return factory.object(id, fields, { metadata: schema.metadata });
55
71
  }
56
72
  case NodeKind.Array:
@@ -58,7 +74,7 @@ function generateNode(id, schema, context) {
58
74
  case NodeKind.Map:
59
75
  return factory.mapAlpha(id, generateAllowedTypes(schema.allowedTypesIdentifiers, context), { metadata: schema.metadata });
60
76
  case NodeKind.Leaf:
61
- return (SchemaFactory.leaves.find((leaf) => leaf.identifier === id) ??
77
+ return (SchemaFactoryAlpha.leaves.find((leaf) => leaf.identifier === id) ??
62
78
  fail(0xb5b /* Missing schema */));
63
79
  default:
64
80
  return unreachableCase(schema);
@@ -1 +1 @@
1
- {"version":3,"file":"schemaFromSimple.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAIN,SAAS,GACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,M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AC;QACH;YACC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype AllowedTypes,\n\ttype FieldSchemaAlpha,\n\tFieldKind,\n} from \"../schemaTypes.js\";\nimport { SchemaFactory } from \"./schemaFactory.js\";\nimport type {\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\n\nconst factory = new SchemaFactoryAlpha(undefined);\n\n/**\n * Create {@link FieldSchema} from a SimpleTreeSchema.\n * @remarks\n * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.\n *\n * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}\n * will produce a poor TypeScript typing experience which is subject to change.\n *\n * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.\n * @alpha\n */\nexport function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): FieldSchemaAlpha {\n\tconst context: Context = new Map(\n\t\t[...simple.definitions].map(([id, schema]): [string, () => TreeNodeSchema] => [\n\t\t\tid,\n\t\t\t// This relies on the caching in evaluateLazySchema so that it only runs once.\n\t\t\t() => generateNode(id, schema, context),\n\t\t]),\n\t);\n\treturn generateFieldSchema(simple, context);\n}\n\ntype Context = ReadonlyMap<string, () => TreeNodeSchema>;\n\nfunction generateFieldSchema(simple: SimpleFieldSchema, context: Context): FieldSchemaAlpha {\n\tconst allowed = generateAllowedTypes(simple.allowedTypesIdentifiers, context);\n\t// Using createFieldSchema could work, but would require setting up the default providers.\n\tswitch (simple.kind) {\n\t\tcase FieldKind.Identifier:\n\t\t\treturn SchemaFactoryAlpha.identifier({ metadata: simple.metadata });\n\t\tcase FieldKind.Optional:\n\t\t\treturn SchemaFactoryAlpha.optional(allowed, { metadata: simple.metadata });\n\t\tcase FieldKind.Required:\n\t\t\treturn SchemaFactoryAlpha.required(allowed, { metadata: simple.metadata });\n\t\tdefault:\n\t\t\treturn unreachableCase(simple.kind);\n\t}\n}\n\nfunction generateAllowedTypes(allowed: ReadonlySet<string>, context: Context): AllowedTypes {\n\treturn [...allowed].map((id) => context.get(id) ?? fail(0xb5a /* Missing schema */));\n}\n\nfunction generateNode(id: string, schema: SimpleNodeSchema, context: Context): TreeNodeSchema {\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Record<string, FieldSchema> = {};\n\t\t\tfor (const [key, field] of schema.fields) {\n\t\t\t\tfields[key] = generateFieldSchema(field, context);\n\t\t\t}\n\t\t\treturn factory.object(id, fields, { metadata: schema.metadata });\n\t\t}\n\t\tcase NodeKind.Array:\n\t\t\treturn factory.arrayAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Map:\n\t\t\treturn factory.mapAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Leaf:\n\t\t\treturn (\n\t\t\t\tSchemaFactory.leaves.find((leaf) => leaf.identifier === id) ??\n\t\t\t\tfail(0xb5b /* Missing schema */)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn unreachableCase(schema);\n\t}\n}\n"]}
1
+ {"version":3,"file":"schemaFromSimple.js","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaFromSimple.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAC5E,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AAuB,EAAE,OAAO,CAAC,EAC7D,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAC7B,CAAC;QACH,KAAK,QAAQ,CAAC,GAAG;YAChB,OAAO,OAAO,CAAC,QAAQ,CACtB,EAAE,EACF,oBAAoB,CAAC,MAAM,CAAC,uBAAuB,EAAE,OAAO,CAAC,EAC7D,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAC7B,CAAC;QACH,KAAK,QAAQ,CAAC,IAAI;YACjB,OAAO,CACN,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC;gBAChE,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAChC,CAAC;QACH;YACC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase, fail } from \"@fluidframework/core-utils/internal\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype AllowedTypes,\n\ttype FieldSchemaAlpha,\n\tFieldKind,\n\ttype FieldProps,\n} from \"../schemaTypes.js\";\nimport type {\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"../simpleSchema.js\";\nimport { SchemaFactoryAlpha } from \"./schemaFactoryAlpha.js\";\nimport type { TreeSchema } from \"./tree.js\";\n\nconst factory = new SchemaFactoryAlpha(undefined);\n\n/**\n * Create {@link FieldSchema} from a SimpleTreeSchema.\n * @remarks\n * Only use this API if hand written schema (produced using {@link SchemaFactory} cannot be provided.\n *\n * Using generated schema with schema aware APIs (designed to work with strongly typed schema) like {@link TreeViewConfiguration}\n * will produce a poor TypeScript typing experience which is subject to change.\n *\n * Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.\n *\n * This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of `allowUnknownOptionalFields`.\n * If any particular choice is required for such cases, this API should not be used.\n * @alpha\n */\nexport function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema {\n\tconst context: Context = new Map(\n\t\t[...simple.definitions].map(\n\t\t\t([id, schema]): [string, () => TreeNodeSchema & SimpleNodeSchema] => [\n\t\t\t\tid,\n\t\t\t\t// This relies on the caching in evaluateLazySchema so that it only runs once.\n\t\t\t\t() => generateNode(id, schema, context),\n\t\t\t],\n\t\t),\n\t);\n\tconst root = generateFieldSchema(simple.root, context, undefined);\n\tconst definitions = new Map<string, TreeNodeSchema & SimpleNodeSchema>();\n\tfor (const [id, lazy] of context) {\n\t\tdefinitions.set(id, lazy());\n\t}\n\treturn {\n\t\troot,\n\t\tdefinitions,\n\t};\n}\n\ntype Context = ReadonlyMap<string, () => TreeNodeSchema & SimpleNodeSchema>;\n\nfunction generateFieldSchema(\n\tsimple: SimpleFieldSchema,\n\tcontext: Context,\n\tstoredKey: string | undefined,\n): FieldSchemaAlpha {\n\tconst allowed = generateAllowedTypes(simple.allowedTypesIdentifiers, context);\n\tconst props: Omit<FieldProps, \"defaultProvider\"> = {\n\t\tmetadata: simple.metadata,\n\t\tkey: storedKey,\n\t};\n\n\t// Using createFieldSchema could work, but would require setting up the default providers.\n\tswitch (simple.kind) {\n\t\tcase FieldKind.Identifier:\n\t\t\treturn SchemaFactoryAlpha.identifier(props);\n\t\tcase FieldKind.Optional:\n\t\t\treturn SchemaFactoryAlpha.optional(allowed, props);\n\t\tcase FieldKind.Required:\n\t\t\treturn SchemaFactoryAlpha.required(allowed, props);\n\t\tdefault:\n\t\t\treturn unreachableCase(simple.kind);\n\t}\n}\n\nfunction generateAllowedTypes(allowed: ReadonlySet<string>, context: Context): AllowedTypes {\n\treturn [...allowed].map((id) => context.get(id) ?? fail(0xb5a /* Missing schema */));\n}\n\nfunction generateNode(\n\tid: string,\n\tschema: SimpleNodeSchema,\n\tcontext: Context,\n): TreeNodeSchema & SimpleNodeSchema {\n\tswitch (schema.kind) {\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Record<string, FieldSchema> = {};\n\t\t\tfor (const [key, field] of schema.fields) {\n\t\t\t\tfields[key] = generateFieldSchema(field, context, field.storedKey);\n\t\t\t}\n\t\t\t// Here allowUnknownOptionalFields is implicitly defaulting. This is a subjective policy choice:\n\t\t\t// users of this code are expected to handle what ever choice this code makes for cases like this.\n\t\t\treturn factory.object(id, fields, { metadata: schema.metadata });\n\t\t}\n\t\tcase NodeKind.Array:\n\t\t\treturn factory.arrayAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Map:\n\t\t\treturn factory.mapAlpha(\n\t\t\t\tid,\n\t\t\t\tgenerateAllowedTypes(schema.allowedTypesIdentifiers, context),\n\t\t\t\t{ metadata: schema.metadata },\n\t\t\t);\n\t\tcase NodeKind.Leaf:\n\t\t\treturn (\n\t\t\t\tSchemaFactoryAlpha.leaves.find((leaf) => leaf.identifier === id) ??\n\t\t\t\tfail(0xb5b /* Missing schema */)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn unreachableCase(schema);\n\t}\n}\n"]}
@@ -3,11 +3,19 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { JsonObjectNodeSchema, JsonTreeSchema } from "./jsonSchema.js";
6
- import type { SimpleObjectNodeSchema, SimpleTreeSchema } from "../simpleSchema.js";
6
+ import type { TreeSchema } from "./tree.js";
7
+ import type { TreeSchemaEncodingOptions } from "./getJsonSchema.js";
8
+ import { ObjectNodeSchema } from "../objectNodeTypes.js";
7
9
  /**
8
10
  * Generates a JSON Schema representation from a simple tree schema.
11
+ * @remarks
12
+ * This expects the data to be in the {@link ConciseTree} format.
13
+ *
14
+ * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.
15
+ * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.
16
+ *
9
17
  * @internal
10
18
  */
11
- export declare function toJsonSchema(schema: SimpleTreeSchema): JsonTreeSchema;
12
- export declare function convertObjectNodeSchema(schema: SimpleObjectNodeSchema): JsonObjectNodeSchema;
19
+ export declare function toJsonSchema(schema: TreeSchema, options: Required<TreeSchemaEncodingOptions>): JsonTreeSchema;
20
+ export declare function convertObjectNodeSchema(schema: ObjectNodeSchema, options: Required<TreeSchemaEncodingOptions>): JsonObjectNodeSchema;
13
21
  //# sourceMappingURL=simpleSchemaToJsonSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAQX,oBAAoB,EACpB,cAAc,EAEd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAKX,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,oBAAoB,CAAC;AAG5B;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAiBrE;AAuFD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,sBAAsB,GAAG,oBAAoB,CAkC5F"}
1
+ {"version":3,"file":"simpleSchemaToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAQX,oBAAoB,EACpB,cAAc,EAEd,MAAM,iBAAiB,CAAC;AAQzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,cAAc,CAoBhB;AAkFD,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,oBAAoB,CAwCtB"}
@@ -5,19 +5,32 @@
5
5
  import { unreachableCase } from "@fluidframework/core-utils/internal";
6
6
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
7
  import { ValueSchema } from "../../core/index.js";
8
- import { copyProperty, getOrCreate, hasSingle } from "../../util/index.js";
8
+ import { copyProperty, hasSingle } from "../../util/index.js";
9
9
  import { FieldKind } from "../schemaTypes.js";
10
10
  import { NodeKind } from "../core/index.js";
11
+ import { ObjectNodeSchema } from "../objectNodeTypes.js";
12
+ import { ArrayNodeSchema } from "../arrayNodeTypes.js";
13
+ import { MapNodeSchema } from "../mapNodeTypes.js";
14
+ import { LeafNodeSchema } from "../leafNodeSchema.js";
11
15
  /**
12
16
  * Generates a JSON Schema representation from a simple tree schema.
17
+ * @remarks
18
+ * This expects the data to be in the {@link ConciseTree} format.
19
+ *
20
+ * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.
21
+ * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.
22
+ *
13
23
  * @internal
14
24
  */
15
- export function toJsonSchema(schema) {
16
- const definitions = convertDefinitions(schema.definitions);
25
+ export function toJsonSchema(schema, options) {
26
+ const definitions = convertDefinitions(schema.definitions, options);
17
27
  const allowedTypes = [];
18
- for (const allowedType of schema.allowedTypesIdentifiers) {
28
+ for (const allowedType of schema.root.allowedTypesIdentifiers) {
19
29
  allowedTypes.push(createSchemaRef(allowedType));
20
30
  }
31
+ // TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.
32
+ // TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes
33
+ // TODO: handle case where allowedTypes is empty.
21
34
  return hasSingle(allowedTypes)
22
35
  ? {
23
36
  ...allowedTypes[0],
@@ -28,37 +41,32 @@ export function toJsonSchema(schema) {
28
41
  anyOf: allowedTypes,
29
42
  };
30
43
  }
31
- function convertDefinitions(definitions) {
44
+ function convertDefinitions(definitions, options) {
32
45
  const result = {};
33
46
  for (const [key, value] of definitions) {
34
- result[key] = convertNodeSchema(value);
47
+ result[key] = convertNodeSchema(value, options);
35
48
  }
36
49
  return result;
37
50
  }
38
- /**
39
- * Private symbol under which the results of {@link convertNodeSchema} are cached on an input {@link SimpleNodeSchema}.
40
- */
41
- const nodeJsonSchemaCache = new WeakMap();
42
51
  /**
43
52
  * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.
44
53
  *
45
54
  * @remarks Caches the result on the input schema for future calls.
46
55
  */
47
- function convertNodeSchema(schema) {
48
- return getOrCreate(nodeJsonSchemaCache, schema, () => {
49
- switch (schema.kind) {
50
- case NodeKind.Array:
51
- return convertArrayNodeSchema(schema);
52
- case NodeKind.Leaf:
53
- return convertLeafNodeSchema(schema);
54
- case NodeKind.Map:
55
- return convertMapNodeSchema(schema);
56
- case NodeKind.Object:
57
- return convertObjectNodeSchema(schema);
58
- default:
59
- throw new TypeError(`Unknown node schema kind: ${schema.kind}`);
60
- }
61
- });
56
+ function convertNodeSchema(schema, options) {
57
+ if (schema instanceof ArrayNodeSchema) {
58
+ return convertArrayNodeSchema(schema);
59
+ }
60
+ else if (schema instanceof MapNodeSchema) {
61
+ return convertMapNodeSchema(schema);
62
+ }
63
+ else if (schema instanceof ObjectNodeSchema) {
64
+ return convertObjectNodeSchema(schema, options);
65
+ }
66
+ else if (schema instanceof LeafNodeSchema) {
67
+ return convertLeafNodeSchema(schema);
68
+ }
69
+ throw new TypeError(`Unknown node schema kind: ${schema.kind}`);
62
70
  }
63
71
  function convertArrayNodeSchema(schema) {
64
72
  const allowedTypes = [];
@@ -101,10 +109,11 @@ function convertLeafNodeSchema(schema) {
101
109
  _treeNodeSchemaKind: NodeKind.Leaf,
102
110
  };
103
111
  }
104
- export function convertObjectNodeSchema(schema) {
112
+ export function convertObjectNodeSchema(schema, options) {
105
113
  const properties = {};
106
114
  const required = [];
107
- for (const [key, fieldSchema] of schema.fields) {
115
+ for (const [propertyKey, fieldSchema] of schema.fields) {
116
+ const key = options.useStoredKeys ? fieldSchema.storedKey : propertyKey;
108
117
  const allowedTypes = [];
109
118
  for (const allowedType of fieldSchema.allowedTypesIdentifiers) {
110
119
  allowedTypes.push(createSchemaRef(allowedType));
@@ -116,8 +125,11 @@ export function convertObjectNodeSchema(schema) {
116
125
  };
117
126
  copyProperty(fieldSchema.metadata, "description", output);
118
127
  properties[key] = output;
119
- if (fieldSchema.kind === FieldKind.Required) {
120
- required.push(key);
128
+ if (fieldSchema.kind !== FieldKind.Optional) {
129
+ if (options.requireFieldsWithDefaults ||
130
+ fieldSchema.props?.defaultProvider === undefined) {
131
+ required.push(key);
132
+ }
121
133
  }
122
134
  }
123
135
  const transformedNode = {