@fluidframework/tree 2.33.1 → 2.40.0-336023

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 (315) hide show
  1. package/.vscode/settings.json +2 -0
  2. package/api-report/tree.alpha.api.md +120 -50
  3. package/api-report/tree.beta.api.md +31 -27
  4. package/api-report/tree.legacy.alpha.api.md +24 -23
  5. package/api-report/tree.legacy.public.api.md +24 -23
  6. package/api-report/tree.public.api.md +24 -23
  7. package/dist/alpha.d.ts +16 -1
  8. package/dist/beta.d.ts +2 -0
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/internalTypes.d.ts +0 -1
  13. package/dist/internalTypes.d.ts.map +1 -1
  14. package/dist/internalTypes.js.map +1 -1
  15. package/dist/jsonDomainSchema.d.ts +2 -2
  16. package/dist/jsonDomainSchema.js +2 -2
  17. package/dist/jsonDomainSchema.js.map +1 -1
  18. package/dist/legacy.d.ts +2 -0
  19. package/dist/packageVersion.d.ts +1 -1
  20. package/dist/packageVersion.d.ts.map +1 -1
  21. package/dist/packageVersion.js +1 -1
  22. package/dist/packageVersion.js.map +1 -1
  23. package/dist/public.d.ts +2 -0
  24. package/dist/serializableDomainSchema.d.ts +3 -3
  25. package/dist/serializableDomainSchema.js +2 -2
  26. package/dist/serializableDomainSchema.js.map +1 -1
  27. package/dist/shared-tree/independentView.d.ts +1 -1
  28. package/dist/shared-tree/independentView.js.map +1 -1
  29. package/dist/shared-tree/index.d.ts +3 -2
  30. package/dist/shared-tree/index.d.ts.map +1 -1
  31. package/dist/shared-tree/index.js +4 -4
  32. package/dist/shared-tree/index.js.map +1 -1
  33. package/dist/shared-tree/schematizeTree.d.ts +4 -4
  34. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  35. package/dist/shared-tree/schematizeTree.js +2 -3
  36. package/dist/shared-tree/schematizeTree.js.map +1 -1
  37. package/dist/shared-tree/schematizingTreeView.d.ts +3 -3
  38. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  39. package/dist/shared-tree/schematizingTreeView.js +4 -4
  40. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  41. package/dist/shared-tree/{treeApi.d.ts → tree.d.ts} +34 -34
  42. package/dist/shared-tree/tree.d.ts.map +1 -0
  43. package/dist/shared-tree/{treeApi.js → tree.js} +6 -6
  44. package/dist/shared-tree/tree.js.map +1 -0
  45. package/dist/shared-tree/{treeApiAlpha.d.ts → treeAlpha.d.ts} +22 -14
  46. package/dist/shared-tree/treeAlpha.d.ts.map +1 -0
  47. package/dist/shared-tree/{treeApiAlpha.js → treeAlpha.js} +4 -3
  48. package/dist/shared-tree/treeAlpha.js.map +1 -0
  49. package/dist/simple-tree/api/conciseTree.d.ts +1 -1
  50. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  51. package/dist/simple-tree/api/configuration.d.ts +177 -0
  52. package/dist/simple-tree/api/configuration.d.ts.map +1 -0
  53. package/dist/simple-tree/api/configuration.js +163 -0
  54. package/dist/simple-tree/api/configuration.js.map +1 -0
  55. package/dist/simple-tree/api/getJsonSchema.js +2 -2
  56. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  57. package/dist/simple-tree/api/index.d.ts +7 -4
  58. package/dist/simple-tree/api/index.d.ts.map +1 -1
  59. package/dist/simple-tree/api/index.js +8 -7
  60. package/dist/simple-tree/api/index.js.map +1 -1
  61. package/dist/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  62. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  63. package/dist/simple-tree/api/{view.js → schemaCompatibilityTester.js} +9 -9
  64. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  65. package/dist/simple-tree/api/schemaFactory.d.ts +16 -10
  66. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  67. package/dist/simple-tree/api/schemaFactory.js +20 -12
  68. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  69. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  70. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  71. package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
  72. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  73. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  74. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  75. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  76. package/dist/simple-tree/api/schemaFromSimple.d.ts +1 -1
  77. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  78. package/dist/simple-tree/api/schemaFromSimple.js +1 -1
  79. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  80. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  81. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  82. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  83. package/dist/simple-tree/api/storedSchema.d.ts +3 -3
  84. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  85. package/dist/simple-tree/api/storedSchema.js +3 -2
  86. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  87. package/dist/simple-tree/api/tree.d.ts +5 -174
  88. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  89. package/dist/simple-tree/api/tree.js +1 -156
  90. package/dist/simple-tree/api/tree.js.map +1 -1
  91. package/{lib/simple-tree/api/treeApiBeta.d.ts → dist/simple-tree/api/treeBeta.d.ts} +13 -5
  92. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -0
  93. package/dist/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  94. package/dist/simple-tree/api/treeBeta.js.map +1 -0
  95. package/dist/simple-tree/api/typesUnsafe.d.ts +4 -9
  96. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  97. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  98. package/dist/simple-tree/arrayNode.d.ts +2 -2
  99. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  100. package/dist/simple-tree/arrayNode.js +3 -2
  101. package/dist/simple-tree/arrayNode.js.map +1 -1
  102. package/dist/simple-tree/arrayNodeTypes.d.ts +3 -3
  103. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  104. package/dist/simple-tree/arrayNodeTypes.js.map +1 -1
  105. package/dist/simple-tree/index.d.ts +3 -3
  106. package/dist/simple-tree/index.d.ts.map +1 -1
  107. package/dist/simple-tree/index.js +2 -2
  108. package/dist/simple-tree/index.js.map +1 -1
  109. package/dist/simple-tree/mapNode.d.ts +2 -2
  110. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  111. package/dist/simple-tree/mapNode.js +1 -1
  112. package/dist/simple-tree/mapNode.js.map +1 -1
  113. package/dist/simple-tree/mapNodeTypes.d.ts +3 -3
  114. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -1
  115. package/dist/simple-tree/mapNodeTypes.js.map +1 -1
  116. package/dist/simple-tree/objectNode.d.ts +18 -5
  117. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  118. package/dist/simple-tree/objectNode.js +4 -3
  119. package/dist/simple-tree/objectNode.js.map +1 -1
  120. package/dist/simple-tree/objectNodeTypes.d.ts +4 -4
  121. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  122. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  123. package/dist/simple-tree/schemaTypes.d.ts +163 -13
  124. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  125. package/dist/simple-tree/schemaTypes.js +107 -8
  126. package/dist/simple-tree/schemaTypes.js.map +1 -1
  127. package/dist/simple-tree/treeNodeValid.js +2 -2
  128. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  129. package/dist/tableSchema.d.ts +197 -86
  130. package/dist/tableSchema.d.ts.map +1 -1
  131. package/dist/tableSchema.js +100 -45
  132. package/dist/tableSchema.js.map +1 -1
  133. package/dist/util/typeUtils.d.ts +1 -1
  134. package/dist/util/typeUtils.js.map +1 -1
  135. package/lib/alpha.d.ts +16 -1
  136. package/lib/beta.d.ts +2 -0
  137. package/lib/index.d.ts +2 -2
  138. package/lib/index.d.ts.map +1 -1
  139. package/lib/index.js.map +1 -1
  140. package/lib/internalTypes.d.ts +0 -1
  141. package/lib/internalTypes.d.ts.map +1 -1
  142. package/lib/internalTypes.js.map +1 -1
  143. package/lib/jsonDomainSchema.d.ts +2 -2
  144. package/lib/jsonDomainSchema.js +2 -2
  145. package/lib/jsonDomainSchema.js.map +1 -1
  146. package/lib/legacy.d.ts +2 -0
  147. package/lib/packageVersion.d.ts +1 -1
  148. package/lib/packageVersion.d.ts.map +1 -1
  149. package/lib/packageVersion.js +1 -1
  150. package/lib/packageVersion.js.map +1 -1
  151. package/lib/public.d.ts +2 -0
  152. package/lib/serializableDomainSchema.d.ts +3 -3
  153. package/lib/serializableDomainSchema.js +2 -2
  154. package/lib/serializableDomainSchema.js.map +1 -1
  155. package/lib/shared-tree/independentView.d.ts +1 -1
  156. package/lib/shared-tree/independentView.js.map +1 -1
  157. package/lib/shared-tree/index.d.ts +3 -2
  158. package/lib/shared-tree/index.d.ts.map +1 -1
  159. package/lib/shared-tree/index.js +2 -2
  160. package/lib/shared-tree/index.js.map +1 -1
  161. package/lib/shared-tree/schematizeTree.d.ts +4 -4
  162. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  163. package/lib/shared-tree/schematizeTree.js +2 -3
  164. package/lib/shared-tree/schematizeTree.js.map +1 -1
  165. package/lib/shared-tree/schematizingTreeView.d.ts +3 -3
  166. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  167. package/lib/shared-tree/schematizingTreeView.js +5 -5
  168. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  169. package/lib/shared-tree/{treeApi.d.ts → tree.d.ts} +34 -34
  170. package/lib/shared-tree/tree.d.ts.map +1 -0
  171. package/lib/shared-tree/{treeApi.js → tree.js} +5 -5
  172. package/lib/shared-tree/tree.js.map +1 -0
  173. package/lib/shared-tree/{treeApiAlpha.d.ts → treeAlpha.d.ts} +22 -14
  174. package/lib/shared-tree/treeAlpha.d.ts.map +1 -0
  175. package/lib/shared-tree/{treeApiAlpha.js → treeAlpha.js} +4 -3
  176. package/lib/shared-tree/treeAlpha.js.map +1 -0
  177. package/lib/simple-tree/api/conciseTree.d.ts +1 -1
  178. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  179. package/lib/simple-tree/api/configuration.d.ts +177 -0
  180. package/lib/simple-tree/api/configuration.d.ts.map +1 -0
  181. package/lib/simple-tree/api/configuration.js +157 -0
  182. package/lib/simple-tree/api/configuration.js.map +1 -0
  183. package/lib/simple-tree/api/getJsonSchema.js +1 -1
  184. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  185. package/lib/simple-tree/api/index.d.ts +7 -4
  186. package/lib/simple-tree/api/index.d.ts.map +1 -1
  187. package/lib/simple-tree/api/index.js +4 -3
  188. package/lib/simple-tree/api/index.js.map +1 -1
  189. package/lib/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  190. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  191. package/lib/simple-tree/api/{view.js → schemaCompatibilityTester.js} +7 -7
  192. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  193. package/lib/simple-tree/api/schemaFactory.d.ts +16 -10
  194. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  195. package/lib/simple-tree/api/schemaFactory.js +20 -12
  196. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  197. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  198. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  199. package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
  200. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  201. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  202. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  203. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  204. package/lib/simple-tree/api/schemaFromSimple.d.ts +1 -1
  205. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  206. package/lib/simple-tree/api/schemaFromSimple.js +1 -1
  207. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  208. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  209. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  210. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  211. package/lib/simple-tree/api/storedSchema.d.ts +3 -3
  212. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  213. package/lib/simple-tree/api/storedSchema.js +3 -2
  214. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  215. package/lib/simple-tree/api/tree.d.ts +5 -174
  216. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  217. package/lib/simple-tree/api/tree.js +0 -152
  218. package/lib/simple-tree/api/tree.js.map +1 -1
  219. package/{dist/simple-tree/api/treeApiBeta.d.ts → lib/simple-tree/api/treeBeta.d.ts} +13 -5
  220. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -0
  221. package/lib/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  222. package/lib/simple-tree/api/treeBeta.js.map +1 -0
  223. package/lib/simple-tree/api/typesUnsafe.d.ts +4 -9
  224. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  225. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  226. package/lib/simple-tree/arrayNode.d.ts +2 -2
  227. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  228. package/lib/simple-tree/arrayNode.js +4 -3
  229. package/lib/simple-tree/arrayNode.js.map +1 -1
  230. package/lib/simple-tree/arrayNodeTypes.d.ts +3 -3
  231. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  232. package/lib/simple-tree/arrayNodeTypes.js.map +1 -1
  233. package/lib/simple-tree/index.d.ts +3 -3
  234. package/lib/simple-tree/index.d.ts.map +1 -1
  235. package/lib/simple-tree/index.js +1 -1
  236. package/lib/simple-tree/index.js.map +1 -1
  237. package/lib/simple-tree/mapNode.d.ts +2 -2
  238. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  239. package/lib/simple-tree/mapNode.js +2 -2
  240. package/lib/simple-tree/mapNode.js.map +1 -1
  241. package/lib/simple-tree/mapNodeTypes.d.ts +3 -3
  242. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -1
  243. package/lib/simple-tree/mapNodeTypes.js.map +1 -1
  244. package/lib/simple-tree/objectNode.d.ts +18 -5
  245. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  246. package/lib/simple-tree/objectNode.js +5 -4
  247. package/lib/simple-tree/objectNode.js.map +1 -1
  248. package/lib/simple-tree/objectNodeTypes.d.ts +4 -4
  249. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  250. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  251. package/lib/simple-tree/schemaTypes.d.ts +163 -13
  252. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  253. package/lib/simple-tree/schemaTypes.js +96 -8
  254. package/lib/simple-tree/schemaTypes.js.map +1 -1
  255. package/lib/simple-tree/treeNodeValid.js +2 -2
  256. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  257. package/lib/tableSchema.d.ts +197 -86
  258. package/lib/tableSchema.d.ts.map +1 -1
  259. package/lib/tableSchema.js +100 -45
  260. package/lib/tableSchema.js.map +1 -1
  261. package/lib/util/typeUtils.d.ts +1 -1
  262. package/lib/util/typeUtils.js.map +1 -1
  263. package/package.json +20 -20
  264. package/src/index.ts +17 -1
  265. package/src/internalTypes.ts +0 -2
  266. package/src/jsonDomainSchema.ts +2 -2
  267. package/src/packageVersion.ts +1 -1
  268. package/src/serializableDomainSchema.ts +3 -3
  269. package/src/shared-tree/independentView.ts +1 -1
  270. package/src/shared-tree/index.ts +3 -6
  271. package/src/shared-tree/schematizeTree.ts +5 -5
  272. package/src/shared-tree/schematizingTreeView.ts +11 -8
  273. package/src/shared-tree/{treeApi.ts → tree.ts} +51 -51
  274. package/src/shared-tree/{treeApiAlpha.ts → treeAlpha.ts} +22 -13
  275. package/src/simple-tree/api/conciseTree.ts +1 -1
  276. package/src/simple-tree/api/configuration.ts +353 -0
  277. package/src/simple-tree/api/getJsonSchema.ts +1 -1
  278. package/src/simple-tree/api/index.ts +21 -15
  279. package/src/simple-tree/api/{view.ts → schemaCompatibilityTester.ts} +8 -15
  280. package/src/simple-tree/api/schemaFactory.ts +130 -19
  281. package/src/simple-tree/api/schemaFactoryAlpha.ts +7 -5
  282. package/src/simple-tree/api/schemaFactoryRecursive.ts +102 -38
  283. package/src/simple-tree/api/schemaFromSimple.ts +2 -2
  284. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  285. package/src/simple-tree/api/storedSchema.ts +8 -4
  286. package/src/simple-tree/api/tree.ts +13 -354
  287. package/src/simple-tree/api/{treeApiBeta.ts → treeBeta.ts} +17 -5
  288. package/src/simple-tree/api/typesUnsafe.ts +15 -11
  289. package/src/simple-tree/arrayNode.ts +10 -5
  290. package/src/simple-tree/arrayNodeTypes.ts +8 -7
  291. package/src/simple-tree/index.ts +17 -1
  292. package/src/simple-tree/mapNode.ts +11 -3
  293. package/src/simple-tree/mapNodeTypes.ts +10 -7
  294. package/src/simple-tree/objectNode.ts +39 -15
  295. package/src/simple-tree/objectNodeTypes.ts +9 -5
  296. package/src/simple-tree/schemaTypes.ts +353 -25
  297. package/src/simple-tree/treeNodeValid.ts +2 -2
  298. package/src/tableSchema.ts +749 -445
  299. package/src/util/typeUtils.ts +1 -1
  300. package/dist/shared-tree/treeApi.d.ts.map +0 -1
  301. package/dist/shared-tree/treeApi.js.map +0 -1
  302. package/dist/shared-tree/treeApiAlpha.d.ts.map +0 -1
  303. package/dist/shared-tree/treeApiAlpha.js.map +0 -1
  304. package/dist/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  305. package/dist/simple-tree/api/treeApiBeta.js.map +0 -1
  306. package/dist/simple-tree/api/view.d.ts.map +0 -1
  307. package/dist/simple-tree/api/view.js.map +0 -1
  308. package/lib/shared-tree/treeApi.d.ts.map +0 -1
  309. package/lib/shared-tree/treeApi.js.map +0 -1
  310. package/lib/shared-tree/treeApiAlpha.d.ts.map +0 -1
  311. package/lib/shared-tree/treeApiAlpha.js.map +0 -1
  312. package/lib/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  313. package/lib/simple-tree/api/treeApiBeta.js.map +0 -1
  314. package/lib/simple-tree/api/view.d.ts.map +0 -1
  315. package/lib/simple-tree/api/view.js.map +0 -1
@@ -4,48 +4,61 @@
4
4
  */
5
5
  import { oob } from "@fluidframework/core-utils/internal";
6
6
  import { Tree } from "./shared-tree/index.js";
7
- import { TreeArrayNode, } from "./simple-tree/index.js";
7
+ import { TreeArrayNode, SchemaFactory, } from "./simple-tree/index.js";
8
8
  // Future improvement TODOs (ideally to be done before promoting these APIs to `@alpha`):
9
- // - Custom fields on Table/Row/Column (props pattern from Nick's demo)
10
- // - Overloads to make Column/Row schema optional when constructing Tables
11
9
  // - Record-like type parameters / input parameters?
12
- // - Move `@system` types into separate / sub scope?
10
+ // - Omit `props` properties from Row and Column schemas when not provided?
11
+ const tableSchemaFactorySubScope = "table";
13
12
  /**
14
- * Contains types and factories for creating schema to represent dynamic tabular data.
15
- * @privateRemarks TODO: document in more detail and add `@example`s.
16
- * @internal
13
+ * Not intended for use outside of this package.
14
+ *
15
+ * @privateRemarks
16
+ * This namespace is a collection of internal system types relate to {@link TableSchema}.
17
+ * This namespace should be strictly type-exported by the package.
18
+ * All members should be tagged with `@system`.
19
+ *
20
+ * @system @internal
17
21
  */
18
- export var TableSchema;
19
- (function (TableSchema) {
20
- const tableSchemaFactorySubScope = "table";
22
+ export var System_TableSchema;
23
+ (function (System_TableSchema) {
21
24
  /**
22
25
  * Factory for creating new table column schema.
23
- * @privateRemarks
24
- * TODO:
25
- * - Add overloads to make propsSchema optional.
26
- * - Take field schema rather than node schema for `propsSchema`, in particular to allow making
27
- * the additional properties optional.
28
- * @internal
26
+ * @system @internal
29
27
  */
30
28
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
31
- function createColumn(inputSchemaFactory, propsSchema) {
29
+ function createColumnInternal(inputSchemaFactory, propsSchema) {
32
30
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
31
+ // Note: `columnFields` is broken into two parts to work around a TypeScript bug
32
+ // that results in broken `.d.ts` output.
33
+ // See definition of `ColumnInsertableType` below.
34
+ const columnFieldsBuiltInParts = {
35
+ id: schemaFactory.identifier,
36
+ };
37
+ const columnFieldsPropsPart = {
38
+ props: propsSchema,
39
+ };
33
40
  /**
34
41
  * {@link Column} fields.
35
- * @remarks Extracted for re-use in returned type signature defined later in this function.
42
+ *
43
+ * @remarks
44
+ * Extracted for re-use in returned type signature defined later in this function.
36
45
  * The implicit typing is intentional.
46
+ *
37
47
  * Note: ideally we would add a satisfies clause here to ensure that this satisfies
38
48
  * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
39
49
  * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
40
50
  */
41
51
  const columnFields = {
42
- id: schemaFactory.identifier,
43
- props: schemaFactory.required(propsSchema),
44
- };
52
+ ...columnFieldsBuiltInParts,
53
+ ...columnFieldsPropsPart,
54
+ }; // satisfies Record<string, ImplicitFieldSchema>;
45
55
  /**
46
56
  * A column in a table.
47
57
  */
48
- class Column extends schemaFactory.object("Column", columnFields) {
58
+ class Column extends schemaFactory.objectAlpha("Column", columnFields, {
59
+ // Will make it easier to evolve this schema in the future.
60
+ allowUnknownOptionalFields: true,
61
+ }) {
49
62
  }
50
63
  // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
51
64
  // for the private brand field of TreeNode.
@@ -55,21 +68,29 @@ export var TableSchema;
55
68
  const ColumnSchemaType = Column;
56
69
  return ColumnSchemaType;
57
70
  }
58
- TableSchema.createColumn = createColumn;
71
+ System_TableSchema.createColumnInternal = createColumnInternal;
59
72
  /**
60
73
  * Factory for creating new table row schema.
61
74
  *
62
- * @privateRemarks
63
- * TODO:
64
- * - Add overloads to make propsSchema optional.
65
- * - Take field schema rather than node schema for `propsSchema`, in particular to allow making
66
- * the additional properties optional.
67
- *
68
75
  * @sealed @internal
69
76
  */
70
77
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
71
- function createRow(inputSchemaFactory, cellSchema, propsSchema) {
78
+ function createRowInternal(inputSchemaFactory, cellSchema, propsSchema) {
72
79
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
80
+ // Note: `rowFields` is broken into two parts to work around a TypeScript bug
81
+ // that results in broken `.d.ts` output.
82
+ // See definition of `RowInsertableType` below.
83
+ const rowFieldsBuiltInParts = {
84
+ id: schemaFactory.identifier,
85
+ cells: schemaFactory.required(schemaFactory.map("Row.cells", cellSchema), {
86
+ metadata: {
87
+ description: "The cells of the table row, keyed by column ID.",
88
+ },
89
+ }),
90
+ };
91
+ const rowFieldsPropsPart = {
92
+ props: propsSchema,
93
+ };
73
94
  /**
74
95
  * {@link Row} fields.
75
96
  * @remarks Extracted for re-use in returned type signature defined later in this function.
@@ -79,14 +100,16 @@ export var TableSchema;
79
100
  * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
80
101
  */
81
102
  const rowFields = {
82
- id: schemaFactory.identifier,
83
- cells: schemaFactory.map("Row.cells", cellSchema),
84
- props: schemaFactory.required(propsSchema),
85
- };
103
+ ...rowFieldsBuiltInParts,
104
+ ...rowFieldsPropsPart,
105
+ }; // satisfies Record<string, ImplicitFieldSchema>;
86
106
  /**
87
107
  * The Row schema - this is a map of Cells where the key is the column id
88
108
  */
89
- class Row extends schemaFactory.object("Row", rowFields) {
109
+ class Row extends schemaFactory.objectAlpha("Row", rowFields, {
110
+ // Will make it easier to evolve this schema in the future.
111
+ allowUnknownOptionalFields: true,
112
+ }) {
90
113
  getCell(columnOrId) {
91
114
  const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
92
115
  return this.cells.get(columnId);
@@ -111,14 +134,7 @@ export var TableSchema;
111
134
  const RowSchemaType = Row;
112
135
  return RowSchemaType;
113
136
  }
114
- TableSchema.createRow = createRow;
115
- /** `createTable` implementation */
116
- function createTable(inputSchemaFactory, _cellSchema, columnSchema, rowSchema) {
117
- const column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);
118
- return createTableInternal(inputSchemaFactory, _cellSchema, column, rowSchema ??
119
- createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null));
120
- }
121
- TableSchema.createTable = createTable;
137
+ System_TableSchema.createRowInternal = createRowInternal;
122
138
  /**
123
139
  * Factory for creating new table schema.
124
140
  * @system @internal
@@ -138,7 +154,10 @@ export var TableSchema;
138
154
  /**
139
155
  * The Table schema
140
156
  */
141
- class Table extends schemaFactory.object("Table", tableFields) {
157
+ class Table extends schemaFactory.objectAlpha("Table", tableFields, {
158
+ // Will make it easier to evolve this schema in the future.
159
+ allowUnknownOptionalFields: true,
160
+ }) {
142
161
  getColumn(id) {
143
162
  // TypeScript is unable to narrow the types correctly here, hence the casts.
144
163
  // See: https://github.com/microsoft/TypeScript/issues/52144
@@ -254,7 +273,43 @@ export var TableSchema;
254
273
  // Return the table schema
255
274
  return TableSchemaType;
256
275
  }
257
- TableSchema.createTableInternal = createTableInternal;
276
+ System_TableSchema.createTableInternal = createTableInternal;
277
+ // #endregion
278
+ })(System_TableSchema || (System_TableSchema = {}));
279
+ /**
280
+ * Contains types and factories for creating schema to represent dynamic tabular data.
281
+ * @privateRemarks TODO: document in more detail and add `@example`s.
282
+ * @internal
283
+ */
284
+ export var TableSchema;
285
+ (function (TableSchema) {
286
+ // #region Column
287
+ /**
288
+ * Overload implementation
289
+ */
290
+ function createColumn({ schemaFactory, props = SchemaFactory.optional(SchemaFactory.null), }) {
291
+ return System_TableSchema.createColumnInternal(schemaFactory, props);
292
+ }
293
+ TableSchema.createColumn = createColumn;
294
+ /**
295
+ * Overload implementation
296
+ */
297
+ function createRow({ schemaFactory, cell, props = SchemaFactory.optional(SchemaFactory.null), }) {
298
+ return System_TableSchema.createRowInternal(schemaFactory, cell, props);
299
+ }
300
+ TableSchema.createRow = createRow;
301
+ /**
302
+ * Overload implementation
303
+ */
304
+ function createTable({ schemaFactory, cell, column = createColumn({
305
+ schemaFactory,
306
+ }), row = createRow({
307
+ schemaFactory,
308
+ cell,
309
+ }), }) {
310
+ return System_TableSchema.createTableInternal(schemaFactory, cell, column, row);
311
+ }
312
+ TableSchema.createTable = createTable;
258
313
  // #endregion
259
314
  })(TableSchema || (TableSchema = {}));
260
315
  //# sourceMappingURL=tableSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tableSchema.js","sourceRoot":"","sources":["../src/tableSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAQN,aAAa,GAMb,MAAM,wBAAwB,CAAC;AAEhC,yFAAyF;AACzF,uEAAuE;AACvE,0EAA0E;AAC1E,oDAAoD;AACpD,oDAAoD;AAEpD;;;;GAIG;AACH,MAAM,KAAW,WAAW,CA4rB3B;AA5rBD,WAAiB,WAAW;IAC3B,MAAM,0BAA0B,GAAG,OAAO,CAAC;IAuB3C;;;;;;;;OAQG;IACH,sIAAsI;IACtI,SAAgB,YAAY,CAG1B,kBAAmD,EAAE,WAAyB;QAC/E,MAAM,aAAa,GAAG,kBAAkB,CAAC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IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;oBACvB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;oBACxC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;wBAC1B,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAC3B,CAAC;gBACF,CAAC;YACF,CAAC;SACD;QAOD,8IAA8I;QAC9I,2CAA2C;QAC3C,yHAAyH;QACzH,iDAAiD;QACjD,qFAAqF;QACrF,MAAM,eAAe,GAOjB,KAAK,CAAC;QAEV,0BAA0B;QAC1B,OAAO,eAAe,CAAC;IACxB,CAAC;IAlMe,+BAAmB,sBAkMlC,CAAA;IAoBD,aAAa;AACd,CAAC,EA5rBgB,WAAW,KAAX,WAAW,QA4rB3B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { Tree } from \"./shared-tree/index.js\";\nimport {\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype NodeKind,\n\ttype SchemaFactoryAlpha,\n\ttype ScopedSchemaName,\n\tTreeArrayNode,\n\ttype TreeNode,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n} from \"./simple-tree/index.js\";\n\n// Future improvement TODOs (ideally to be done before promoting these APIs to `@alpha`):\n// - Custom fields on Table/Row/Column (props pattern from Nick's demo)\n// - Overloads to make Column/Row schema optional when constructing Tables\n// - Record-like type parameters / input parameters?\n// - Move `@system` types into separate / sub scope?\n\n/**\n * Contains types and factories for creating schema to represent dynamic tabular data.\n * @privateRemarks TODO: document in more detail and add `@example`s.\n * @internal\n */\nexport namespace TableSchema {\n\tconst tableSchemaFactorySubScope = \"table\";\n\n\t// #region Column\n\n\t/**\n\t * A column in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.createColumn}.\n\t * @sealed @internal\n\t */\n\texport interface IColumn<TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> {\n\t\t/**\n\t\t * The unique identifier of the column.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\n\t\t/**\n\t\t * User-provided column properties.\n\t\t */\n\t\tget props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;\n\t\tset props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);\n\t}\n\n\t/**\n\t * Factory for creating new table column schema.\n\t * @privateRemarks\n\t * TODO:\n\t * - Add overloads to make propsSchema optional.\n\t * - Take field schema rather than node schema for `propsSchema`, in particular to allow making\n\t * the additional properties optional.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createColumn<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TPropsSchema extends ImplicitAllowedTypes,\n\t>(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\t/**\n\t\t * {@link Column} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t * Note: ideally we would add a satisfies clause here to ensure that this satisfies\n\t\t * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.\n\t\t * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394\n\t\t */\n\t\tconst columnFields = {\n\t\t\tid: schemaFactory.identifier,\n\t\t\tprops: schemaFactory.required(propsSchema),\n\t\t} as const;\n\n\t\t/**\n\t\t * A column in a table.\n\t\t */\n\t\tclass Column extends schemaFactory.object(\"Column\", columnFields) {}\n\n\t\ttype ColumnValueType = TreeNode &\n\t\t\tIColumn<TPropsSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Column\">>;\n\n\t\ttype ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst ColumnSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Column\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ ColumnValueType,\n\t\t\t/* TInsertable */ object & ColumnInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof columnFields\n\t\t> = Column;\n\n\t\treturn ColumnSchemaType;\n\t}\n\n\t/**\n\t * Base column schema type.\n\t * @sealed @system @internal\n\t */\n\texport type ColumnSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTPropsSchema extends ImplicitAllowedTypes,\n\t> = ReturnType<typeof createColumn<TScope, TPropsSchema>>;\n\n\t// #endregion\n\n\t// #region Row\n\n\t/**\n\t * A row in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.createRow}.\n\t * @sealed @internal\n\t */\n\texport interface IRow<\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * The unique identifier of the row.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\n\t\t/**\n\t\t * Gets the cell in the specified column.\n\t\t * @returns The cell if it exists, otherwise undefined.\n\t\t */\n\t\tgetCell(column: IColumn): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\t\t/**\n\t\t * Gets the cell in the specified column, denoted by column ID.\n\t\t * @returns The cell if it exists, otherwise undefined.\n\t\t */\n\t\tgetCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\n\t\t/**\n\t\t * Sets the cell in the specified column.\n\t\t * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:1)} instead.\n\t\t */\n\t\tsetCell(\n\t\t\tcolumn: IColumn,\n\t\t\tvalue: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,\n\t\t): void;\n\t\t/**\n\t\t * Sets the cell in the specified column, denoted by column ID.\n\t\t * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:2)} instead.\n\t\t */\n\t\tsetCell(\n\t\t\tcolumnId: string,\n\t\t\tvalue: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,\n\t\t): void;\n\n\t\t/**\n\t\t * Removes the cell in the specified column.\n\t\t * @privateRemarks TODO: return removed cell\n\t\t */\n\t\tremoveCell(column: IColumn): void;\n\t\t/**\n\t\t * Removes the cell in the specified column, denoted by column ID.\n\t\t * @privateRemarks TODO: return removed cell\n\t\t */\n\t\tremoveCell(columnId: string): void;\n\n\t\t/**\n\t\t * User-provided row properties.\n\t\t */\n\t\tget props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;\n\t\tset props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);\n\t}\n\n\t/**\n\t * Factory for creating new table row schema.\n\t *\n\t * @privateRemarks\n\t * TODO:\n\t * - Add overloads to make propsSchema optional.\n\t * - Take field schema rather than node schema for `propsSchema`, in particular to allow making\n\t * the additional properties optional.\n\t *\n\t * @sealed @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createRow<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCellSchema extends ImplicitAllowedTypes,\n\t\tconst TPropsSchema extends ImplicitAllowedTypes,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\tcellSchema: TCellSchema,\n\t\tpropsSchema: TPropsSchema,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\n\t\t/**\n\t\t * {@link Row} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t * Note: ideally we would add a satisfies clause here to ensure that this satisfies\n\t\t * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.\n\t\t * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394\n\t\t */\n\t\tconst rowFields = {\n\t\t\tid: schemaFactory.identifier,\n\t\t\tcells: schemaFactory.map(\"Row.cells\", cellSchema),\n\t\t\tprops: schemaFactory.required(propsSchema),\n\t\t} as const;\n\n\t\t/**\n\t\t * The Row schema - this is a map of Cells where the key is the column id\n\t\t */\n\t\tclass Row\n\t\t\textends schemaFactory.object(\"Row\", rowFields)\n\t\t\timplements IRow<TCellSchema, TPropsSchema>\n\t\t{\n\t\t\tpublic getCell(columnOrId: IColumn | string): CellValueType | undefined {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\treturn this.cells.get(columnId) as CellValueType | undefined;\n\t\t\t}\n\n\t\t\tpublic setCell(\n\t\t\t\tcolumnOrId: IColumn | string,\n\t\t\t\tvalue: CellInsertableType | undefined,\n\t\t\t): void {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\tthis.cells.set(columnId, value);\n\t\t\t}\n\n\t\t\tpublic removeCell(columnOrId: IColumn | string): void {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\tif (!this.cells.has(columnId)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.cells.delete(columnId);\n\t\t\t}\n\t\t}\n\n\t\ttype RowValueType = TreeNode &\n\t\t\tIRow<TCellSchema, TPropsSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Row\">>;\n\t\ttype RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst RowSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Row\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ RowValueType,\n\t\t\t/* TInsertable */ object & RowInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof rowFields\n\t\t> = Row;\n\n\t\treturn RowSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type RowSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTPropsSchema extends ImplicitAllowedTypes,\n\t> = ReturnType<typeof createRow<TScope, TCellSchema, TPropsSchema>>;\n\n\t// #endregion\n\n\t// #region Table\n\n\t/**\n\t * A key to uniquely identify a cell in a table.\n\t * @sealed @internal\n\t */\n\texport interface CellKey {\n\t\t/**\n\t\t * {@link TableSchema.IColumn.id} of the containing {@link TableSchema.IColumn}.\n\t\t */\n\t\treadonly columnId: string;\n\n\t\t/**\n\t\t * {@link TableSchema.IRow.id} of the containing {@link TableSchema.IRow}.\n\t\t */\n\t\treadonly rowId: string;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertColumn} parameters.\n\t * @sealed @internal\n\t */\n\texport interface InsertColumnParameters<TInsertableColumn> {\n\t\t/**\n\t\t * The index at which to insert the new column.\n\t\t * @remarks If not provided, the column will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The column to insert.\n\t\t */\n\t\treadonly column: TInsertableColumn;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertRows} parameters.\n\t * @sealed @internal\n\t */\n\texport interface InsertRowsParameters<TInsertableRow> {\n\t\t/**\n\t\t * The index at which to insert the new rows.\n\t\t * @remarks If not provided, the rows will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The rows to insert.\n\t\t */\n\t\treadonly rows: TInsertableRow[];\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.setCell} parameters.\n\t * @sealed @internal\n\t */\n\texport interface SetCellParameters<TInsertableCell> {\n\t\t/**\n\t\t * The key to uniquely identify a cell in a table.\n\t\t */\n\t\treadonly key: CellKey;\n\n\t\t/**\n\t\t * The cell to set.\n\t\t */\n\t\treadonly cell: TInsertableCell;\n\t}\n\n\t/**\n\t * A table.\n\t * @sealed @internal\n\t */\n\texport interface ITable<\n\t\tTCellSchema extends ImplicitAllowedTypes,\n\t\tTColumnSchema extends ImplicitAllowedTypes,\n\t\tTRowSchema extends ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * The table's columns.\n\t\t */\n\t\treadonly columns: TreeArrayNode<TColumnSchema>;\n\n\t\t/**\n\t\t * The table's rows.\n\t\t */\n\t\treadonly rows: TreeArrayNode<TRowSchema>;\n\n\t\t/**\n\t\t * Gets a table column by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumnSchema> | undefined;\n\n\t\t/**\n\t\t * Gets a table row by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetRow(id: string): TreeNodeFromImplicitAllowedTypes<TRowSchema> | undefined;\n\n\t\t/**\n\t\t * Gets a cell in the table by column and row IDs.\n\t\t * @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.\n\t\t * @privateRemarks TODO: add overload that takes row and column nodes.\n\t\t */\n\t\tgetCell(key: CellKey): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;\n\n\t\t/**\n\t\t * Inserts a column into the table.\n\t\t * @throws Throws an error if the column is already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertColumn(\n\t\t\tparams: InsertColumnParameters<\n\t\t\t\tInsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>\n\t\t\t>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TColumnSchema>;\n\n\t\t/**\n\t\t * Inserts 0 or more rows into the table.\n\t\t * @throws Throws an error if any of the rows are already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertRows(\n\t\t\tparams: InsertRowsParameters<InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TRowSchema>[];\n\n\t\t/**\n\t\t * Sets the cell at the specified location in the table.\n\t\t * @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tsetCell(\n\t\t\tparams: SetCellParameters<InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Removes the specified column from the table.\n\t\t * @remarks Note: this does not remove any cells from the table's rows.\n\t\t * @privateRemarks\n\t\t * TODO:\n\t\t * - Policy for when the column is not in the table.\n\t\t * - Actually remove corresponding cells from table rows.\n\t\t */\n\t\tremoveColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;\n\n\t\t/**\n\t\t * Removes 0 or more rows from the table.\n\t\t * @privateRemarks TODO: policy for when 1 or more rows are not in the table.\n\t\t */\n\t\tremoveRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;\n\n\t\t/**\n\t\t * Removes all rows from the table.\n\t\t */\n\t\tremoveAllRows: () => void;\n\n\t\t/**\n\t\t * Removes the cell at the specified location in the table.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tremoveCell: (key: CellKey) => void;\n\t}\n\n\t/**\n\t * Factory for creating new table schema without specifying row or column schema.\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t): ReturnType<typeof createTableInternal<TInputScope, TCell>>;\n\t/**\n\t * Factory for creating new table schema without specifying row schema\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema: TColumn,\n\t): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn>>;\n\t/**\n\t * Factory for creating new table schema.\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t\tconst TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema: TColumn,\n\t\trowSchema: TRow,\n\t): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn, TRow>>;\n\t/** `createTable` implementation */\n\texport function createTable<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t\tconst TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema?: TColumn,\n\t\trowSchema?: TRow,\n\t): TreeNodeSchema {\n\t\tconst column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);\n\t\treturn createTableInternal(\n\t\t\tinputSchemaFactory,\n\t\t\t_cellSchema,\n\t\t\tcolumn as TColumn,\n\t\t\trowSchema ??\n\t\t\t\t(createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null) as TRow),\n\t\t);\n\t}\n\n\t/**\n\t * Factory for creating new table schema.\n\t * @system @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createTableInternal<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends ColumnSchemaBase<\n\t\t\tTInputScope,\n\t\t\tImplicitAllowedTypes\n\t\t> = ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,\n\t\tconst TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<\n\t\t\tTInputScope,\n\t\t\tTCell,\n\t\t\tImplicitAllowedTypes\n\t\t>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCell,\n\t\tcolumnSchema: TColumn,\n\t\trowSchema: TRow,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCell>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCell>;\n\n\t\ttype ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumn>;\n\t\ttype ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumn>;\n\n\t\ttype RowValueType = TreeNodeFromImplicitAllowedTypes<TRow>;\n\t\ttype RowInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TRow>;\n\n\t\t/**\n\t\t * {@link Table} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t */\n\t\tconst tableFields = {\n\t\t\trows: schemaFactory.array(\"Table.rows\", rowSchema),\n\t\t\tcolumns: schemaFactory.array(\"Table.columns\", columnSchema),\n\t\t} as const satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * The Table schema\n\t\t */\n\t\tclass Table\n\t\t\textends schemaFactory.object(\"Table\", tableFields)\n\t\t\timplements ITable<TCell, TColumn, TRow>\n\t\t{\n\t\t\tpublic getColumn(id: string): ColumnValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.columns.find((column) => (column as ColumnValueType).id === id) as\n\t\t\t\t\t| ColumnValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getRow(id: string): RowValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.rows.find((_row) => (_row as RowValueType).id === id) as\n\t\t\t\t\t| RowValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getCell(key: CellKey): CellValueType | undefined {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\treturn row.getCell(column.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If the cell does not exist return undefined\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tpublic insertColumn({\n\t\t\t\tcolumn,\n\t\t\t\tindex,\n\t\t\t}: InsertColumnParameters<ColumnInsertableType>): ColumnValueType {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAtEnd(column as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAt(index, column as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input node into the tree hydrates it, making it usable as a node.\n\t\t\t\treturn column as ColumnValueType;\n\t\t\t}\n\n\t\t\tpublic insertRows({\n\t\t\t\tindex,\n\t\t\t\trows,\n\t\t\t}: InsertRowsParameters<RowInsertableType>): RowValueType[] {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAtEnd(TreeArrayNode.spread(rows) as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAt(index, TreeArrayNode.spread(rows) as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input nodes into the tree hydrates them, making them usable as nodes.\n\t\t\t\treturn rows as unknown as RowValueType[];\n\t\t\t}\n\n\t\t\tpublic setCell({ key, cell }: SetCellParameters<CellInsertableType>): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.setCell(column.id, cell);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpublic removeColumn(column: ColumnValueType): void {\n\t\t\t\tconst index = this.columns.indexOf(column);\n\t\t\t\t// If the column is not in the table, do nothing\n\t\t\t\tif (index === -1) return;\n\t\t\t\tthis.columns.removeAt(index);\n\t\t\t}\n\n\t\t\tpublic removeRows(rows: readonly RowValueType[]): void {\n\t\t\t\t// If there are no rows to remove, do nothing\n\t\t\t\tif (rows.length === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If there is only one row to remove, remove it\n\t\t\t\tif (rows.length === 1) {\n\t\t\t\t\tconst index = this.rows.indexOf(rows[0] ?? oob());\n\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// If there are multiple rows to remove, remove them in a transaction\n\t\t\t\t// This is to avoid the performance issues of deleting multiple rows at once\n\t\t\t\tTree.runTransaction(this, () => {\n\t\t\t\t\t// Iterate over the rows and remove them\n\t\t\t\t\tfor (const row of rows) {\n\t\t\t\t\t\tconst index = this.rows.indexOf(row);\n\t\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic removeAllRows(): void {\n\t\t\t\tthis.rows.removeRange();\n\t\t\t}\n\n\t\t\tpublic removeCell(key: CellKey): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.removeCell(column.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttype TableValueType = TreeNode &\n\t\t\tITable<TCell, TColumn, TRow> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Table\">>;\n\t\ttype TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst TableSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Table\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ TableValueType,\n\t\t\t/* TInsertable */ object & TableInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof tableFields\n\t\t> = Table;\n\n\t\t// Return the table schema\n\t\treturn TableSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type TableSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTCell extends ImplicitAllowedTypes,\n\t\tTColumn extends ColumnSchemaBase<TScope, ImplicitAllowedTypes> = ColumnSchemaBase<\n\t\t\tTScope,\n\t\t\tImplicitAllowedTypes\n\t\t>,\n\t\tTRow extends RowSchemaBase<TScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<\n\t\t\tTScope,\n\t\t\tTCell,\n\t\t\tImplicitAllowedTypes\n\t\t>,\n\t> = ReturnType<typeof createTable<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C,EA9jBgB,kBAAkB,KAAlB,kBAAkB,QA8jBlC;AAED;;;;GAIG;AACH,MAAM,KAAW,WAAW,CAyZ3B;AAzZD,WAAiB,WAAW;IAC3B,iBAAiB;IAyDjB;;OAEG;IACH,SAAgB,YAAY,CAAC,EAC5B,aAAa,EACb,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,GAGlD;QACA,OAAO,kBAAkB,CAAC,oBAAoB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAPe,wBAAY,eAO3B,CAAA;IAsGD;;OAEG;IACH,SAAgB,SAAS,CAAC,EACzB,aAAa,EACb,IAAI,EACJ,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,GAGlD;QACA,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;IARe,qBAAS,YAQxB,CAAA;IA+MD;;OAEG;IACH,SAAgB,WAAW,CAAC,EAC3B,aAAa,EACb,IAAI,EACJ,MAAM,GAAG,YAAY,CAAC;QACrB,aAAa;KACb,CAAC,EACF,GAAG,GAAG,SAAS,CAAC;QACf,aAAa;QACb,IAAI;KACJ,CAAC,GAIF;QACA,OAAO,kBAAkB,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACjF,CAAC;IAfe,uBAAW,cAe1B,CAAA;IAED,aAAa;AACd,CAAC,EAzZgB,WAAW,KAAX,WAAW,QAyZ3B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { oob } from \"@fluidframework/core-utils/internal\";\n\nimport { Tree } from \"./shared-tree/index.js\";\nimport {\n\ttype FieldHasDefault,\n\ttype ImplicitAllowedTypes,\n\ttype ImplicitFieldSchema,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype NodeKind,\n\ttype SchemaFactoryAlpha,\n\ttype ScopedSchemaName,\n\tTreeArrayNode,\n\ttype TreeNode,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype TreeNodeSchema,\n\ttype TreeNodeSchemaClass,\n\ttype WithType,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype InternalTreeNode,\n\ttype FieldSchema,\n\ttype FieldKind,\n\tSchemaFactory,\n\ttype ImplicitAnnotatedFieldSchema,\n\ttype UnannotateImplicitFieldSchema,\n} from \"./simple-tree/index.js\";\n\n// Future improvement TODOs (ideally to be done before promoting these APIs to `@alpha`):\n// - Record-like type parameters / input parameters?\n// - Omit `props` properties from Row and Column schemas when not provided?\n\nconst tableSchemaFactorySubScope = \"table\";\n\n/**\n * Not intended for use outside of this package.\n *\n * @privateRemarks\n * This namespace is a collection of internal system types relate to {@link TableSchema}.\n * This namespace should be strictly type-exported by the package.\n * All members should be tagged with `@system`.\n *\n * @system @internal\n */\nexport namespace System_TableSchema {\n\t/**\n\t * A base interface for factory input options which include an schema factory.\n\t * @remarks This interface should not be referenced directly.\n\t * @privateRemarks This interface primarily exists to provide a single home for property documentation.\n\t * @system @internal\n\t */\n\texport interface OptionsWithSchemaFactory<\n\t\tTScope extends string | undefined = string | undefined,\n\t> {\n\t\t/**\n\t\t * Schema factory with which the Column schema will be associated.\n\t\t * @remarks Can be used to associate the resulting schema with an existing {@link SchemaFactory.scope|scope}.\n\t\t */\n\t\treadonly schemaFactory: SchemaFactoryAlpha<TScope>;\n\t}\n\n\t/**\n\t * A base interface for factory input options which include the table cell schema.\n\t * @remarks This interface should not be referenced directly.\n\t * @privateRemarks This interface primarily exists to provide a single home for property documentation.\n\t * @system @internal\n\t */\n\texport interface OptionsWithCellSchema<\n\t\tTCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * Schema for the table's cells.\n\t\t */\n\t\treadonly cell: TCellSchema;\n\t}\n\n\t// #region Column\n\n\t/**\n\t * Base options for creating table cow schema.\n\t * @remarks Includes parameters common to all column factory overloads.\n\t * @system @internal\n\t */\n\texport type CreateColumnOptionsBase<\n\t\tTInputScope extends string | undefined = string | undefined,\n\t> = OptionsWithSchemaFactory<TInputScope>;\n\n\t/**\n\t * Factory for creating new table column schema.\n\t * @system @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createColumnInternal<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TPropsSchema extends ImplicitAnnotatedFieldSchema,\n\t>(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\t// Note: `columnFields` is broken into two parts to work around a TypeScript bug\n\t\t// that results in broken `.d.ts` output.\n\t\t// See definition of `ColumnInsertableType` below.\n\t\tconst columnFieldsBuiltInParts = {\n\t\t\tid: schemaFactory.identifier,\n\t\t} as const;\n\t\tconst columnFieldsPropsPart = {\n\t\t\tprops: propsSchema,\n\t\t} as const;\n\n\t\t/**\n\t\t * {@link Column} fields.\n\t\t *\n\t\t * @remarks\n\t\t * Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t *\n\t\t * Note: ideally we would add a satisfies clause here to ensure that this satisfies\n\t\t * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.\n\t\t * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394\n\t\t */\n\t\tconst columnFields = {\n\t\t\t...columnFieldsBuiltInParts,\n\t\t\t...columnFieldsPropsPart,\n\t\t} as const; // satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * A column in a table.\n\t\t */\n\t\tclass Column\n\t\t\textends schemaFactory.objectAlpha(\"Column\", columnFields, {\n\t\t\t\t// Will make it easier to evolve this schema in the future.\n\t\t\t\tallowUnknownOptionalFields: true,\n\t\t\t})\n\t\t\timplements TableSchema.IColumn<TPropsSchema> {}\n\n\t\ttype ColumnValueType = TreeNode &\n\t\t\tTableSchema.IColumn<TPropsSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Column\">>;\n\n\t\t// Note: ideally this type would just leverage `InsertableObjectFromSchemaRecord<typeof columnFields>`,\n\t\t// but that results in broken `.d.ts` output due to a TypeScript bug.\n\t\t// See: https://github.com/microsoft/TypeScript/issues/58688.\n\t\t// Instead we extract and inline the typing of the \"props\" field here, which seems to sufficiently work around the issue.\n\t\t// type ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;\n\t\ttype ColumnInsertableType = InsertableObjectFromSchemaRecord<\n\t\t\ttypeof columnFieldsBuiltInParts\n\t\t> &\n\t\t\t(FieldHasDefault<UnannotateImplicitFieldSchema<TPropsSchema>> extends true\n\t\t\t\t? // Note: The docs on the below properties are copied from `IRow.props`' docs to ensure that the\n\t\t\t\t\t// documentation appears in the data insertion scenario.\n\t\t\t\t\t// The contents are duplicated instead of using `@inheritdoc`, as intellisense does not correctly\n\t\t\t\t\t// support `@inheritDoc`.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/31267\n\t\t\t\t\t{\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The column's properties.\n\t\t\t\t\t\t * @remarks This is a user-defined schema that can be used to store additional information about the column.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tprops?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\t\t\tUnannotateImplicitFieldSchema<TPropsSchema>\n\t\t\t\t\t\t>;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The column's properties.\n\t\t\t\t\t\t * @remarks This is a user-defined schema that can be used to store additional information about the column.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tprops: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\t\t\tUnannotateImplicitFieldSchema<TPropsSchema>\n\t\t\t\t\t\t>;\n\t\t\t\t\t});\n\n\t\t// Modified version of `Column` that ensures the constructor (and `createFromInsertable`) are\n\t\t// typed correctly in terms of our insertable type.\n\t\t// This lets us be selective in our type-cast for the value returned from this function,\n\t\t// preserving as much type-safety as we reasonably can.\n\t\ttype ColumnSchemaModifiedType = Omit<\n\t\t\t// Use mapped type to omit the constructor\n\t\t\t{\n\t\t\t\t[Property in keyof typeof Column]: (typeof Column)[Property];\n\t\t\t},\n\t\t\t\"createFromInsertable\"\n\t\t> &\n\t\t\t(new (\n\t\t\t\tparameters: InternalTreeNode | ColumnInsertableType,\n\t\t\t) => Column) & {\n\t\t\t\tcreateFromInsertable(parameters: ColumnInsertableType): Column;\n\t\t\t};\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst ColumnSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Column\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ ColumnValueType,\n\t\t\t/* TInsertable */ object & ColumnInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof columnFields\n\t\t> = Column as ColumnSchemaModifiedType;\n\n\t\treturn ColumnSchemaType;\n\t}\n\n\t/**\n\t * Base column schema type.\n\t * @sealed @system @internal\n\t */\n\texport type ColumnSchemaBase<\n\t\tTScope extends string | undefined = string | undefined,\n\t\tTPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t> = ReturnType<typeof TableSchema.createColumn<TScope, TPropsSchema>>;\n\n\t// #endregion\n\n\t// #region Row\n\n\t/**\n\t * Base options for creating table row schema.\n\t * @remarks Includes parameters common to all row factory overloads.\n\t * @system @internal\n\t */\n\texport type CreateRowOptionsBase<\n\t\tTScope extends string | undefined = string | undefined,\n\t\tTCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t> = OptionsWithSchemaFactory<TScope> & OptionsWithCellSchema<TCell>;\n\n\t/**\n\t * Factory for creating new table row schema.\n\t *\n\t * @sealed @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createRowInternal<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCellSchema extends ImplicitAllowedTypes,\n\t\tconst TPropsSchema extends ImplicitFieldSchema,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\tcellSchema: TCellSchema,\n\t\tpropsSchema: TPropsSchema,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\n\t\t// Note: `rowFields` is broken into two parts to work around a TypeScript bug\n\t\t// that results in broken `.d.ts` output.\n\t\t// See definition of `RowInsertableType` below.\n\t\tconst rowFieldsBuiltInParts = {\n\t\t\tid: schemaFactory.identifier,\n\t\t\tcells: schemaFactory.required(schemaFactory.map(\"Row.cells\", cellSchema), {\n\t\t\t\tmetadata: {\n\t\t\t\t\tdescription: \"The cells of the table row, keyed by column ID.\",\n\t\t\t\t},\n\t\t\t}),\n\t\t} as const;\n\t\tconst rowFieldsPropsPart = {\n\t\t\tprops: propsSchema,\n\t\t} as const;\n\n\t\t/**\n\t\t * {@link Row} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t * Note: ideally we would add a satisfies clause here to ensure that this satisfies\n\t\t * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.\n\t\t * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394\n\t\t */\n\t\tconst rowFields = {\n\t\t\t...rowFieldsBuiltInParts,\n\t\t\t...rowFieldsPropsPart,\n\t\t} as const; // satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * The Row schema - this is a map of Cells where the key is the column id\n\t\t */\n\t\tclass Row\n\t\t\textends schemaFactory.objectAlpha(\"Row\", rowFields, {\n\t\t\t\t// Will make it easier to evolve this schema in the future.\n\t\t\t\tallowUnknownOptionalFields: true,\n\t\t\t})\n\t\t\timplements TableSchema.IRow<TCellSchema, TPropsSchema>\n\t\t{\n\t\t\tpublic getCell(columnOrId: TableSchema.IColumn | string): CellValueType | undefined {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\treturn this.cells.get(columnId) as CellValueType | undefined;\n\t\t\t}\n\n\t\t\tpublic setCell(\n\t\t\t\tcolumnOrId: TableSchema.IColumn | string,\n\t\t\t\tvalue: CellInsertableType | undefined,\n\t\t\t): void {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\tthis.cells.set(columnId, value);\n\t\t\t}\n\n\t\t\tpublic removeCell(columnOrId: TableSchema.IColumn | string): void {\n\t\t\t\tconst columnId = typeof columnOrId === \"string\" ? columnOrId : columnOrId.id;\n\t\t\t\tif (!this.cells.has(columnId)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.cells.delete(columnId);\n\t\t\t}\n\t\t}\n\n\t\ttype RowValueType = TreeNode &\n\t\t\tTableSchema.IRow<TCellSchema, TPropsSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Row\">>;\n\n\t\t// Note: ideally this type would just leverage `InsertableObjectFromSchemaRecord<typeof rowFields>`,\n\t\t// but that results in broken `.d.ts` output due to a TypeScript bug.\n\t\t// See: https://github.com/microsoft/TypeScript/issues/58688.\n\t\t// Instead we extract and inline the typing of the \"props\" field here, which seems to sufficiently work around\n\t\t// the issue.\n\t\t// type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;\n\t\ttype RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFieldsBuiltInParts> &\n\t\t\t(FieldHasDefault<TPropsSchema> extends true\n\t\t\t\t? // Note: The docs on the below properties are copied from `IRow.props`' docs to ensure that the\n\t\t\t\t\t// documentation appears in the data insertion scenario.\n\t\t\t\t\t// The contents are duplicated instead of using `@inheritdoc`, as intellisense does not correctly\n\t\t\t\t\t// support `@inheritDoc`.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/31267\n\t\t\t\t\t{\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The row's properties.\n\t\t\t\t\t\t * @remarks This is a user-defined schema that can be used to store additional information\n\t\t\t\t\t\t * about the row.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tprops?: InsertableTreeFieldFromImplicitField<TPropsSchema>;\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The row's properties.\n\t\t\t\t\t\t * @remarks This is a user-defined schema that can be used to store additional information\n\t\t\t\t\t\t * about the row.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tprops: InsertableTreeFieldFromImplicitField<TPropsSchema>;\n\t\t\t\t\t});\n\n\t\t// Modified version of `Column` that ensures the constructor (and `createFromInsertable`) are\n\t\t// typed correctly in terms of our insertable type.\n\t\t// This lets us be selective in our type-cast for the value returned from this function,\n\t\t// preserving as much type-safety as we reasonably can.\n\t\ttype RowSchemaModifiedType = Omit<\n\t\t\t// Use mapped type to omit the constructor\n\t\t\t{\n\t\t\t\t[Property in keyof typeof Row]: (typeof Row)[Property];\n\t\t\t},\n\t\t\t\"createFromInsertable\"\n\t\t> &\n\t\t\t(new (\n\t\t\t\tparameters: InternalTreeNode | RowInsertableType,\n\t\t\t) => Row) & {\n\t\t\t\tcreateFromInsertable(parameters: RowInsertableType): Row;\n\t\t\t};\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst RowSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Row\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ RowValueType,\n\t\t\t/* TInsertable */ object & RowInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof rowFields\n\t\t> = Row as RowSchemaModifiedType;\n\n\t\treturn RowSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type RowSchemaBase<\n\t\tTScope extends string | undefined = string | undefined,\n\t\tTCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t\tTPropsSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t> = ReturnType<typeof TableSchema.createRow<TScope, TCellSchema, TPropsSchema>>;\n\n\t// #endregion\n\n\t// #region Table\n\n\t/**\n\t * Base options for creating table schema.\n\t * @remarks Includes parameters common to all table factory overloads.\n\t * @system @internal\n\t */\n\texport type TableFactoryOptionsBase<\n\t\tTScope extends string | undefined = string | undefined,\n\t\tTCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,\n\t> = OptionsWithSchemaFactory<TScope> & OptionsWithCellSchema<TCell>;\n\n\t/**\n\t * Factory for creating new table schema.\n\t * @system @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify\n\texport function createTableInternal<\n\t\tconst TInputScope extends string | undefined,\n\t\tconst TCellSchema extends ImplicitAllowedTypes,\n\t\tconst TColumnSchema extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,\n\t\tconst TRowSchema extends RowSchemaBase<TInputScope, TCellSchema> = RowSchemaBase<\n\t\t\tTInputScope,\n\t\t\tTCellSchema\n\t\t>,\n\t>(\n\t\tinputSchemaFactory: SchemaFactoryAlpha<TInputScope>,\n\t\t_cellSchema: TCellSchema,\n\t\tcolumnSchema: TColumnSchema,\n\t\trowSchema: TRowSchema,\n\t) {\n\t\tconst schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);\n\t\ttype Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;\n\n\t\ttype CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\t\ttype CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;\n\n\t\ttype ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;\n\t\ttype ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>;\n\n\t\ttype RowValueType = TreeNodeFromImplicitAllowedTypes<TRowSchema>;\n\t\ttype RowInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>;\n\n\t\t/**\n\t\t * {@link Table} fields.\n\t\t * @remarks Extracted for re-use in returned type signature defined later in this function.\n\t\t * The implicit typing is intentional.\n\t\t */\n\t\tconst tableFields = {\n\t\t\trows: schemaFactory.array(\"Table.rows\", rowSchema),\n\t\t\tcolumns: schemaFactory.array(\"Table.columns\", columnSchema),\n\t\t} as const satisfies Record<string, ImplicitFieldSchema>;\n\n\t\t/**\n\t\t * The Table schema\n\t\t */\n\t\tclass Table\n\t\t\textends schemaFactory.objectAlpha(\"Table\", tableFields, {\n\t\t\t\t// Will make it easier to evolve this schema in the future.\n\t\t\t\tallowUnknownOptionalFields: true,\n\t\t\t})\n\t\t\timplements TableSchema.ITable<TCellSchema, TColumnSchema, TRowSchema>\n\t\t{\n\t\t\tpublic getColumn(id: string): ColumnValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.columns.find((column) => (column as ColumnValueType).id === id) as\n\t\t\t\t\t| ColumnValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getRow(id: string): RowValueType | undefined {\n\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the casts.\n\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\treturn this.rows.find((_row) => (_row as RowValueType).id === id) as\n\t\t\t\t\t| RowValueType\n\t\t\t\t\t| undefined;\n\t\t\t}\n\n\t\t\tpublic getCell(key: TableSchema.CellKey): CellValueType | undefined {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\treturn row.getCell(column.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If the cell does not exist return undefined\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tpublic insertColumn({\n\t\t\t\tcolumn,\n\t\t\t\tindex,\n\t\t\t}: TableSchema.InsertColumnParameters<ColumnInsertableType>): ColumnValueType {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAtEnd(column as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.columns.insertAt(index, column as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input node into the tree hydrates it, making it usable as a node.\n\t\t\t\treturn column as ColumnValueType;\n\t\t\t}\n\n\t\t\tpublic insertRows({\n\t\t\t\tindex,\n\t\t\t\trows,\n\t\t\t}: TableSchema.InsertRowsParameters<RowInsertableType>): RowValueType[] {\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAtEnd(TreeArrayNode.spread(rows) as any);\n\t\t\t\t} else {\n\t\t\t\t\t// TypeScript is unable to narrow the types correctly here, hence the cast.\n\t\t\t\t\t// See: https://github.com/microsoft/TypeScript/issues/52144\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\tthis.rows.insertAt(index, TreeArrayNode.spread(rows) as any);\n\t\t\t\t}\n\n\t\t\t\t// Inserting the input nodes into the tree hydrates them, making them usable as nodes.\n\t\t\t\treturn rows as unknown as RowValueType[];\n\t\t\t}\n\n\t\t\tpublic setCell({ key, cell }: TableSchema.SetCellParameters<CellInsertableType>): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.setCell(column.id, cell);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpublic removeColumn(column: ColumnValueType): void {\n\t\t\t\tconst index = this.columns.indexOf(column);\n\t\t\t\t// If the column is not in the table, do nothing\n\t\t\t\tif (index === -1) return;\n\t\t\t\tthis.columns.removeAt(index);\n\t\t\t}\n\n\t\t\tpublic removeRows(rows: readonly RowValueType[]): void {\n\t\t\t\t// If there are no rows to remove, do nothing\n\t\t\t\tif (rows.length === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If there is only one row to remove, remove it\n\t\t\t\tif (rows.length === 1) {\n\t\t\t\t\tconst index = this.rows.indexOf(rows[0] ?? oob());\n\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// If there are multiple rows to remove, remove them in a transaction\n\t\t\t\t// This is to avoid the performance issues of deleting multiple rows at once\n\t\t\t\tTree.runTransaction(this, () => {\n\t\t\t\t\t// Iterate over the rows and remove them\n\t\t\t\t\tfor (const row of rows) {\n\t\t\t\t\t\tconst index = this.rows.indexOf(row);\n\t\t\t\t\t\tthis.rows.removeAt(index);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpublic removeAllRows(): void {\n\t\t\t\tthis.rows.removeRange();\n\t\t\t}\n\n\t\t\tpublic removeCell(key: TableSchema.CellKey): void {\n\t\t\t\tconst { columnId, rowId } = key;\n\t\t\t\tconst row = this.getRow(rowId);\n\t\t\t\tif (row !== undefined) {\n\t\t\t\t\tconst column = this.getColumn(columnId);\n\t\t\t\t\tif (column !== undefined) {\n\t\t\t\t\t\trow.removeCell(column.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttype TableValueType = TreeNode &\n\t\t\tTableSchema.ITable<TCellSchema, TColumnSchema, TRowSchema> &\n\t\t\tWithType<ScopedSchemaName<Scope, \"Table\">>;\n\t\ttype TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;\n\n\t\t// Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly \"__#124291@#brand\": unknown;`\n\t\t// for the private brand field of TreeNode.\n\t\t// This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.\n\t\t// This is avoided by doing this type conversion.\n\t\t// The conversion is done via assignment instead of `as` to get stronger type safety.\n\t\tconst TableSchemaType: TreeNodeSchemaClass<\n\t\t\t/* Name */ ScopedSchemaName<Scope, \"Table\">,\n\t\t\t/* Kind */ NodeKind.Object,\n\t\t\t/* TNode */ TableValueType,\n\t\t\t/* TInsertable */ object & TableInsertableType,\n\t\t\t/* ImplicitlyConstructable */ true,\n\t\t\t/* Info */ typeof tableFields\n\t\t> = Table;\n\n\t\t// Return the table schema\n\t\treturn TableSchemaType;\n\t}\n\n\t/**\n\t * Base row schema type.\n\t * @sealed @system @internal\n\t */\n\texport type TableSchemaBase<\n\t\tTScope extends string | undefined,\n\t\tTCell extends ImplicitAllowedTypes,\n\t\tTColumn extends ColumnSchemaBase<TScope> = ColumnSchemaBase<TScope>,\n\t\tTRow extends RowSchemaBase<TScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<\n\t\t\tTScope,\n\t\t\tTCell,\n\t\t\tImplicitAllowedTypes\n\t\t>,\n\t> = ReturnType<typeof TableSchema.createTable<TScope, TCell, TColumn, TRow>>;\n\n\t// #endregion\n}\n\n/**\n * Contains types and factories for creating schema to represent dynamic tabular data.\n * @privateRemarks TODO: document in more detail and add `@example`s.\n * @internal\n */\nexport namespace TableSchema {\n\t// #region Column\n\n\t/**\n\t * A column in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.(createColumn:2)}.\n\t * @sealed @internal\n\t */\n\texport interface IColumn<\n\t\tTProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,\n\t> {\n\t\t/**\n\t\t * The unique identifier of the column.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\n\t\t/**\n\t\t * The column's properties.\n\t\t * @remarks This is a user-defined schema that can be used to store additional information about the column.\n\t\t * @privateRemarks\n\t\t * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.\n\t\t * If you update the docs here, please also update the inline type definitions.\n\t\t */\n\t\tget props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>> | undefined;\n\t\tset props(value: InsertableTreeFieldFromImplicitField<\n\t\t\tUnannotateImplicitFieldSchema<TProps>\n\t\t>);\n\t}\n\n\t/**\n\t * Factory for creating new table column schema.\n\t * @internal\n\t */\n\texport function createColumn<const TScope extends string | undefined>({\n\t\tschemaFactory,\n\t}: System_TableSchema.CreateColumnOptionsBase<TScope>): ReturnType<\n\t\ttypeof System_TableSchema.createColumnInternal<\n\t\t\tTScope,\n\t\t\tFieldSchema<FieldKind.Optional, typeof SchemaFactoryAlpha.null>\n\t\t>\n\t>;\n\t/**\n\t * Factory for creating new table column schema.\n\t * @internal\n\t */\n\texport function createColumn<\n\t\tconst TScope extends string | undefined,\n\t\tconst TProps extends ImplicitFieldSchema,\n\t>({\n\t\tschemaFactory,\n\t\tprops,\n\t}: System_TableSchema.CreateColumnOptionsBase<TScope> & {\n\t\t/**\n\t\t * Optional column properties.\n\t\t */\n\t\treadonly props: TProps;\n\t}): ReturnType<typeof System_TableSchema.createColumnInternal<TScope, TProps>>;\n\t/**\n\t * Overload implementation\n\t */\n\texport function createColumn({\n\t\tschemaFactory,\n\t\tprops = SchemaFactory.optional(SchemaFactory.null),\n\t}: System_TableSchema.CreateColumnOptionsBase & {\n\t\treadonly props?: ImplicitFieldSchema;\n\t}): TreeNodeSchema {\n\t\treturn System_TableSchema.createColumnInternal(schemaFactory, props);\n\t}\n\n\t// #endregion\n\n\t// #region Row\n\n\t/**\n\t * A row in a table.\n\t * @remarks Implemented by the schema class returned from {@link TableSchema.(createRow:2)}.\n\t * @sealed @internal\n\t */\n\texport interface IRow<\n\t\tTCell extends ImplicitAllowedTypes,\n\t\tTProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,\n\t> {\n\t\t/**\n\t\t * The unique identifier of the row.\n\t\t * @remarks Uniquely identifies the node within the entire tree, not just the table.\n\t\t */\n\t\treadonly id: string;\n\n\t\t/**\n\t\t * Gets the cell in the specified column.\n\t\t * @returns The cell if it exists, otherwise undefined.\n\t\t */\n\t\tgetCell(column: IColumn): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;\n\t\t/**\n\t\t * Gets the cell in the specified column, denoted by column ID.\n\t\t * @returns The cell if it exists, otherwise undefined.\n\t\t */\n\t\tgetCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;\n\n\t\t/**\n\t\t * Sets the cell in the specified column.\n\t\t * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:1)} instead.\n\t\t */\n\t\tsetCell(column: IColumn, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;\n\t\t/**\n\t\t * Sets the cell in the specified column, denoted by column ID.\n\t\t * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:2)} instead.\n\t\t */\n\t\tsetCell(columnId: string, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;\n\n\t\t/**\n\t\t * Removes the cell in the specified column.\n\t\t * @privateRemarks TODO: return removed cell\n\t\t */\n\t\tremoveCell(column: IColumn): void;\n\t\t/**\n\t\t * Removes the cell in the specified column, denoted by column ID.\n\t\t * @privateRemarks TODO: return removed cell\n\t\t */\n\t\tremoveCell(columnId: string): void;\n\n\t\t/**\n\t\t * The row's properties.\n\t\t * @remarks This is a user-defined schema that can be used to store additional information about the row.\n\t\t * @privateRemarks\n\t\t * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.\n\t\t * If you update the docs here, please also update the inline type definitions.\n\t\t */\n\t\tget props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;\n\t\tset props(value: InsertableTreeFieldFromImplicitField<\n\t\t\tUnannotateImplicitFieldSchema<TProps>\n\t\t>);\n\t}\n\n\t/**\n\t * Factory for creating new table column schema.\n\t * @internal\n\t */\n\texport function createRow<\n\t\tconst TScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t>({\n\t\tschemaFactory,\n\t\tcell,\n\t}: System_TableSchema.CreateRowOptionsBase<TScope, TCell>): ReturnType<\n\t\ttypeof System_TableSchema.createRowInternal<\n\t\t\tTScope,\n\t\t\tTCell,\n\t\t\tFieldSchema<FieldKind.Optional, typeof SchemaFactoryAlpha.null>\n\t\t>\n\t>;\n\t/**\n\t * Factory for creating new table column schema.\n\t * @internal\n\t */\n\texport function createRow<\n\t\tconst TScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TProps extends ImplicitFieldSchema,\n\t>({\n\t\tschemaFactory,\n\t\tcell,\n\t\tprops,\n\t}: System_TableSchema.CreateRowOptionsBase<TScope, TCell> & {\n\t\t/**\n\t\t * Optional row properties.\n\t\t */\n\t\treadonly props: TProps;\n\t}): ReturnType<typeof System_TableSchema.createRowInternal<TScope, TCell, TProps>>;\n\t/**\n\t * Overload implementation\n\t */\n\texport function createRow({\n\t\tschemaFactory,\n\t\tcell,\n\t\tprops = SchemaFactory.optional(SchemaFactory.null),\n\t}: System_TableSchema.CreateRowOptionsBase & {\n\t\treadonly props?: ImplicitFieldSchema;\n\t}): TreeNodeSchema {\n\t\treturn System_TableSchema.createRowInternal(schemaFactory, cell, props);\n\t}\n\n\t// #endregion\n\n\t// #region Table\n\n\t/**\n\t * A key to uniquely identify a cell in a table.\n\t * @internal\n\t */\n\texport interface CellKey {\n\t\t/**\n\t\t * {@link TableSchema.IColumn.id} of the containing {@link TableSchema.IColumn}.\n\t\t */\n\t\treadonly columnId: string;\n\n\t\t/**\n\t\t * {@link TableSchema.IRow.id} of the containing {@link TableSchema.IRow}.\n\t\t */\n\t\treadonly rowId: string;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertColumn} parameters.\n\t * @internal\n\t */\n\texport interface InsertColumnParameters<TInsertableColumn> {\n\t\t/**\n\t\t * The index at which to insert the new column.\n\t\t * @remarks If not provided, the column will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The column to insert.\n\t\t */\n\t\treadonly column: TInsertableColumn;\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.insertRows} parameters.\n\t * @internal\n\t */\n\texport interface InsertRowsParameters<TInsertableRow> {\n\t\t/**\n\t\t * The index at which to insert the new rows.\n\t\t * @remarks If not provided, the rows will be appended to the end of the table.\n\t\t */\n\t\treadonly index?: number | undefined;\n\n\t\t/**\n\t\t * The rows to insert.\n\t\t */\n\t\treadonly rows: TInsertableRow[];\n\t}\n\n\t/**\n\t * {@link TableSchema.ITable.setCell} parameters.\n\t * @internal\n\t */\n\texport interface SetCellParameters<TInsertableCell> {\n\t\t/**\n\t\t * The key to uniquely identify a cell in a table.\n\t\t */\n\t\treadonly key: CellKey;\n\n\t\t/**\n\t\t * The cell to set.\n\t\t */\n\t\treadonly cell: TInsertableCell;\n\t}\n\n\t/**\n\t * A table.\n\t * @sealed @internal\n\t */\n\texport interface ITable<\n\t\tTCell extends ImplicitAllowedTypes,\n\t\tTColumn extends ImplicitAllowedTypes,\n\t\tTRow extends ImplicitAllowedTypes,\n\t> {\n\t\t/**\n\t\t * The table's columns.\n\t\t */\n\t\treadonly columns: TreeArrayNode<TColumn>;\n\n\t\t/**\n\t\t * The table's rows.\n\t\t */\n\t\treadonly rows: TreeArrayNode<TRow>;\n\n\t\t/**\n\t\t * Gets a table column by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;\n\n\t\t/**\n\t\t * Gets a table row by its {@link TableSchema.IRow.id}.\n\t\t */\n\t\tgetRow(id: string): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;\n\n\t\t/**\n\t\t * Gets a cell in the table by column and row IDs.\n\t\t * @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.\n\t\t * @privateRemarks TODO: add overload that takes row and column nodes.\n\t\t */\n\t\tgetCell(key: CellKey): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;\n\n\t\t/**\n\t\t * Inserts a column into the table.\n\t\t * @throws Throws an error if the column is already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertColumn(\n\t\t\tparams: InsertColumnParameters<InsertableTreeNodeFromImplicitAllowedTypes<TColumn>>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TColumn>;\n\n\t\t/**\n\t\t * Inserts 0 or more rows into the table.\n\t\t * @throws Throws an error if any of the rows are already in the tree, or if the specified index is out of range.\n\t\t */\n\t\tinsertRows(\n\t\t\tparams: InsertRowsParameters<InsertableTreeNodeFromImplicitAllowedTypes<TRow>>,\n\t\t): TreeNodeFromImplicitAllowedTypes<TRow>[];\n\n\t\t/**\n\t\t * Sets the cell at the specified location in the table.\n\t\t * @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tsetCell(\n\t\t\tparams: SetCellParameters<InsertableTreeNodeFromImplicitAllowedTypes<TCell>>,\n\t\t): void;\n\n\t\t/**\n\t\t * Removes the specified column from the table.\n\t\t * @remarks Note: this does not remove any cells from the table's rows.\n\t\t * @privateRemarks\n\t\t * TODO:\n\t\t * - Policy for when the column is not in the table.\n\t\t * - Actually remove corresponding cells from table rows.\n\t\t */\n\t\tremoveColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumn>) => void;\n\n\t\t/**\n\t\t * Removes 0 or more rows from the table.\n\t\t * @privateRemarks TODO: policy for when 1 or more rows are not in the table.\n\t\t */\n\t\tremoveRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRow>[]) => void;\n\n\t\t/**\n\t\t * Removes all rows from the table.\n\t\t */\n\t\tremoveAllRows: () => void;\n\n\t\t/**\n\t\t * Removes the cell at the specified location in the table.\n\t\t * @privateRemarks TODO: add overload that takes column/row nodes?\n\t\t */\n\t\tremoveCell: (key: CellKey) => void;\n\t}\n\n\t/**\n\t * Factory for creating new table schema without specifying row or column schema.\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t>({\n\t\tschemaFactory,\n\t\tcell,\n\t}: System_TableSchema.TableFactoryOptionsBase<TScope, TCell>): ReturnType<\n\t\ttypeof System_TableSchema.createTableInternal<TScope, TCell>\n\t>;\n\t/**\n\t * Factory for creating new table schema without specifying row schema.\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,\n\t>({\n\t\tschemaFactory,\n\t\tcell,\n\t\tcolumn,\n\t}: System_TableSchema.TableFactoryOptionsBase<TScope, TCell> & {\n\t\treadonly column: TColumn;\n\t}): ReturnType<typeof System_TableSchema.createTableInternal<TScope, TCell, TColumn>>;\n\t/**\n\t * Factory for creating new table schema.\n\t * @internal\n\t */\n\texport function createTable<\n\t\tconst TScope extends string | undefined,\n\t\tconst TCell extends ImplicitAllowedTypes,\n\t\tconst TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,\n\t\tconst TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>,\n\t>({\n\t\tschemaFactory,\n\t\tcell,\n\t\tcolumn,\n\t\trow,\n\t}: System_TableSchema.TableFactoryOptionsBase<TScope, TCell> & {\n\t\treadonly column: TColumn;\n\t\treadonly row: TRow;\n\t}): ReturnType<typeof System_TableSchema.createTableInternal<TScope, TCell, TColumn, TRow>>;\n\t/**\n\t * Overload implementation\n\t */\n\texport function createTable({\n\t\tschemaFactory,\n\t\tcell,\n\t\tcolumn = createColumn({\n\t\t\tschemaFactory,\n\t\t}),\n\t\trow = createRow({\n\t\t\tschemaFactory,\n\t\t\tcell,\n\t\t}),\n\t}: System_TableSchema.TableFactoryOptionsBase & {\n\t\treadonly column?: System_TableSchema.ColumnSchemaBase;\n\t\treadonly row?: System_TableSchema.RowSchemaBase;\n\t}): TreeNodeSchema {\n\t\treturn System_TableSchema.createTableInternal(schemaFactory, cell, column, row);\n\t}\n\n\t// #endregion\n}\n"]}
@@ -109,7 +109,7 @@ export type RestrictiveStringRecord<T> = {
109
109
  * Returns `true` if T is a union and false if it is not.
110
110
  * @typeparam T - Type to test if it is a union.
111
111
  * @typeparam T2 - Do not specify: default value used as implementation detail.
112
- * @system @alpha
112
+ * @system @public
113
113
  */
114
114
  export type IsUnion<T, T2 = T> = T extends unknown ? [T2] extends [T] ? false : true : "error";
115
115
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"typeUtils.js","sourceRoot":"","sources":["../../src/util/typeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8EH,wIAAwI;AACxI,CAAC;IAwBA,qDAAqD;AACtD,CAAC;AA8FD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,kBAAkB,CAAI,KAAU;IAC/C,OAAO,KAAwB,CAAC;AACjC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Utilities for manipulating types.\n */\n\n/**\n * Return a type thats equivalent to the input, but with different IntelliSense.\n * This tends to convert unions and intersections into objects.\n * @system @public\n */\nexport type FlattenKeys<T> = [{ [Property in keyof T]: T[Property] }][_InlineTrick];\n\n/**\n * Use for trick to \"inline\" generic types.\n *\n * @remarks\n * The TypeScript compiler can be convinced to inline a generic type\n * (so the result of evaluating the generic type show up in IntelliSense and error messages instead of just the invocation of the generic type)\n * by creating an object with a field, and returning the type of that field.\n *\n * For example:\n * ```typescript\n * type MyGeneric<T1, T2> = {x: T1 extends [] ? T1 : T2 };\n * type MyGenericExpanded<T1, T2> = [{x: T1 extends [] ? T1 : T2 }][_InlineTrick]\n *\n * // Type is MyGeneric<5, string>\n * const foo: MyGeneric<5, string> = {x: \"x\"}\n * // Type is {x: \"x\"}\n * const foo2: MyGenericExpanded<5, string> = {x: \"x\"}\n * ```\n *\n * This constant is defined to provide a way to find this documentation from types which use this pattern,\n * and to locate types which use this pattern in case they need updating for compiler changes.\n * @system @public\n */\nexport type _InlineTrick = 0;\n\n/**\n * Use for trick to prevent self reference error `ts(2456)`.\n *\n * Prefix a type expression with `K extends _RecursiveTrick ? _RecursiveTrick : ` for some K to break the cycle.\n *\n * @remarks\n * The TypeScript compiler handles some cases of recursive types, but not others.\n * Sometimes adding an otherwise needless conditional can make a type compile.\n * Use this type in such cases.\n *\n *For example:\n * ```typescript\n * // The TypeScript compiler can't handle this case\n * type Broken<T> = FlattenKeys<\n *\t{\n * \t\t[K in keyof T]: 0;\n * \t} & {\n * \t\t[K in keyof T]: Broken<T[K]>;\n * \t}\n * >;\n *\n * // Adding `K extends _RecursiveTrick ? _RecursiveTrick :` makes it compile, and has no effect on the type produced.\n * type Works<T> = FlattenKeys<\n * \t{\n * \t\t[K in keyof T]: 0;\n * \t} & {\n * \t\t// Trick added here. Since `k` never extends `never`, the second conditional option is always taken,\n * \t\t// making this equivalent to the broken version, except this one compiles.\n * \t\t[K in keyof T]: K extends _RecursiveTrick ? _RecursiveTrick : Works<T[K]>;\n * \t}\n * >;\n * ```\n *\n * This trick appears to start working in TypeScript 4.1 and is confirmed to still work in 5.0.4.\n *\n * This constant is defined to provide a way to find this documentation from types which use this pattern,\n * and to locate types which use this pattern in case they need updating for compiler changes.\n */\nexport type _RecursiveTrick = never;\n\n// This block is kept here to ensure the above example behaves as documented, and can be copied into the example to update it as needed.\n{\n\t/* eslint-disable @typescript-eslint/no-unused-vars */\n\n\t// @ts-expect-error The TypeScript compiler can't handle this case\n\ttype Broken<T> = FlattenKeys<\n\t\t{\n\t\t\t[K in keyof T]: 0;\n\t\t} & {\n\t\t\t// @ts-expect-error Same error as above.\n\t\t\t[K in keyof T]: Broken<T[K]>;\n\t\t}\n\t>;\n\n\t// Adding `K extends _RecursiveTrick ? _RecursiveTrick:` OR `T extends _RecursiveTrick ? _RecursiveTrick :` makes it compile and has no effect on the type produced.\n\ttype Works<T> = FlattenKeys<\n\t\t{\n\t\t\t[K in keyof T]: 0;\n\t\t} & {\n\t\t\t// Trick added here. Since `K` never extends `never`, the second conditional option is always taken,\n\t\t\t// making this equivalent to the broken version, except this one compiles.\n\t\t\t[K in keyof T]: T extends _RecursiveTrick ? _RecursiveTrick : Works<T[K]>;\n\t\t}\n\t>;\n\n\t/* eslint-enable @typescript-eslint/no-unused-vars */\n}\n\n/**\n * Alternative to the built in Record type which does not permit unexpected members,\n * and is readonly.\n *\n * @remarks\n * This does not work correctly when `K` is more specific than `string` or `symbol`.\n * For example `{a: 5}` is not assignable to `RestrictiveReadonlyRecord<\"a\",: number>`\n *\n * @privateRemarks\n * `number` is not allowed as a key here since doing so causes the compiler to reject recursive schema.\n * The cause for this is unclear, but empirically it was the case when this comment was written.\n *\n * @deprecated Use a more robust / specific type instead. This type never worked as intended.\n * @public\n */\nexport type RestrictiveReadonlyRecord<K extends symbol | string, T> = {\n\treadonly [P in symbol | string]: P extends K ? T : never;\n};\n\n/**\n * Alternative to the built-in `Record<string, T>` type which is readonly and does not permit symbols.\n * @remarks\n * It would be nice if `keyof RestrictiveStringRecord<T>` returned string, but it does not: use `keyof RestrictiveStringRecord<T> & string` instead.\n * @system @public\n */\nexport type RestrictiveStringRecord<T> = {\n\treadonly [P in string]: T;\n} & {\n\treadonly [P in symbol]?: never;\n};\n\n/**\n * Returns `true` if T is a union and false if it is not.\n * @typeparam T - Type to test if it is a union.\n * @typeparam T2 - Do not specify: default value used as implementation detail.\n * @system @alpha\n */\nexport type IsUnion<T, T2 = T> = T extends unknown\n\t? [T2] extends [T]\n\t\t? false\n\t\t: true\n\t: \"error\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred, giving the intersection.\n * @system @public\n */\nexport type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * Gets the first item of a union type.\n *\n * @typeparam Union - The union to convert.\n * @typeparam AsOverloadedFunction - Implementation detail: do not specify.\n * @system @alpha\n */\nexport type PopUnion<\n\tUnion,\n\tAsOverloadedFunction = UnionToIntersection<\n\t\tUnion extends unknown ? (f: Union) => void : never\n\t>,\n> = AsOverloadedFunction extends (a: infer First) => void ? First : never;\n\n/**\n * Converts a union type to a tuple type.\n *\n * @typeparam T - The union to convert.\n * @typeparam A - Implementation detail: do not specify.\n * @typeparam First - Implementation detail: do not specify.\n *\n * @privateRemarks\n * `A` is a tuple to prepend members of the union to.\n *\n * https://www.hacklewayne.com/typescript-convert-union-to-tuple-array-yes-but-how and https://catchts.com/union-array both explain the general approach this uses pretty well.\n * This implementation is inspired to those, but slightly different in implementation.\n * @alpha\n */\nexport type UnionToTuple<\n\tUnion,\n\tA extends unknown[] = [],\n\tFirst = PopUnion<Union>,\n> = IsUnion<Union> extends true\n\t? UnionToTuple<Exclude<Union, First>, [First, ...A]>\n\t: [Union, ...A];\n\n/**\n * This is unsafe, meaning that the returned value might not match its type.\n *\n * For the result to match its type, T must be a union of the types of each item in `items` in the order that they occur.\n * For this to be possible, there must be no duplicate or overlapping types.\n * This is fragile and must be used with care.\n *\n * @remarks\n * The main use-case for this is recovering lost information from {@link AllowedTypes} which is necessary to preserve when using them with {@link Input} APIs.\n * Since {@link AllowedTypes} is actually order independent, it is somewhat safer when used to produce `AllowedTypes`.\n *\n * @example\n * ```typescript\n * // Gives imprecise type (typeof A | typeof B)[]\n * const schemaBad = [A, B];\n * // Fixes the type to be [typeof A, typeof B]\n * const schema = unsafeArrayToTuple(schemaBad);\n *\n * const config = new TreeViewConfiguration({ schema });\n * ```\n * @alpha\n */\nexport function unsafeArrayToTuple<T>(items: T[]): UnionToTuple<T> {\n\treturn items as UnionToTuple<T>;\n}\n"]}
1
+ {"version":3,"file":"typeUtils.js","sourceRoot":"","sources":["../../src/util/typeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8EH,wIAAwI;AACxI,CAAC;IAwBA,qDAAqD;AACtD,CAAC;AA8FD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,kBAAkB,CAAI,KAAU;IAC/C,OAAO,KAAwB,CAAC;AACjC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Utilities for manipulating types.\n */\n\n/**\n * Return a type thats equivalent to the input, but with different IntelliSense.\n * This tends to convert unions and intersections into objects.\n * @system @public\n */\nexport type FlattenKeys<T> = [{ [Property in keyof T]: T[Property] }][_InlineTrick];\n\n/**\n * Use for trick to \"inline\" generic types.\n *\n * @remarks\n * The TypeScript compiler can be convinced to inline a generic type\n * (so the result of evaluating the generic type show up in IntelliSense and error messages instead of just the invocation of the generic type)\n * by creating an object with a field, and returning the type of that field.\n *\n * For example:\n * ```typescript\n * type MyGeneric<T1, T2> = {x: T1 extends [] ? T1 : T2 };\n * type MyGenericExpanded<T1, T2> = [{x: T1 extends [] ? T1 : T2 }][_InlineTrick]\n *\n * // Type is MyGeneric<5, string>\n * const foo: MyGeneric<5, string> = {x: \"x\"}\n * // Type is {x: \"x\"}\n * const foo2: MyGenericExpanded<5, string> = {x: \"x\"}\n * ```\n *\n * This constant is defined to provide a way to find this documentation from types which use this pattern,\n * and to locate types which use this pattern in case they need updating for compiler changes.\n * @system @public\n */\nexport type _InlineTrick = 0;\n\n/**\n * Use for trick to prevent self reference error `ts(2456)`.\n *\n * Prefix a type expression with `K extends _RecursiveTrick ? _RecursiveTrick : ` for some K to break the cycle.\n *\n * @remarks\n * The TypeScript compiler handles some cases of recursive types, but not others.\n * Sometimes adding an otherwise needless conditional can make a type compile.\n * Use this type in such cases.\n *\n *For example:\n * ```typescript\n * // The TypeScript compiler can't handle this case\n * type Broken<T> = FlattenKeys<\n *\t{\n * \t\t[K in keyof T]: 0;\n * \t} & {\n * \t\t[K in keyof T]: Broken<T[K]>;\n * \t}\n * >;\n *\n * // Adding `K extends _RecursiveTrick ? _RecursiveTrick :` makes it compile, and has no effect on the type produced.\n * type Works<T> = FlattenKeys<\n * \t{\n * \t\t[K in keyof T]: 0;\n * \t} & {\n * \t\t// Trick added here. Since `k` never extends `never`, the second conditional option is always taken,\n * \t\t// making this equivalent to the broken version, except this one compiles.\n * \t\t[K in keyof T]: K extends _RecursiveTrick ? _RecursiveTrick : Works<T[K]>;\n * \t}\n * >;\n * ```\n *\n * This trick appears to start working in TypeScript 4.1 and is confirmed to still work in 5.0.4.\n *\n * This constant is defined to provide a way to find this documentation from types which use this pattern,\n * and to locate types which use this pattern in case they need updating for compiler changes.\n */\nexport type _RecursiveTrick = never;\n\n// This block is kept here to ensure the above example behaves as documented, and can be copied into the example to update it as needed.\n{\n\t/* eslint-disable @typescript-eslint/no-unused-vars */\n\n\t// @ts-expect-error The TypeScript compiler can't handle this case\n\ttype Broken<T> = FlattenKeys<\n\t\t{\n\t\t\t[K in keyof T]: 0;\n\t\t} & {\n\t\t\t// @ts-expect-error Same error as above.\n\t\t\t[K in keyof T]: Broken<T[K]>;\n\t\t}\n\t>;\n\n\t// Adding `K extends _RecursiveTrick ? _RecursiveTrick:` OR `T extends _RecursiveTrick ? _RecursiveTrick :` makes it compile and has no effect on the type produced.\n\ttype Works<T> = FlattenKeys<\n\t\t{\n\t\t\t[K in keyof T]: 0;\n\t\t} & {\n\t\t\t// Trick added here. Since `K` never extends `never`, the second conditional option is always taken,\n\t\t\t// making this equivalent to the broken version, except this one compiles.\n\t\t\t[K in keyof T]: T extends _RecursiveTrick ? _RecursiveTrick : Works<T[K]>;\n\t\t}\n\t>;\n\n\t/* eslint-enable @typescript-eslint/no-unused-vars */\n}\n\n/**\n * Alternative to the built in Record type which does not permit unexpected members,\n * and is readonly.\n *\n * @remarks\n * This does not work correctly when `K` is more specific than `string` or `symbol`.\n * For example `{a: 5}` is not assignable to `RestrictiveReadonlyRecord<\"a\",: number>`\n *\n * @privateRemarks\n * `number` is not allowed as a key here since doing so causes the compiler to reject recursive schema.\n * The cause for this is unclear, but empirically it was the case when this comment was written.\n *\n * @deprecated Use a more robust / specific type instead. This type never worked as intended.\n * @public\n */\nexport type RestrictiveReadonlyRecord<K extends symbol | string, T> = {\n\treadonly [P in symbol | string]: P extends K ? T : never;\n};\n\n/**\n * Alternative to the built-in `Record<string, T>` type which is readonly and does not permit symbols.\n * @remarks\n * It would be nice if `keyof RestrictiveStringRecord<T>` returned string, but it does not: use `keyof RestrictiveStringRecord<T> & string` instead.\n * @system @public\n */\nexport type RestrictiveStringRecord<T> = {\n\treadonly [P in string]: T;\n} & {\n\treadonly [P in symbol]?: never;\n};\n\n/**\n * Returns `true` if T is a union and false if it is not.\n * @typeparam T - Type to test if it is a union.\n * @typeparam T2 - Do not specify: default value used as implementation detail.\n * @system @public\n */\nexport type IsUnion<T, T2 = T> = T extends unknown\n\t? [T2] extends [T]\n\t\t? false\n\t\t: true\n\t: \"error\";\n\n/**\n * Convert a union of types to an intersection of those types. Useful for `TransformEvents`.\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred, giving the intersection.\n * @system @public\n */\nexport type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * Gets the first item of a union type.\n *\n * @typeparam Union - The union to convert.\n * @typeparam AsOverloadedFunction - Implementation detail: do not specify.\n * @system @alpha\n */\nexport type PopUnion<\n\tUnion,\n\tAsOverloadedFunction = UnionToIntersection<\n\t\tUnion extends unknown ? (f: Union) => void : never\n\t>,\n> = AsOverloadedFunction extends (a: infer First) => void ? First : never;\n\n/**\n * Converts a union type to a tuple type.\n *\n * @typeparam T - The union to convert.\n * @typeparam A - Implementation detail: do not specify.\n * @typeparam First - Implementation detail: do not specify.\n *\n * @privateRemarks\n * `A` is a tuple to prepend members of the union to.\n *\n * https://www.hacklewayne.com/typescript-convert-union-to-tuple-array-yes-but-how and https://catchts.com/union-array both explain the general approach this uses pretty well.\n * This implementation is inspired to those, but slightly different in implementation.\n * @alpha\n */\nexport type UnionToTuple<\n\tUnion,\n\tA extends unknown[] = [],\n\tFirst = PopUnion<Union>,\n> = IsUnion<Union> extends true\n\t? UnionToTuple<Exclude<Union, First>, [First, ...A]>\n\t: [Union, ...A];\n\n/**\n * This is unsafe, meaning that the returned value might not match its type.\n *\n * For the result to match its type, T must be a union of the types of each item in `items` in the order that they occur.\n * For this to be possible, there must be no duplicate or overlapping types.\n * This is fragile and must be used with care.\n *\n * @remarks\n * The main use-case for this is recovering lost information from {@link AllowedTypes} which is necessary to preserve when using them with {@link Input} APIs.\n * Since {@link AllowedTypes} is actually order independent, it is somewhat safer when used to produce `AllowedTypes`.\n *\n * @example\n * ```typescript\n * // Gives imprecise type (typeof A | typeof B)[]\n * const schemaBad = [A, B];\n * // Fixes the type to be [typeof A, typeof B]\n * const schema = unsafeArrayToTuple(schemaBad);\n *\n * const config = new TreeViewConfiguration({ schema });\n * ```\n * @alpha\n */\nexport function unsafeArrayToTuple<T>(items: T[]): UnionToTuple<T> {\n\treturn items as UnionToTuple<T>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree",
3
- "version": "2.33.1",
3
+ "version": "2.40.0-336023",
4
4
  "description": "Distributed tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -89,17 +89,17 @@
89
89
  "temp-directory": "nyc/.nyc_output"
90
90
  },
91
91
  "dependencies": {
92
- "@fluid-internal/client-utils": "~2.33.1",
93
- "@fluidframework/container-runtime": "~2.33.1",
94
- "@fluidframework/core-interfaces": "~2.33.1",
95
- "@fluidframework/core-utils": "~2.33.1",
96
- "@fluidframework/datastore-definitions": "~2.33.1",
97
- "@fluidframework/driver-definitions": "~2.33.1",
98
- "@fluidframework/id-compressor": "~2.33.1",
99
- "@fluidframework/runtime-definitions": "~2.33.1",
100
- "@fluidframework/runtime-utils": "~2.33.1",
101
- "@fluidframework/shared-object-base": "~2.33.1",
102
- "@fluidframework/telemetry-utils": "~2.33.1",
92
+ "@fluid-internal/client-utils": "2.40.0-336023",
93
+ "@fluidframework/container-runtime": "2.40.0-336023",
94
+ "@fluidframework/core-interfaces": "2.40.0-336023",
95
+ "@fluidframework/core-utils": "2.40.0-336023",
96
+ "@fluidframework/datastore-definitions": "2.40.0-336023",
97
+ "@fluidframework/driver-definitions": "2.40.0-336023",
98
+ "@fluidframework/id-compressor": "2.40.0-336023",
99
+ "@fluidframework/runtime-definitions": "2.40.0-336023",
100
+ "@fluidframework/runtime-utils": "2.40.0-336023",
101
+ "@fluidframework/shared-object-base": "2.40.0-336023",
102
+ "@fluidframework/telemetry-utils": "2.40.0-336023",
103
103
  "@sinclair/typebox": "^0.34.13",
104
104
  "@tylerbu/sorted-btree-es6": "^1.8.0",
105
105
  "@types/ungap__structured-clone": "^1.2.0",
@@ -109,19 +109,19 @@
109
109
  "devDependencies": {
110
110
  "@arethetypeswrong/cli": "^0.17.1",
111
111
  "@biomejs/biome": "~1.9.3",
112
- "@fluid-internal/mocha-test-setup": "~2.33.1",
113
- "@fluid-private/stochastic-test-utils": "~2.33.1",
114
- "@fluid-private/test-dds-utils": "~2.33.1",
115
- "@fluid-private/test-drivers": "~2.33.1",
112
+ "@fluid-internal/mocha-test-setup": "2.40.0-336023",
113
+ "@fluid-private/stochastic-test-utils": "2.40.0-336023",
114
+ "@fluid-private/test-dds-utils": "2.40.0-336023",
115
+ "@fluid-private/test-drivers": "2.40.0-336023",
116
116
  "@fluid-tools/benchmark": "^0.50.0",
117
117
  "@fluid-tools/build-cli": "^0.55.0",
118
118
  "@fluidframework/build-common": "^2.0.3",
119
119
  "@fluidframework/build-tools": "^0.55.0",
120
- "@fluidframework/container-definitions": "~2.33.1",
121
- "@fluidframework/container-loader": "~2.33.1",
120
+ "@fluidframework/container-definitions": "2.40.0-336023",
121
+ "@fluidframework/container-loader": "2.40.0-336023",
122
122
  "@fluidframework/eslint-config-fluid": "^5.7.3",
123
- "@fluidframework/test-runtime-utils": "~2.33.1",
124
- "@fluidframework/test-utils": "~2.33.1",
123
+ "@fluidframework/test-runtime-utils": "2.40.0-336023",
124
+ "@fluidframework/test-utils": "2.40.0-336023",
125
125
  "@fluidframework/tree-previous": "npm:@fluidframework/tree@2.33.0",
126
126
  "@microsoft/api-extractor": "7.52.5",
127
127
  "@types/diff": "^3.5.1",
package/src/index.ts CHANGED
@@ -152,6 +152,20 @@ export {
152
152
  type FactoryContentObject,
153
153
  type ReadableField,
154
154
  type ReadSchema,
155
+ type ImplicitAnnotatedAllowedTypes,
156
+ type ImplicitAnnotatedFieldSchema,
157
+ type AnnotatedAllowedType,
158
+ type AnnotatedAllowedTypes,
159
+ type AllowedTypeMetadata,
160
+ type AllowedTypesMetadata,
161
+ type InsertableObjectFromAnnotatedSchemaRecord,
162
+ type UnannotateImplicitAllowedTypes,
163
+ type UnannotateAllowedTypes,
164
+ type UnannotateAllowedType,
165
+ type UnannotateAllowedTypesList,
166
+ type UnannotateAllowedTypeOrLazyItem,
167
+ type UnannotateImplicitFieldSchema,
168
+ type UnannotateSchemaRecord,
155
169
  // test recursive schema for checking that d.ts files handles schema correctly
156
170
  test_RecursiveObject,
157
171
  test_RecursiveObject_base,
@@ -232,6 +246,8 @@ export {
232
246
  type MapNodePojoEmulationSchema,
233
247
  MapNodeSchema,
234
248
  type ObjectFromSchemaRecord,
249
+ type ValidateRecursiveSchemaTemplate,
250
+ type FixRecursiveRecursionLimit,
235
251
  } from "./simple-tree/index.js";
236
252
  export {
237
253
  SharedTree,
@@ -286,4 +302,4 @@ export type { MapNodeInsertableData } from "./simple-tree/index.js";
286
302
 
287
303
  export { JsonAsTree } from "./jsonDomainSchema.js";
288
304
  export { FluidSerializableAsTree } from "./serializableDomainSchema.js";
289
- export { TableSchema } from "./tableSchema.js";
305
+ export { TableSchema, type System_TableSchema } from "./tableSchema.js";
@@ -19,5 +19,3 @@ export type {
19
19
  InsertableObjectFromSchemaRecord,
20
20
  } from "./simple-tree/index.js";
21
21
  export type { FlexList, FlexListToUnion, ExtractItemType } from "./simple-tree/index.js";
22
-
23
- export type { TreeApi } from "./shared-tree/index.js";
@@ -36,7 +36,7 @@ const sf = new SchemaFactory("com.fluidframework.json");
36
36
  *
37
37
  * 2. The order of fields on an object is not preserved. The resulting order is arbitrary.
38
38
  *
39
- * JSON data can be imported from JSON into this format using `JSON.parse` then {@link TreeAlpha.importConcise} with the {@link JsonAsTree.(Tree:variable)} schema.
39
+ * JSON data can be imported from JSON into this format using `JSON.parse` then {@link (TreeAlpha:interface).importConcise} with the {@link JsonAsTree.(Tree:variable)} schema.
40
40
  *
41
41
  * @alpha
42
42
  */
@@ -125,7 +125,7 @@ export namespace JsonAsTree {
125
125
  /**
126
126
  * Arbitrary JSON array as a {@link TreeNode}.
127
127
  * @remarks
128
- * This can be imported using {@link TreeAlpha.importConcise}.
128
+ * This can be imported using {@link (TreeAlpha:interface).importConcise}.
129
129
  * @example
130
130
  * ```typescript
131
131
  * // Due to TypeScript restrictions on recursive types, the constructor can be somewhat limiting.
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/tree";
9
- export const pkgVersion = "2.33.1";
9
+ export const pkgVersion = "2.40.0-336023";