@fluidframework/tree 2.31.0 → 2.32.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 (242) 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 +1 -1
  7. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  8. package/dist/feature-libraries/flex-tree/context.js +1 -2
  9. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  10. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  11. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  12. package/dist/feature-libraries/flex-tree/index.js +1 -2
  13. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  14. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  15. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  16. package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -18
  17. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  18. package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  19. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  20. package/dist/feature-libraries/flex-tree/lazyField.js +14 -14
  21. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  22. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  23. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  24. package/dist/feature-libraries/flex-tree/lazyNode.js +12 -12
  25. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  26. package/dist/feature-libraries/index.d.ts +1 -1
  27. package/dist/feature-libraries/index.d.ts.map +1 -1
  28. package/dist/feature-libraries/index.js +1 -2
  29. package/dist/feature-libraries/index.js.map +1 -1
  30. package/dist/index.d.ts +2 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -2
  33. package/dist/index.js.map +1 -1
  34. package/dist/packageVersion.d.ts +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/shared-tree/sharedTree.js +2 -2
  38. package/dist/shared-tree/sharedTree.js.map +1 -1
  39. package/dist/shared-tree/treeApiAlpha.d.ts +6 -6
  40. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  41. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  42. package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -6
  43. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  44. package/dist/shared-tree-core/sharedTreeCore.js +0 -17
  45. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  46. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  47. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  48. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  49. package/dist/simple-tree/api/customTree.d.ts +14 -12
  50. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  51. package/dist/simple-tree/api/customTree.js.map +1 -1
  52. package/dist/simple-tree/api/getJsonSchema.d.ts +21 -7
  53. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  54. package/dist/simple-tree/api/getJsonSchema.js +8 -16
  55. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  56. package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -10
  57. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  58. package/dist/simple-tree/api/getSimpleSchema.js +4 -16
  59. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  60. package/dist/simple-tree/api/index.d.ts +4 -3
  61. package/dist/simple-tree/api/index.d.ts.map +1 -1
  62. package/dist/simple-tree/api/index.js +2 -1
  63. package/dist/simple-tree/api/index.js.map +1 -1
  64. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  65. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  66. package/dist/simple-tree/api/schemaFactoryAlpha.js +4 -0
  67. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  68. package/dist/simple-tree/api/schemaFromSimple.d.ts +5 -2
  69. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  70. package/dist/simple-tree/api/schemaFromSimple.js +24 -8
  71. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  72. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  73. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  74. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +40 -28
  75. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  76. package/dist/simple-tree/api/tree.d.ts +32 -5
  77. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  78. package/dist/simple-tree/api/tree.js +17 -1
  79. package/dist/simple-tree/api/tree.js.map +1 -1
  80. package/dist/simple-tree/api/verboseTree.d.ts +4 -28
  81. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  82. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  83. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  84. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  85. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  86. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  87. package/dist/simple-tree/core/treeNodeKernel.js +7 -6
  88. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  89. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  90. package/dist/simple-tree/core/unhydratedFlexTree.js +12 -1
  91. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  92. package/dist/simple-tree/index.d.ts +1 -1
  93. package/dist/simple-tree/index.d.ts.map +1 -1
  94. package/dist/simple-tree/index.js +3 -2
  95. package/dist/simple-tree/index.js.map +1 -1
  96. package/dist/simple-tree/simpleSchema.d.ts +4 -11
  97. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  98. package/dist/simple-tree/simpleSchema.js.map +1 -1
  99. package/dist/tableSchema.d.ts +227 -0
  100. package/dist/tableSchema.d.ts.map +1 -0
  101. package/dist/tableSchema.js +234 -0
  102. package/dist/tableSchema.js.map +1 -0
  103. package/dist/treeFactory.d.ts +4 -4
  104. package/dist/treeFactory.d.ts.map +1 -1
  105. package/dist/treeFactory.js.map +1 -1
  106. package/dist/util/breakable.d.ts.map +1 -1
  107. package/dist/util/breakable.js +9 -7
  108. package/dist/util/breakable.js.map +1 -1
  109. package/lib/alpha.d.ts +6 -2
  110. package/lib/feature-libraries/flex-tree/context.d.ts +1 -1
  111. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  112. package/lib/feature-libraries/flex-tree/context.js +1 -2
  113. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  114. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  115. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  116. package/lib/feature-libraries/flex-tree/index.js +1 -1
  117. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  118. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  119. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  120. package/lib/feature-libraries/flex-tree/lazyEntity.js +8 -17
  121. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  122. package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  123. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  124. package/lib/feature-libraries/flex-tree/lazyField.js +15 -15
  125. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  126. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  127. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  128. package/lib/feature-libraries/flex-tree/lazyNode.js +13 -13
  129. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  130. package/lib/feature-libraries/index.d.ts +1 -1
  131. package/lib/feature-libraries/index.d.ts.map +1 -1
  132. package/lib/feature-libraries/index.js +1 -1
  133. package/lib/feature-libraries/index.js.map +1 -1
  134. package/lib/index.d.ts +2 -1
  135. package/lib/index.d.ts.map +1 -1
  136. package/lib/index.js +2 -1
  137. package/lib/index.js.map +1 -1
  138. package/lib/packageVersion.d.ts +1 -1
  139. package/lib/packageVersion.js +1 -1
  140. package/lib/packageVersion.js.map +1 -1
  141. package/lib/shared-tree/sharedTree.js +2 -2
  142. package/lib/shared-tree/sharedTree.js.map +1 -1
  143. package/lib/shared-tree/treeApiAlpha.d.ts +6 -6
  144. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  145. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  146. package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -6
  147. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  148. package/lib/shared-tree-core/sharedTreeCore.js +0 -17
  149. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  150. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  151. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  152. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  153. package/lib/simple-tree/api/customTree.d.ts +14 -12
  154. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  155. package/lib/simple-tree/api/customTree.js.map +1 -1
  156. package/lib/simple-tree/api/getJsonSchema.d.ts +21 -7
  157. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  158. package/lib/simple-tree/api/getJsonSchema.js +8 -16
  159. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  160. package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -10
  161. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  162. package/lib/simple-tree/api/getSimpleSchema.js +4 -16
  163. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  164. package/lib/simple-tree/api/index.d.ts +4 -3
  165. package/lib/simple-tree/api/index.d.ts.map +1 -1
  166. package/lib/simple-tree/api/index.js +1 -1
  167. package/lib/simple-tree/api/index.js.map +1 -1
  168. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  169. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  170. package/lib/simple-tree/api/schemaFactoryAlpha.js +4 -0
  171. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  172. package/lib/simple-tree/api/schemaFromSimple.d.ts +5 -2
  173. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  174. package/lib/simple-tree/api/schemaFromSimple.js +24 -8
  175. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  176. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  177. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  178. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +41 -29
  179. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  180. package/lib/simple-tree/api/tree.d.ts +32 -5
  181. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  182. package/lib/simple-tree/api/tree.js +16 -1
  183. package/lib/simple-tree/api/tree.js.map +1 -1
  184. package/lib/simple-tree/api/verboseTree.d.ts +4 -28
  185. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  186. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  187. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  188. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  189. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  190. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  191. package/lib/simple-tree/core/treeNodeKernel.js +8 -7
  192. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  193. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  194. package/lib/simple-tree/core/unhydratedFlexTree.js +12 -1
  195. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  196. package/lib/simple-tree/index.d.ts +1 -1
  197. package/lib/simple-tree/index.d.ts.map +1 -1
  198. package/lib/simple-tree/index.js +1 -1
  199. package/lib/simple-tree/index.js.map +1 -1
  200. package/lib/simple-tree/simpleSchema.d.ts +4 -11
  201. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  202. package/lib/simple-tree/simpleSchema.js.map +1 -1
  203. package/lib/tableSchema.d.ts +227 -0
  204. package/lib/tableSchema.d.ts.map +1 -0
  205. package/lib/tableSchema.js +231 -0
  206. package/lib/tableSchema.js.map +1 -0
  207. package/lib/treeFactory.d.ts +4 -4
  208. package/lib/treeFactory.d.ts.map +1 -1
  209. package/lib/treeFactory.js.map +1 -1
  210. package/lib/util/breakable.d.ts.map +1 -1
  211. package/lib/util/breakable.js +9 -7
  212. package/lib/util/breakable.js.map +1 -1
  213. package/package.json +25 -37
  214. package/src/feature-libraries/flex-tree/context.ts +2 -2
  215. package/src/feature-libraries/flex-tree/index.ts +0 -1
  216. package/src/feature-libraries/flex-tree/lazyEntity.ts +11 -21
  217. package/src/feature-libraries/flex-tree/lazyField.ts +17 -26
  218. package/src/feature-libraries/flex-tree/lazyNode.ts +13 -19
  219. package/src/feature-libraries/index.ts +0 -1
  220. package/src/index.ts +6 -2
  221. package/src/packageVersion.ts +1 -1
  222. package/src/shared-tree/sharedTree.ts +2 -2
  223. package/src/shared-tree/treeApiAlpha.ts +17 -15
  224. package/src/shared-tree-core/sharedTreeCore.ts +0 -23
  225. package/src/simple-tree/api/conciseTree.ts +4 -4
  226. package/src/simple-tree/api/customTree.ts +16 -14
  227. package/src/simple-tree/api/getJsonSchema.ts +25 -16
  228. package/src/simple-tree/api/getSimpleSchema.ts +4 -18
  229. package/src/simple-tree/api/index.ts +4 -2
  230. package/src/simple-tree/api/schemaFactoryAlpha.ts +18 -1
  231. package/src/simple-tree/api/schemaFromSimple.ts +45 -16
  232. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +53 -34
  233. package/src/simple-tree/api/tree.ts +51 -4
  234. package/src/simple-tree/api/verboseTree.ts +7 -32
  235. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +8 -3
  236. package/src/simple-tree/core/treeNodeKernel.ts +11 -7
  237. package/src/simple-tree/core/unhydratedFlexTree.ts +17 -4
  238. package/src/simple-tree/index.ts +4 -2
  239. package/src/simple-tree/simpleSchema.ts +4 -12
  240. package/src/tableSchema.ts +609 -0
  241. package/src/treeFactory.ts +4 -3
  242. package/src/util/breakable.ts +9 -6
@@ -1 +1 @@
1
- {"version":3,"file":"conciseTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/conciseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAGN,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,GAAG,YAAY,IAC3C,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,GACpC,OAAO,GACP,WAAW,CAAC,OAAO,CAAC,EAAE,GACtB;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC;AAEL;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,aAAa,GACpB,WAAW,CAQb;AAUD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAC1C,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,WAAW,CAAC,CAAC,CAAC,CAEhB"}
1
+ {"version":3,"file":"conciseTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/conciseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAGN,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,GAAG,YAAY,IAC3C,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,GACpC,OAAO,GACP,WAAW,CAAC,OAAO,CAAC,EAAE,GACtB;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;CACnC,CAAC;AAEL;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,mBAAmB,GAC1B,WAAW,CAQb;AAUD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAC1C,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,WAAW,CAAC,CAAC,CAAC,CAEhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"conciseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/conciseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACN,gBAAgB,EAChB,cAAc,GAGd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAwB3D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAChC,MAAmB,EACnB,UAAgC,EAChC,OAAsB;IAEtB,MAAM,MAAM,GAA4B;QACvC,aAAa,EAAE,KAAK;QACpB,GAAG,OAAO;KACV,CAAC;IAEF,MAAM,SAAS,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;IAC1D,OAAO,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,sBAAsB,CAC9B,MAAmB,EACnB,OAAgC,EAChC,MAA2C;IAE3C,OAAO,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAC1E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAiB,EACjB,QAA4B;IAE5B,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAmB,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nimport type { ITreeCursor } from \"../../core/index.js\";\nimport type { TreeLeafValue, ImplicitAllowedTypes } from \"../schemaTypes.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tcustomFromCursor,\n\treplaceHandles,\n\ttype EncodeOptions,\n\ttype HandleConverter,\n} from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Concise encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is \"concise\" meaning that explicit type information is omitted.\n * If the schema is compatible with {@link ITreeConfigurationOptions.preventAmbiguity},\n * types will be lossless and compatible with {@link TreeAlpha.create} (unless the options are used to customize it).\n *\n * Every {@link TreeNode} is an array or object.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n * @alpha\n */\nexport type ConciseTree<THandle = IFluidHandle> =\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle\n\t| ConciseTree<THandle>[]\n\t| {\n\t\t\t[key: string]: ConciseTree<THandle>;\n\t };\n\n/**\n * Used to read a node cursor as a ConciseTree.\n */\nexport function conciseFromCursor(\n\treader: ITreeCursor,\n\trootSchema: ImplicitAllowedTypes,\n\toptions: EncodeOptions,\n): ConciseTree {\n\tconst config: Required<EncodeOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst schemaMap = getUnhydratedContext(rootSchema).schema;\n\treturn conciseFromCursorInner(reader, config, schemaMap);\n}\n\nfunction conciseFromCursorInner(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): ConciseTree {\n\treturn customFromCursor(reader, options, schema, conciseFromCursorInner);\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks A strongly typed version of {@link replaceHandles}.\n * @alpha\n */\nexport function replaceConciseTreeHandles<T>(\n\ttree: ConciseTree,\n\treplacer: HandleConverter<T>,\n): ConciseTree<T> {\n\treturn replaceHandles(tree, replacer) as ConciseTree<T>;\n}\n"]}
1
+ {"version":3,"file":"conciseTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/conciseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACN,gBAAgB,EAChB,cAAc,GAGd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAwB3D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAChC,MAAmB,EACnB,UAAgC,EAChC,OAA4B;IAE5B,MAAM,MAAM,GAAkC;QAC7C,aAAa,EAAE,KAAK;QACpB,GAAG,OAAO;KACV,CAAC;IAEF,MAAM,SAAS,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;IAC1D,OAAO,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,sBAAsB,CAC9B,MAAmB,EACnB,OAAsC,EACtC,MAA2C;IAE3C,OAAO,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAC1E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAiB,EACjB,QAA4B;IAE5B,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAmB,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nimport type { ITreeCursor } from \"../../core/index.js\";\nimport type { TreeLeafValue, ImplicitAllowedTypes } from \"../schemaTypes.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tcustomFromCursor,\n\treplaceHandles,\n\ttype TreeEncodingOptions,\n\ttype HandleConverter,\n} from \"./customTree.js\";\nimport { getUnhydratedContext } from \"../createContext.js\";\n\n/**\n * Concise encoding of a {@link TreeNode} or {@link TreeLeafValue}.\n * @remarks\n * This is \"concise\" meaning that explicit type information is omitted.\n * If the schema is compatible with {@link ITreeConfigurationOptions.preventAmbiguity},\n * types will be lossless and compatible with {@link TreeAlpha.create} (unless the options are used to customize it).\n *\n * Every {@link TreeNode} is an array or object.\n * Any IFluidHandle values have been replaced by `THandle`.\n * @privateRemarks\n * This can store all possible simple trees,\n * but it can not store all possible trees representable by our internal representations like FlexTree and JsonableTree.\n * @alpha\n */\nexport type ConciseTree<THandle = IFluidHandle> =\n\t| Exclude<TreeLeafValue, IFluidHandle>\n\t| THandle\n\t| ConciseTree<THandle>[]\n\t| {\n\t\t\t[key: string]: ConciseTree<THandle>;\n\t };\n\n/**\n * Used to read a node cursor as a ConciseTree.\n */\nexport function conciseFromCursor(\n\treader: ITreeCursor,\n\trootSchema: ImplicitAllowedTypes,\n\toptions: TreeEncodingOptions,\n): ConciseTree {\n\tconst config: Required<TreeEncodingOptions> = {\n\t\tuseStoredKeys: false,\n\t\t...options,\n\t};\n\n\tconst schemaMap = getUnhydratedContext(rootSchema).schema;\n\treturn conciseFromCursorInner(reader, config, schemaMap);\n}\n\nfunction conciseFromCursorInner(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n): ConciseTree {\n\treturn customFromCursor(reader, options, schema, conciseFromCursorInner);\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks A strongly typed version of {@link replaceHandles}.\n * @alpha\n */\nexport function replaceConciseTreeHandles<T>(\n\ttree: ConciseTree,\n\treplacer: HandleConverter<T>,\n): ConciseTree<T> {\n\treturn replaceHandles(tree, replacer) as ConciseTree<T>;\n}\n"]}
@@ -7,24 +7,19 @@ import { type FieldKey, type ITreeCursor, type TreeNodeSchemaIdentifier, type Tr
7
7
  import type { TreeLeafValue } from "../schemaTypes.js";
8
8
  import { type TreeNodeSchema } from "../core/index.js";
9
9
  /**
10
- * Options for how to encode a tree.
10
+ * Options for how to interpret or encode a tree when schema information is available.
11
11
  * @alpha
12
12
  */
13
- export interface EncodeOptions {
13
+ export interface TreeEncodingOptions {
14
14
  /**
15
- * If true, interpret the input keys of object nodes as stored keys.
16
- * If false, interpret them as property keys.
15
+ * If true, use the stored keys of object nodes.
16
+ * If false, use the property keys.
17
+ * @remarks
18
+ * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.
17
19
  * @defaultValue false.
18
20
  */
19
21
  readonly useStoredKeys?: boolean;
20
22
  }
21
- /**
22
- * Options for how to transcode handles.
23
- * @remarks
24
- * Can be applied using {@link replaceHandles}.
25
- * @alpha
26
- */
27
- export type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;
28
23
  /**
29
24
  * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.
30
25
  */
@@ -54,7 +49,7 @@ export type CustomTreeNode<TChild> = TChild[] | {
54
49
  /**
55
50
  * Builds an {@link CustomTree} from a cursor in Nodes mode.
56
51
  */
57
- export declare function customFromCursor<TChild>(reader: ITreeCursor, options: Required<EncodeOptions>, schema: ReadonlyMap<string, TreeNodeSchema>, childHandler: (reader: ITreeCursor, options: Required<EncodeOptions>, schema: ReadonlyMap<string, TreeNodeSchema>) => TChild): CustomTree<TChild>;
52
+ export declare function customFromCursor<TChild>(reader: ITreeCursor, options: Required<TreeEncodingOptions>, schema: ReadonlyMap<string, TreeNodeSchema>, childHandler: (reader: ITreeCursor, options: Required<TreeEncodingOptions>, schema: ReadonlyMap<string, TreeNodeSchema>) => TChild): CustomTree<TChild>;
58
53
  /**
59
54
  * Builds an {@link CustomTree} from a cursor in Nodes mode.
60
55
  * @remarks
@@ -67,6 +62,13 @@ export declare function customFromCursorStored<TChild>(reader: ITreeCursor, sche
67
62
  * Otherwise returns `undefined`.
68
63
  */
69
64
  export declare function tryStoredSchemaAsArray(schema: TreeNodeStoredSchema): ReadonlySet<string> | undefined;
65
+ /**
66
+ * Options for how to transcode handles.
67
+ * @remarks
68
+ * Can be applied using {@link replaceHandles}.
69
+ * @alpha
70
+ */
71
+ export type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;
70
72
  /**
71
73
  * Clones tree, replacing any handles.
72
74
  * @remarks
@@ -1 +1 @@
1
- {"version":3,"file":"customTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAIpE,OAAO,EAON,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE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AE,KAAK,EAAE,EAAE;QACrD,kDAAkD;QAClD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n} from \"../../core/index.js\";\nimport { cloneWithReplacements } from \"../../util/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\n\n/**\n * Options for how to encode a tree.\n * @alpha\n */\nexport interface EncodeOptions {\n\t/**\n\t * If true, interpret the input keys of object nodes as stored keys.\n\t * If false, interpret them as property keys.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<EncodeOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<EncodeOptions>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(0xb2f /* missing property key */))\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Assumes `schema` corresponds to a simple-tree schema.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n */\nexport function tryStoredSchemaAsArray(\n\tschema: TreeNodeStoredSchema,\n): ReadonlySet<string> | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"file":"customTree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/customTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GAKtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EACN,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AA6CjF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAAmB,EACnB,OAAsC,EACtC,MAA2C,EAC3C,YAIW;IAEX,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAE3F,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,YAAY,CAAC,UAAU,CAAC;QAC7B,KAAK,aAAa,CAAC,UAAU,CAAC;QAC9B,KAA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;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAI,IAAa,EAAE,QAA4B;IAC5E,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrD,kDAAkD;QAClD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,CAAC;aAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tforEachField,\n\tinCursorField,\n\tLeafNodeStoredSchema,\n\tmapCursorField,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype ITreeCursor,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n} from \"../../core/index.js\";\nimport { cloneWithReplacements } from \"../../util/index.js\";\nimport type { TreeLeafValue } from \"../schemaTypes.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isObjectNodeSchema } from \"../objectNodeTypes.js\";\nimport { FieldKinds, valueSchemaAllows } from \"../../feature-libraries/index.js\";\n\n/**\n * Options for how to interpret or encode a tree when schema information is available.\n * @alpha\n */\nexport interface TreeEncodingOptions {\n\t/**\n\t * If true, use the stored keys of object nodes.\n\t * If false, use the property keys.\n\t * @remarks\n\t * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.\n\t * @defaultValue false.\n\t */\n\treadonly useStoredKeys?: boolean;\n}\n\n/**\n * Options for how to interpret a `ConciseTree<TCustom>` without relying on schema.\n */\nexport interface SchemalessParseOptions {\n\t/**\n\t * Converts stored keys into whatever key the tree is using in its encoding.\n\t */\n\tkeyConverter?: {\n\t\tparse(type: string, inputKey: string): FieldKey;\n\t\tencode(type: string, key: FieldKey): string;\n\t};\n}\n\n/**\n * Tree representation with fields as properties and customized handle and child representations.\n */\nexport type CustomTree<TChild> = CustomTreeNode<TChild> | CustomTreeValue;\n\n/**\n * TreeLeafValue except the handle type is customized.\n */\nexport type CustomTreeValue = TreeLeafValue;\n\n/**\n * Tree node representation with fields as properties and customized child representation.\n */\nexport type CustomTreeNode<TChild> = TChild[] | { [key: string]: TChild };\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n */\nexport function customFromCursor<TChild>(\n\treader: ITreeCursor,\n\toptions: Required<TreeEncodingOptions>,\n\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\toptions: Required<TreeEncodingOptions>,\n\t\tschema: ReadonlyMap<string, TreeNodeSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb2e /* missing schema for type in cursor */);\n\n\tswitch (type) {\n\t\tcase numberSchema.identifier:\n\t\tcase booleanSchema.identifier:\n\t\tcase nullSchema.identifier:\n\t\tcase stringSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa50 /* out of schema: missing value */);\n\t\t\tassert(!isFluidHandle(reader.value), 0xa51 /* out of schema: unexpected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tcase handleSchema.identifier:\n\t\t\tassert(reader.value !== undefined, 0xa52 /* out of schema: missing value */);\n\t\t\tassert(isFluidHandle(reader.value), 0xa53 /* out of schema: expected FluidHandle */);\n\t\t\treturn reader.value;\n\t\tdefault: {\n\t\t\tassert(reader.value === undefined, 0xa54 /* out of schema: unexpected value */);\n\t\t\tif (nodeSchema.kind === NodeKind.Array) {\n\t\t\t\tconst fields = inCursorField(reader, EmptyKey, () =>\n\t\t\t\t\tmapCursorField(reader, () => childHandler(reader, options, schema)),\n\t\t\t\t);\n\t\t\t\treturn fields;\n\t\t\t} else {\n\t\t\t\tconst fields: Record<string, TChild> = {};\n\t\t\t\tforEachField(reader, () => {\n\t\t\t\t\tconst children = mapCursorField(reader, () => childHandler(reader, options, schema));\n\t\t\t\t\tif (children.length === 1) {\n\t\t\t\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t\t\t\tconst key =\n\t\t\t\t\t\t\tisObjectNodeSchema(nodeSchema) && !options.useStoredKeys\n\t\t\t\t\t\t\t\t? (nodeSchema.storedKeyToPropertyKey.get(storedKey) ??\n\t\t\t\t\t\t\t\t\tfail(0xb2f /* missing property key */))\n\t\t\t\t\t\t\t\t: storedKey;\n\t\t\t\t\t\t// Length is checked above.\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\tfields[key] = children[0]!;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tassert(children.length === 0, 0xa19 /* invalid children number */);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn fields;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Builds an {@link CustomTree} from a cursor in Nodes mode.\n * @remarks\n * Uses stored keys and stored schema.\n */\nexport function customFromCursorStored<TChild>(\n\treader: ITreeCursor,\n\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\tchildHandler: (\n\t\treader: ITreeCursor,\n\t\tschema: ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t) => TChild,\n): CustomTree<TChild> {\n\tconst type = reader.type;\n\tconst nodeSchema = schema.get(type) ?? fail(0xb30 /* missing schema for type in cursor */);\n\n\tif (nodeSchema instanceof LeafNodeStoredSchema) {\n\t\tassert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);\n\t\treturn reader.value;\n\t}\n\n\tassert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);\n\n\tconst arrayTypes = tryStoredSchemaAsArray(nodeSchema);\n\tif (arrayTypes !== undefined) {\n\t\tconst field = inCursorField(reader, EmptyKey, () =>\n\t\t\tmapCursorField(reader, () => childHandler(reader, schema)),\n\t\t);\n\t\treturn field;\n\t}\n\n\tconst fields: Record<string, TChild> = {};\n\tforEachField(reader, () => {\n\t\tconst children = mapCursorField(reader, () => childHandler(reader, schema));\n\t\tif (children.length === 1) {\n\t\t\tconst storedKey = reader.getFieldKey();\n\t\t\t// Length is checked above.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tfields[storedKey] = children[0]!;\n\t\t} else {\n\t\t\tassert(children.length === 0, 0xa9e /* invalid children number */);\n\t\t}\n\t});\n\treturn fields;\n}\n\n/**\n * Assumes `schema` corresponds to a simple-tree schema.\n * If it is an array schema, returns the allowed types for the array field.\n * Otherwise returns `undefined`.\n */\nexport function tryStoredSchemaAsArray(\n\tschema: TreeNodeStoredSchema,\n): ReadonlySet<string> | undefined {\n\tif (schema instanceof ObjectNodeStoredSchema) {\n\t\tconst empty = schema.getFieldSchema(EmptyKey);\n\t\tif (empty.kind === FieldKinds.sequence.identifier) {\n\t\t\tassert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);\n\t\t\treturn empty.types;\n\t\t}\n\t}\n}\n\n/**\n * Options for how to transcode handles.\n * @remarks\n * Can be applied using {@link replaceHandles}.\n * @alpha\n */\nexport type HandleConverter<TCustom> = (data: IFluidHandle) => TCustom;\n\n/**\n * Clones tree, replacing any handles.\n * @remarks\n * This can be useful converting data containing handles to JSON compatible formats,\n * or just asserting that data does not contain handles.\n *\n * Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer\n * does not have all the necessary context to restore the handles\n * (e.g. if the handles are something insufficiently descriptive,\n * if data referenced by the handle got garbage collected,\n * if the encoded form of the handle can't be differentiated from other data,\n * or the replacer doesn't have access to the correct Fluid container to to restore them from).\n *\n * Code attempting to reverse this replacement may want to use {@link cloneWithReplacements}.\n * @alpha\n */\nexport function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown {\n\treturn cloneWithReplacements(tree, \"\", (key, value) => {\n\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\tif (isFluidHandle(value)) {\n\t\t\treturn { clone: false, value: replacer(value) };\n\t\t} else {\n\t\t\treturn { clone: true, value };\n\t\t}\n\t});\n}\n"]}
@@ -3,7 +3,22 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { JsonTreeSchema } from "./jsonSchema.js";
6
- import type { ImplicitFieldSchema } from "../schemaTypes.js";
6
+ import type { ImplicitAllowedTypes } from "../schemaTypes.js";
7
+ import type { TreeEncodingOptions } from "./customTree.js";
8
+ /**
9
+ * Options for how to interpret or encode a tree when schema information is available.
10
+ * @alpha
11
+ */
12
+ export interface TreeSchemaEncodingOptions extends TreeEncodingOptions {
13
+ /**
14
+ * If true, fields with default providers (like {@link SchemaFactory.identifier}) will be required.
15
+ * If false, they will be optional.
16
+ * @remarks
17
+ * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.
18
+ * @defaultValue false.
19
+ */
20
+ readonly requireFieldsWithDefaults?: boolean;
21
+ }
7
22
  /**
8
23
  * Creates a {@link https://json-schema.org/ | JSON Schema} representation of the provided {@link TreeNodeSchema}.
9
24
  *
@@ -52,14 +67,13 @@ import type { ImplicitFieldSchema } from "../schemaTypes.js";
52
67
  * TODO:
53
68
  * This API should allow generating JSON schema for the whole matrix of combinations:
54
69
  *
55
- * 1. VerboseTree and ConciseTree
56
- * 2. With and without requiring values with defaults (for insertion vs reading)
57
- * 3. Using stored keys and property keys
58
- *
59
- * This current API seems to give ConciseTree with property keys and ignoring default values.
70
+ * 1. VerboseTree and (Done) ConciseTree
71
+ * 2. (Done) With and without requiring values with defaults (for insertion vs reading)
72
+ * 3. (Done) Using stored keys and property keys.
60
73
  *
74
+ * This takes in `ImplicitAllowedTypes` since underlying `toJsonSchema` can't handle optional roots.
61
75
  *
62
76
  * @alpha
63
77
  */
64
- export declare function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema;
78
+ export declare function getJsonSchema(schema: ImplicitAllowedTypes, options: Required<TreeSchemaEncodingOptions>): JsonTreeSchema;
65
79
  //# sourceMappingURL=getJsonSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAW7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,cAAc,CAKzE"}
1
+ {"version":3,"file":"getJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACrE;;;;;;OAMG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC1C,cAAc,CAGhB"}
@@ -3,12 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { toJsonSchema } from "./simpleSchemaToJsonSchema.js";
6
- import { getSimpleSchema } from "./getSimpleSchema.js";
7
- import { getOrCreate } from "../../util/index.js";
8
- /**
9
- * Cache in which the results of {@link getJsonSchema} are saved.
10
- */
11
- const jsonSchemaCache = new WeakMap();
6
+ import { TreeViewConfigurationAlpha } from "./tree.js";
12
7
  /**
13
8
  * Creates a {@link https://json-schema.org/ | JSON Schema} representation of the provided {@link TreeNodeSchema}.
14
9
  *
@@ -57,19 +52,16 @@ const jsonSchemaCache = new WeakMap();
57
52
  * TODO:
58
53
  * This API should allow generating JSON schema for the whole matrix of combinations:
59
54
  *
60
- * 1. VerboseTree and ConciseTree
61
- * 2. With and without requiring values with defaults (for insertion vs reading)
62
- * 3. Using stored keys and property keys
63
- *
64
- * This current API seems to give ConciseTree with property keys and ignoring default values.
55
+ * 1. VerboseTree and (Done) ConciseTree
56
+ * 2. (Done) With and without requiring values with defaults (for insertion vs reading)
57
+ * 3. (Done) Using stored keys and property keys.
65
58
  *
59
+ * This takes in `ImplicitAllowedTypes` since underlying `toJsonSchema` can't handle optional roots.
66
60
  *
67
61
  * @alpha
68
62
  */
69
- export function getJsonSchema(schema) {
70
- return getOrCreate(jsonSchemaCache, schema, () => {
71
- const simpleSchema = getSimpleSchema(schema);
72
- return toJsonSchema(simpleSchema);
73
- });
63
+ export function getJsonSchema(schema, options) {
64
+ const treeSchema = new TreeViewConfigurationAlpha({ schema });
65
+ return toJsonSchema(treeSchema, options);
74
66
  }
75
67
  //# sourceMappingURL=getJsonSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,aAAa,CAAC,MAA2B;IACxD,OAAO,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE;QAChD,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { JsonTreeSchema } from \"./jsonSchema.js\";\nimport type { ImplicitFieldSchema } from \"../schemaTypes.js\";\nimport { toJsonSchema } from \"./simpleSchemaToJsonSchema.js\";\nimport { getSimpleSchema } from \"./getSimpleSchema.js\";\nimport { getOrCreate } from \"../../util/index.js\";\nimport type { TreeNodeSchema } from \"../core/index.js\";\n\n/**\n * Cache in which the results of {@link getJsonSchema} are saved.\n */\nconst jsonSchemaCache = new WeakMap<TreeNodeSchema, JsonTreeSchema>();\n\n/**\n * Creates a {@link https://json-schema.org/ | JSON Schema} representation of the provided {@link TreeNodeSchema}.\n *\n * @remarks\n * Useful when communicating the schema to external libraries or services.\n * Caches the result for future calls.\n *\n * @example\n *\n * A Shared Tree schema like the following:\n *\n * ```typescript\n * class MyObject extends schemaFactory.object(\"MyObject\", {\n * \tfoo: schemaFactory.number,\n * \tbar: schemaFactory.optional(schemaFactory.string),\n * });\n * ```\n *\n * Will yield JSON Schema like the following:\n *\n * ```json\n * {\n * \t\"$defs\": {\n * \t\t\"com.fluidframework.leaf.string\": {\n * \t\t\t\"type\": \"string\",\n * \t\t},\n * \t\t\"com.fluidframework.leaf.number\": {\n * \t\t\t\"type\": \"number\",\n * \t\t},\n * \t\t\"com.myapp.MyObject\": {\n * \t\t\t\"type\": \"object\",\n * \t\t\t\"properties\": {\n * \t\t\t\t\"foo\": { \"$ref\": \"com.fluidframework.leaf.number\" },\n * \t\t\t\t\"bar\": { \"$ref\": \"com.fluidframework.leaf.string\" },\n * \t\t\t},\n * \t\t\t\"required\": [\"foo\"],\n * \t\t},\n * \t},\n * \t\"$ref\": \"#/$defs/com.myapp.MyObject\",\n * }\n * ```\n *\n * @privateRemarks 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 * TODO:\n * This API should allow generating JSON schema for the whole matrix of combinations:\n *\n * 1. VerboseTree and ConciseTree\n * 2. With and without requiring values with defaults (for insertion vs reading)\n * 3. Using stored keys and property keys\n *\n * This current API seems to give ConciseTree with property keys and ignoring default values.\n *\n *\n * @alpha\n */\nexport function getJsonSchema(schema: ImplicitFieldSchema): JsonTreeSchema {\n\treturn getOrCreate(jsonSchemaCache, schema, () => {\n\t\tconst simpleSchema = getSimpleSchema(schema);\n\t\treturn toJsonSchema(simpleSchema);\n\t});\n}\n"]}
1
+ {"version":3,"file":"getJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/getJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAiBvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,UAAU,aAAa,CAC5B,MAA4B,EAC5B,OAA4C;IAE5C,MAAM,UAAU,GAAG,IAAI,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { JsonTreeSchema } from \"./jsonSchema.js\";\nimport type { ImplicitAllowedTypes } from \"../schemaTypes.js\";\nimport { toJsonSchema } from \"./simpleSchemaToJsonSchema.js\";\nimport type { TreeEncodingOptions } from \"./customTree.js\";\nimport { TreeViewConfigurationAlpha } from \"./tree.js\";\n\n/**\n * Options for how to interpret or encode a tree when schema information is available.\n * @alpha\n */\nexport interface TreeSchemaEncodingOptions extends TreeEncodingOptions {\n\t/**\n\t * If true, fields with default providers (like {@link SchemaFactory.identifier}) will be required.\n\t * If false, they will be optional.\n\t * @remarks\n\t * Has no effect on {@link NodeKind}s other than {@link NodeKind.Object}.\n\t * @defaultValue false.\n\t */\n\treadonly requireFieldsWithDefaults?: boolean;\n}\n\n/**\n * Creates a {@link https://json-schema.org/ | JSON Schema} representation of the provided {@link TreeNodeSchema}.\n *\n * @remarks\n * Useful when communicating the schema to external libraries or services.\n * Caches the result for future calls.\n *\n * @example\n *\n * A Shared Tree schema like the following:\n *\n * ```typescript\n * class MyObject extends schemaFactory.object(\"MyObject\", {\n * \tfoo: schemaFactory.number,\n * \tbar: schemaFactory.optional(schemaFactory.string),\n * });\n * ```\n *\n * Will yield JSON Schema like the following:\n *\n * ```json\n * {\n * \t\"$defs\": {\n * \t\t\"com.fluidframework.leaf.string\": {\n * \t\t\t\"type\": \"string\",\n * \t\t},\n * \t\t\"com.fluidframework.leaf.number\": {\n * \t\t\t\"type\": \"number\",\n * \t\t},\n * \t\t\"com.myapp.MyObject\": {\n * \t\t\t\"type\": \"object\",\n * \t\t\t\"properties\": {\n * \t\t\t\t\"foo\": { \"$ref\": \"com.fluidframework.leaf.number\" },\n * \t\t\t\t\"bar\": { \"$ref\": \"com.fluidframework.leaf.string\" },\n * \t\t\t},\n * \t\t\t\"required\": [\"foo\"],\n * \t\t},\n * \t},\n * \t\"$ref\": \"#/$defs/com.myapp.MyObject\",\n * }\n * ```\n *\n * @privateRemarks 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 * TODO:\n * This API should allow generating JSON schema for the whole matrix of combinations:\n *\n * 1. VerboseTree and (Done) ConciseTree\n * 2. (Done) With and without requiring values with defaults (for insertion vs reading)\n * 3. (Done) Using stored keys and property keys.\n *\n * This takes in `ImplicitAllowedTypes` since underlying `toJsonSchema` can't handle optional roots.\n *\n * @alpha\n */\nexport function getJsonSchema(\n\tschema: ImplicitAllowedTypes,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonTreeSchema {\n\tconst treeSchema = new TreeViewConfigurationAlpha({ schema });\n\treturn toJsonSchema(treeSchema, options);\n}\n"]}
@@ -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;;;GAGG;AAEH,OAAO,EACN,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,eAAe,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,aAAa,GAClB,MAAM,oBAAo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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,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;AAgB3F,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,EAIN,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\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,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;;;;;;GAQG;AACH,qBAAa,kBAAkB,CAC9B,GAAG,CAAC,MAAM,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EAC1D,KAAK,SAAS,MAAM,GAAG,M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,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,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAC5B,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACa,MAAM,CAKrB,IAAU,EACV,MAAS,EACT,OAAqD;QAErD,OAAO,YAAY,CAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAClB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,0BAA0B;YAClC,iCAAiC,CAAC,0BAA0B,EAC7D,OAAO,EAAE,QAAQ,CACjB,CAAC;IACH,CAAC;IAED;;OAEG;IACa,eAAe,CAK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G;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,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AAC,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