@fluidframework/tree 2.33.2 → 2.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (621) hide show
  1. package/.vscode/settings.json +2 -0
  2. package/CHANGELOG.md +64 -0
  3. package/api-report/tree.alpha.api.md +124 -51
  4. package/api-report/tree.beta.api.md +31 -27
  5. package/api-report/tree.legacy.alpha.api.md +24 -23
  6. package/api-report/tree.legacy.public.api.md +24 -23
  7. package/api-report/tree.public.api.md +24 -23
  8. package/dist/alpha.d.ts +17 -1
  9. package/dist/beta.d.ts +2 -0
  10. package/dist/codec/codec.d.ts +5 -1
  11. package/dist/codec/codec.d.ts.map +1 -1
  12. package/dist/codec/codec.js +6 -2
  13. package/dist/codec/codec.js.map +1 -1
  14. package/dist/codec/index.d.ts +1 -1
  15. package/dist/codec/index.d.ts.map +1 -1
  16. package/dist/codec/index.js +2 -1
  17. package/dist/codec/index.js.map +1 -1
  18. package/dist/core/index.d.ts +2 -2
  19. package/dist/core/index.d.ts.map +1 -1
  20. package/dist/core/index.js +2 -3
  21. package/dist/core/index.js.map +1 -1
  22. package/dist/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  23. package/dist/core/schema-stored/formatV1.d.ts.map +1 -0
  24. package/dist/core/schema-stored/{format.js → formatV1.js} +1 -1
  25. package/dist/core/schema-stored/formatV1.js.map +1 -0
  26. package/dist/core/schema-stored/index.d.ts +3 -3
  27. package/dist/core/schema-stored/index.d.ts.map +1 -1
  28. package/dist/core/schema-stored/index.js +3 -3
  29. package/dist/core/schema-stored/index.js.map +1 -1
  30. package/dist/core/schema-stored/schema.d.ts +3 -1
  31. package/dist/core/schema-stored/schema.d.ts.map +1 -1
  32. package/dist/core/schema-stored/schema.js +8 -6
  33. package/dist/core/schema-stored/schema.js.map +1 -1
  34. package/dist/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  35. package/dist/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  36. package/dist/core/schema-stored/storedSchemaRepository.js.map +1 -1
  37. package/dist/core/schema-view/index.d.ts +1 -1
  38. package/dist/core/schema-view/index.d.ts.map +1 -1
  39. package/dist/core/schema-view/index.js +1 -2
  40. package/dist/core/schema-view/index.js.map +1 -1
  41. package/dist/core/schema-view/view.d.ts +0 -27
  42. package/dist/core/schema-view/view.d.ts.map +1 -1
  43. package/dist/core/schema-view/view.js +1 -35
  44. package/dist/core/schema-view/view.js.map +1 -1
  45. package/dist/core/tree/persistedTreeTextFormat.d.ts +4 -4
  46. package/dist/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  47. package/dist/core/tree/persistedTreeTextFormat.js +1 -1
  48. package/dist/core/tree/persistedTreeTextFormat.js.map +1 -1
  49. package/dist/feature-libraries/forest-summary/format.d.ts +2 -2
  50. package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
  51. package/dist/feature-libraries/forest-summary/format.js +1 -1
  52. package/dist/feature-libraries/forest-summary/format.js.map +1 -1
  53. package/dist/feature-libraries/index.d.ts +1 -1
  54. package/dist/feature-libraries/index.d.ts.map +1 -1
  55. package/dist/feature-libraries/index.js +4 -2
  56. package/dist/feature-libraries/index.js.map +1 -1
  57. package/dist/feature-libraries/mapTreeCursor.d.ts +3 -3
  58. package/dist/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  59. package/dist/feature-libraries/mapTreeCursor.js +2 -2
  60. package/dist/feature-libraries/mapTreeCursor.js.map +1 -1
  61. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  62. package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  63. package/dist/feature-libraries/modular-schema/modularChangeFormat.js +2 -2
  64. package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  65. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  66. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  67. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -5
  68. package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  69. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  70. package/dist/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  71. package/dist/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  72. package/dist/feature-libraries/schema-index/codec.d.ts +34 -5
  73. package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
  74. package/dist/feature-libraries/schema-index/codec.js +63 -9
  75. package/dist/feature-libraries/schema-index/codec.js.map +1 -1
  76. package/{lib/feature-libraries/schema-index/format.d.ts → dist/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  77. package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  78. package/dist/feature-libraries/schema-index/{format.js → formatV1.js} +4 -4
  79. package/dist/feature-libraries/schema-index/formatV1.js.map +1 -0
  80. package/dist/feature-libraries/schema-index/index.d.ts +2 -2
  81. package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
  82. package/dist/feature-libraries/schema-index/index.js +6 -3
  83. package/dist/feature-libraries/schema-index/index.js.map +1 -1
  84. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  85. package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  86. package/dist/feature-libraries/schema-index/schemaSummarizer.js +4 -4
  87. package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  88. package/dist/index.d.ts +3 -2
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +10 -8
  91. package/dist/index.js.map +1 -1
  92. package/dist/internalTypes.d.ts +0 -1
  93. package/dist/internalTypes.d.ts.map +1 -1
  94. package/dist/internalTypes.js.map +1 -1
  95. package/dist/jsonDomainSchema.d.ts +2 -2
  96. package/dist/jsonDomainSchema.js +2 -2
  97. package/dist/jsonDomainSchema.js.map +1 -1
  98. package/dist/legacy.d.ts +2 -0
  99. package/dist/packageVersion.d.ts +1 -1
  100. package/dist/packageVersion.js +1 -1
  101. package/dist/packageVersion.js.map +1 -1
  102. package/dist/public.d.ts +2 -0
  103. package/dist/serializableDomainSchema.d.ts +3 -3
  104. package/dist/serializableDomainSchema.js +2 -2
  105. package/dist/serializableDomainSchema.js.map +1 -1
  106. package/dist/shared-tree/independentView.d.ts +1 -1
  107. package/dist/shared-tree/independentView.d.ts.map +1 -1
  108. package/dist/shared-tree/independentView.js +1 -1
  109. package/dist/shared-tree/independentView.js.map +1 -1
  110. package/dist/shared-tree/index.d.ts +4 -3
  111. package/dist/shared-tree/index.d.ts.map +1 -1
  112. package/dist/shared-tree/index.js +6 -5
  113. package/dist/shared-tree/index.js.map +1 -1
  114. package/dist/shared-tree/schematizeTree.d.ts +10 -11
  115. package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
  116. package/dist/shared-tree/schematizeTree.js +11 -36
  117. package/dist/shared-tree/schematizeTree.js.map +1 -1
  118. package/dist/shared-tree/schematizingTreeView.d.ts +3 -3
  119. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  120. package/dist/shared-tree/schematizingTreeView.js +4 -7
  121. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  122. package/dist/shared-tree/sharedTree.d.ts +28 -3
  123. package/dist/shared-tree/sharedTree.d.ts.map +1 -1
  124. package/dist/shared-tree/sharedTree.js +29 -3
  125. package/dist/shared-tree/sharedTree.js.map +1 -1
  126. package/dist/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
  127. package/dist/shared-tree/tree.d.ts.map +1 -0
  128. package/dist/shared-tree/{treeApi.js → tree.js} +6 -6
  129. package/dist/shared-tree/tree.js.map +1 -0
  130. package/{lib/shared-tree/treeApiAlpha.d.ts → dist/shared-tree/treeAlpha.d.ts} +24 -14
  131. package/dist/shared-tree/treeAlpha.d.ts.map +1 -0
  132. package/dist/shared-tree/{treeApiAlpha.js → treeAlpha.js} +7 -5
  133. package/dist/shared-tree/treeAlpha.js.map +1 -0
  134. package/dist/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  135. package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  136. package/dist/shared-tree-core/branchCommitEnricher.js +0 -1
  137. package/dist/shared-tree-core/branchCommitEnricher.js.map +1 -1
  138. package/dist/shared-tree-core/transactionEnricher.d.ts +1 -1
  139. package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  140. package/dist/shared-tree-core/transactionEnricher.js +4 -1
  141. package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
  142. package/dist/simple-tree/api/conciseTree.d.ts +1 -1
  143. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  144. package/dist/simple-tree/api/configuration.d.ts +177 -0
  145. package/dist/simple-tree/api/configuration.d.ts.map +1 -0
  146. package/dist/simple-tree/api/configuration.js +163 -0
  147. package/dist/simple-tree/api/configuration.js.map +1 -0
  148. package/dist/simple-tree/api/getJsonSchema.js +2 -2
  149. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  150. package/dist/simple-tree/api/index.d.ts +9 -5
  151. package/dist/simple-tree/api/index.d.ts.map +1 -1
  152. package/dist/simple-tree/api/index.js +9 -7
  153. package/dist/simple-tree/api/index.js.map +1 -1
  154. package/dist/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  155. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  156. package/dist/simple-tree/api/{view.js → schemaCompatibilityTester.js} +9 -9
  157. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  158. package/dist/simple-tree/api/schemaFactory.d.ts +25 -10
  159. package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
  160. package/dist/simple-tree/api/schemaFactory.js +27 -12
  161. package/dist/simple-tree/api/schemaFactory.js.map +1 -1
  162. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  163. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  164. package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
  165. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  166. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  167. package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  168. package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  169. package/dist/simple-tree/api/schemaFromSimple.d.ts +1 -1
  170. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  171. package/dist/simple-tree/api/schemaFromSimple.js +1 -1
  172. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  173. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  174. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  175. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  176. package/dist/simple-tree/api/storedSchema.d.ts +11 -10
  177. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  178. package/dist/simple-tree/api/storedSchema.js +16 -11
  179. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  180. package/dist/simple-tree/api/tree.d.ts +30 -174
  181. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  182. package/dist/simple-tree/api/tree.js +1 -156
  183. package/dist/simple-tree/api/tree.js.map +1 -1
  184. package/{lib/simple-tree/api/treeApiBeta.d.ts → dist/simple-tree/api/treeBeta.d.ts} +17 -6
  185. package/dist/simple-tree/api/treeBeta.d.ts.map +1 -0
  186. package/dist/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  187. package/dist/simple-tree/api/treeBeta.js.map +1 -0
  188. package/dist/simple-tree/api/treeChangeEvents.d.ts +83 -0
  189. package/dist/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  190. package/dist/simple-tree/api/treeChangeEvents.js +7 -0
  191. package/dist/simple-tree/api/treeChangeEvents.js.map +1 -0
  192. package/dist/simple-tree/api/treeNodeApi.d.ts +2 -1
  193. package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  194. package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
  195. package/dist/simple-tree/api/typesUnsafe.d.ts +4 -9
  196. package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  197. package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
  198. package/dist/simple-tree/arrayNode.d.ts +30 -2
  199. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  200. package/dist/simple-tree/arrayNode.js +3 -2
  201. package/dist/simple-tree/arrayNode.js.map +1 -1
  202. package/dist/simple-tree/arrayNodeTypes.d.ts +3 -3
  203. package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  204. package/dist/simple-tree/arrayNodeTypes.js.map +1 -1
  205. package/dist/simple-tree/core/getOrCreateNode.d.ts +1 -1
  206. package/dist/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  207. package/dist/simple-tree/core/getOrCreateNode.js.map +1 -1
  208. package/dist/simple-tree/core/index.d.ts +2 -1
  209. package/dist/simple-tree/core/index.d.ts.map +1 -1
  210. package/dist/simple-tree/core/index.js +5 -5
  211. package/dist/simple-tree/core/index.js.map +1 -1
  212. package/dist/simple-tree/core/treeNode.d.ts +94 -0
  213. package/dist/simple-tree/core/treeNode.d.ts.map +1 -0
  214. package/dist/simple-tree/core/treeNode.js +123 -0
  215. package/dist/simple-tree/core/treeNode.js.map +1 -0
  216. package/dist/simple-tree/core/treeNodeKernel.d.ts +2 -1
  217. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  218. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  219. package/dist/simple-tree/core/treeNodeSchema.d.ts +3 -1
  220. package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  221. package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
  222. package/dist/simple-tree/core/types.d.ts +0 -165
  223. package/dist/simple-tree/core/types.d.ts.map +1 -1
  224. package/dist/simple-tree/core/types.js +1 -113
  225. package/dist/simple-tree/core/types.js.map +1 -1
  226. package/dist/simple-tree/core/withType.d.ts +1 -1
  227. package/dist/simple-tree/core/withType.d.ts.map +1 -1
  228. package/dist/simple-tree/core/withType.js.map +1 -1
  229. package/dist/simple-tree/index.d.ts +4 -4
  230. package/dist/simple-tree/index.d.ts.map +1 -1
  231. package/dist/simple-tree/index.js +4 -3
  232. package/dist/simple-tree/index.js.map +1 -1
  233. package/dist/simple-tree/mapNode.d.ts +2 -2
  234. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  235. package/dist/simple-tree/mapNode.js +1 -1
  236. package/dist/simple-tree/mapNode.js.map +1 -1
  237. package/dist/simple-tree/mapNodeTypes.d.ts +3 -3
  238. package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -1
  239. package/dist/simple-tree/mapNodeTypes.js.map +1 -1
  240. package/dist/simple-tree/objectNode.d.ts +18 -5
  241. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  242. package/dist/simple-tree/objectNode.js +4 -3
  243. package/dist/simple-tree/objectNode.js.map +1 -1
  244. package/dist/simple-tree/objectNodeTypes.d.ts +4 -4
  245. package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
  246. package/dist/simple-tree/objectNodeTypes.js.map +1 -1
  247. package/dist/simple-tree/schemaTypes.d.ts +164 -13
  248. package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
  249. package/dist/simple-tree/schemaTypes.js +107 -8
  250. package/dist/simple-tree/schemaTypes.js.map +1 -1
  251. package/dist/simple-tree/toStoredSchema.d.ts +8 -8
  252. package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
  253. package/dist/simple-tree/toStoredSchema.js +27 -32
  254. package/dist/simple-tree/toStoredSchema.js.map +1 -1
  255. package/dist/simple-tree/treeNodeValid.js +2 -2
  256. package/dist/simple-tree/treeNodeValid.js.map +1 -1
  257. package/dist/tableSchema.d.ts +455 -125
  258. package/dist/tableSchema.d.ts.map +1 -1
  259. package/dist/tableSchema.js +398 -101
  260. package/dist/tableSchema.js.map +1 -1
  261. package/dist/treeFactory.d.ts +1 -1
  262. package/dist/treeFactory.d.ts.map +1 -1
  263. package/dist/treeFactory.js +30 -75
  264. package/dist/treeFactory.js.map +1 -1
  265. package/dist/util/typeUtils.d.ts +1 -1
  266. package/dist/util/typeUtils.js.map +1 -1
  267. package/lib/alpha.d.ts +17 -1
  268. package/lib/beta.d.ts +2 -0
  269. package/lib/codec/codec.d.ts +5 -1
  270. package/lib/codec/codec.d.ts.map +1 -1
  271. package/lib/codec/codec.js +5 -1
  272. package/lib/codec/codec.js.map +1 -1
  273. package/lib/codec/index.d.ts +1 -1
  274. package/lib/codec/index.d.ts.map +1 -1
  275. package/lib/codec/index.js +1 -1
  276. package/lib/codec/index.js.map +1 -1
  277. package/lib/core/index.d.ts +2 -2
  278. package/lib/core/index.d.ts.map +1 -1
  279. package/lib/core/index.js +2 -2
  280. package/lib/core/index.js.map +1 -1
  281. package/lib/core/schema-stored/{format.d.ts → formatV1.d.ts} +1 -1
  282. package/lib/core/schema-stored/formatV1.d.ts.map +1 -0
  283. package/lib/core/schema-stored/{format.js → formatV1.js} +1 -1
  284. package/lib/core/schema-stored/formatV1.js.map +1 -0
  285. package/lib/core/schema-stored/index.d.ts +3 -3
  286. package/lib/core/schema-stored/index.d.ts.map +1 -1
  287. package/lib/core/schema-stored/index.js +2 -2
  288. package/lib/core/schema-stored/index.js.map +1 -1
  289. package/lib/core/schema-stored/schema.d.ts +3 -1
  290. package/lib/core/schema-stored/schema.d.ts.map +1 -1
  291. package/lib/core/schema-stored/schema.js +3 -1
  292. package/lib/core/schema-stored/schema.js.map +1 -1
  293. package/lib/core/schema-stored/storedSchemaRepository.d.ts +1 -1
  294. package/lib/core/schema-stored/storedSchemaRepository.d.ts.map +1 -1
  295. package/lib/core/schema-stored/storedSchemaRepository.js.map +1 -1
  296. package/lib/core/schema-view/index.d.ts +1 -1
  297. package/lib/core/schema-view/index.d.ts.map +1 -1
  298. package/lib/core/schema-view/index.js +1 -1
  299. package/lib/core/schema-view/index.js.map +1 -1
  300. package/lib/core/schema-view/view.d.ts +0 -27
  301. package/lib/core/schema-view/view.d.ts.map +1 -1
  302. package/lib/core/schema-view/view.js +0 -34
  303. package/lib/core/schema-view/view.js.map +1 -1
  304. package/lib/core/tree/persistedTreeTextFormat.d.ts +4 -4
  305. package/lib/core/tree/persistedTreeTextFormat.d.ts.map +1 -1
  306. package/lib/core/tree/persistedTreeTextFormat.js +2 -2
  307. package/lib/core/tree/persistedTreeTextFormat.js.map +1 -1
  308. package/lib/feature-libraries/forest-summary/format.d.ts +2 -2
  309. package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
  310. package/lib/feature-libraries/forest-summary/format.js +2 -2
  311. package/lib/feature-libraries/forest-summary/format.js.map +1 -1
  312. package/lib/feature-libraries/index.d.ts +1 -1
  313. package/lib/feature-libraries/index.d.ts.map +1 -1
  314. package/lib/feature-libraries/index.js +1 -1
  315. package/lib/feature-libraries/index.js.map +1 -1
  316. package/lib/feature-libraries/mapTreeCursor.d.ts +3 -3
  317. package/lib/feature-libraries/mapTreeCursor.d.ts.map +1 -1
  318. package/lib/feature-libraries/mapTreeCursor.js +2 -2
  319. package/lib/feature-libraries/mapTreeCursor.js.map +1 -1
  320. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts +9 -9
  321. package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +1 -1
  322. package/lib/feature-libraries/modular-schema/modularChangeFormat.js +3 -3
  323. package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +1 -1
  324. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +14 -1
  325. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
  326. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +26 -6
  327. package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
  328. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts +2 -2
  329. package/lib/feature-libraries/schema-edits/schemaChangeFormat.d.ts.map +1 -1
  330. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js +3 -3
  331. package/lib/feature-libraries/schema-edits/schemaChangeFormat.js.map +1 -1
  332. package/lib/feature-libraries/schema-index/codec.d.ts +34 -5
  333. package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
  334. package/lib/feature-libraries/schema-index/codec.js +61 -9
  335. package/lib/feature-libraries/schema-index/codec.js.map +1 -1
  336. package/{dist/feature-libraries/schema-index/format.d.ts → lib/feature-libraries/schema-index/formatV1.d.ts} +9 -9
  337. package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -0
  338. package/lib/feature-libraries/schema-index/{format.js → formatV1.js} +5 -5
  339. package/lib/feature-libraries/schema-index/formatV1.js.map +1 -0
  340. package/lib/feature-libraries/schema-index/index.d.ts +2 -2
  341. package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
  342. package/lib/feature-libraries/schema-index/index.js +2 -2
  343. package/lib/feature-libraries/schema-index/index.js.map +1 -1
  344. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +5 -5
  345. package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
  346. package/lib/feature-libraries/schema-index/schemaSummarizer.js +5 -5
  347. package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
  348. package/lib/index.d.ts +3 -2
  349. package/lib/index.d.ts.map +1 -1
  350. package/lib/index.js +1 -0
  351. package/lib/index.js.map +1 -1
  352. package/lib/internalTypes.d.ts +0 -1
  353. package/lib/internalTypes.d.ts.map +1 -1
  354. package/lib/internalTypes.js.map +1 -1
  355. package/lib/jsonDomainSchema.d.ts +2 -2
  356. package/lib/jsonDomainSchema.js +2 -2
  357. package/lib/jsonDomainSchema.js.map +1 -1
  358. package/lib/legacy.d.ts +2 -0
  359. package/lib/packageVersion.d.ts +1 -1
  360. package/lib/packageVersion.js +1 -1
  361. package/lib/packageVersion.js.map +1 -1
  362. package/lib/public.d.ts +2 -0
  363. package/lib/serializableDomainSchema.d.ts +3 -3
  364. package/lib/serializableDomainSchema.js +2 -2
  365. package/lib/serializableDomainSchema.js.map +1 -1
  366. package/lib/shared-tree/independentView.d.ts +1 -1
  367. package/lib/shared-tree/independentView.d.ts.map +1 -1
  368. package/lib/shared-tree/independentView.js +2 -2
  369. package/lib/shared-tree/independentView.js.map +1 -1
  370. package/lib/shared-tree/index.d.ts +4 -3
  371. package/lib/shared-tree/index.d.ts.map +1 -1
  372. package/lib/shared-tree/index.js +3 -3
  373. package/lib/shared-tree/index.js.map +1 -1
  374. package/lib/shared-tree/schematizeTree.d.ts +10 -11
  375. package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
  376. package/lib/shared-tree/schematizeTree.js +12 -37
  377. package/lib/shared-tree/schematizeTree.js.map +1 -1
  378. package/lib/shared-tree/schematizingTreeView.d.ts +3 -3
  379. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  380. package/lib/shared-tree/schematizingTreeView.js +6 -9
  381. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  382. package/lib/shared-tree/sharedTree.d.ts +28 -3
  383. package/lib/shared-tree/sharedTree.d.ts.map +1 -1
  384. package/lib/shared-tree/sharedTree.js +29 -4
  385. package/lib/shared-tree/sharedTree.js.map +1 -1
  386. package/lib/shared-tree/{treeApi.d.ts → tree.d.ts} +58 -34
  387. package/lib/shared-tree/tree.d.ts.map +1 -0
  388. package/lib/shared-tree/{treeApi.js → tree.js} +5 -5
  389. package/lib/shared-tree/tree.js.map +1 -0
  390. package/{dist/shared-tree/treeApiAlpha.d.ts → lib/shared-tree/treeAlpha.d.ts} +24 -14
  391. package/lib/shared-tree/treeAlpha.d.ts.map +1 -0
  392. package/lib/shared-tree/{treeApiAlpha.js → treeAlpha.js} +8 -6
  393. package/lib/shared-tree/treeAlpha.js.map +1 -0
  394. package/lib/shared-tree-core/branchCommitEnricher.d.ts +0 -1
  395. package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
  396. package/lib/shared-tree-core/branchCommitEnricher.js +0 -1
  397. package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
  398. package/lib/shared-tree-core/transactionEnricher.d.ts +1 -1
  399. package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
  400. package/lib/shared-tree-core/transactionEnricher.js +4 -1
  401. package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
  402. package/lib/simple-tree/api/conciseTree.d.ts +1 -1
  403. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  404. package/lib/simple-tree/api/configuration.d.ts +177 -0
  405. package/lib/simple-tree/api/configuration.d.ts.map +1 -0
  406. package/lib/simple-tree/api/configuration.js +157 -0
  407. package/lib/simple-tree/api/configuration.js.map +1 -0
  408. package/lib/simple-tree/api/getJsonSchema.js +1 -1
  409. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  410. package/lib/simple-tree/api/index.d.ts +9 -5
  411. package/lib/simple-tree/api/index.d.ts.map +1 -1
  412. package/lib/simple-tree/api/index.js +5 -4
  413. package/lib/simple-tree/api/index.js.map +1 -1
  414. package/lib/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
  415. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
  416. package/lib/simple-tree/api/{view.js → schemaCompatibilityTester.js} +7 -7
  417. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
  418. package/lib/simple-tree/api/schemaFactory.d.ts +25 -10
  419. package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
  420. package/lib/simple-tree/api/schemaFactory.js +27 -12
  421. package/lib/simple-tree/api/schemaFactory.js.map +1 -1
  422. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
  423. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  424. package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
  425. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  426. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
  427. package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
  428. package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
  429. package/lib/simple-tree/api/schemaFromSimple.d.ts +1 -1
  430. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  431. package/lib/simple-tree/api/schemaFromSimple.js +1 -1
  432. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  433. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
  434. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  435. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  436. package/lib/simple-tree/api/storedSchema.d.ts +11 -10
  437. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  438. package/lib/simple-tree/api/storedSchema.js +20 -13
  439. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  440. package/lib/simple-tree/api/tree.d.ts +30 -174
  441. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  442. package/lib/simple-tree/api/tree.js +0 -152
  443. package/lib/simple-tree/api/tree.js.map +1 -1
  444. package/{dist/simple-tree/api/treeApiBeta.d.ts → lib/simple-tree/api/treeBeta.d.ts} +17 -6
  445. package/lib/simple-tree/api/treeBeta.d.ts.map +1 -0
  446. package/lib/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
  447. package/lib/simple-tree/api/treeBeta.js.map +1 -0
  448. package/lib/simple-tree/api/treeChangeEvents.d.ts +83 -0
  449. package/lib/simple-tree/api/treeChangeEvents.d.ts.map +1 -0
  450. package/lib/simple-tree/api/treeChangeEvents.js +6 -0
  451. package/lib/simple-tree/api/treeChangeEvents.js.map +1 -0
  452. package/lib/simple-tree/api/treeNodeApi.d.ts +2 -1
  453. package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
  454. package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
  455. package/lib/simple-tree/api/typesUnsafe.d.ts +4 -9
  456. package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
  457. package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
  458. package/lib/simple-tree/arrayNode.d.ts +30 -2
  459. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  460. package/lib/simple-tree/arrayNode.js +4 -3
  461. package/lib/simple-tree/arrayNode.js.map +1 -1
  462. package/lib/simple-tree/arrayNodeTypes.d.ts +3 -3
  463. package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -1
  464. package/lib/simple-tree/arrayNodeTypes.js.map +1 -1
  465. package/lib/simple-tree/core/getOrCreateNode.d.ts +1 -1
  466. package/lib/simple-tree/core/getOrCreateNode.d.ts.map +1 -1
  467. package/lib/simple-tree/core/getOrCreateNode.js.map +1 -1
  468. package/lib/simple-tree/core/index.d.ts +2 -1
  469. package/lib/simple-tree/core/index.d.ts.map +1 -1
  470. package/lib/simple-tree/core/index.js +1 -1
  471. package/lib/simple-tree/core/index.js.map +1 -1
  472. package/lib/simple-tree/core/treeNode.d.ts +94 -0
  473. package/lib/simple-tree/core/treeNode.d.ts.map +1 -0
  474. package/lib/simple-tree/core/treeNode.js +118 -0
  475. package/lib/simple-tree/core/treeNode.js.map +1 -0
  476. package/lib/simple-tree/core/treeNodeKernel.d.ts +2 -1
  477. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  478. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  479. package/lib/simple-tree/core/treeNodeSchema.d.ts +3 -1
  480. package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
  481. package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
  482. package/lib/simple-tree/core/types.d.ts +0 -165
  483. package/lib/simple-tree/core/types.d.ts.map +1 -1
  484. package/lib/simple-tree/core/types.js +0 -110
  485. package/lib/simple-tree/core/types.js.map +1 -1
  486. package/lib/simple-tree/core/withType.d.ts +1 -1
  487. package/lib/simple-tree/core/withType.d.ts.map +1 -1
  488. package/lib/simple-tree/core/withType.js.map +1 -1
  489. package/lib/simple-tree/index.d.ts +4 -4
  490. package/lib/simple-tree/index.d.ts.map +1 -1
  491. package/lib/simple-tree/index.js +1 -1
  492. package/lib/simple-tree/index.js.map +1 -1
  493. package/lib/simple-tree/mapNode.d.ts +2 -2
  494. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  495. package/lib/simple-tree/mapNode.js +2 -2
  496. package/lib/simple-tree/mapNode.js.map +1 -1
  497. package/lib/simple-tree/mapNodeTypes.d.ts +3 -3
  498. package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -1
  499. package/lib/simple-tree/mapNodeTypes.js.map +1 -1
  500. package/lib/simple-tree/objectNode.d.ts +18 -5
  501. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  502. package/lib/simple-tree/objectNode.js +5 -4
  503. package/lib/simple-tree/objectNode.js.map +1 -1
  504. package/lib/simple-tree/objectNodeTypes.d.ts +4 -4
  505. package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
  506. package/lib/simple-tree/objectNodeTypes.js.map +1 -1
  507. package/lib/simple-tree/schemaTypes.d.ts +164 -13
  508. package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
  509. package/lib/simple-tree/schemaTypes.js +96 -8
  510. package/lib/simple-tree/schemaTypes.js.map +1 -1
  511. package/lib/simple-tree/toStoredSchema.d.ts +8 -8
  512. package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
  513. package/lib/simple-tree/toStoredSchema.js +26 -31
  514. package/lib/simple-tree/toStoredSchema.js.map +1 -1
  515. package/lib/simple-tree/treeNodeValid.js +2 -2
  516. package/lib/simple-tree/treeNodeValid.js.map +1 -1
  517. package/lib/tableSchema.d.ts +455 -125
  518. package/lib/tableSchema.d.ts.map +1 -1
  519. package/lib/tableSchema.js +398 -101
  520. package/lib/tableSchema.js.map +1 -1
  521. package/lib/treeFactory.d.ts +1 -1
  522. package/lib/treeFactory.d.ts.map +1 -1
  523. package/lib/treeFactory.js +30 -75
  524. package/lib/treeFactory.js.map +1 -1
  525. package/lib/util/typeUtils.d.ts +1 -1
  526. package/lib/util/typeUtils.js.map +1 -1
  527. package/package.json +21 -21
  528. package/src/codec/codec.ts +6 -1
  529. package/src/codec/index.ts +1 -0
  530. package/src/core/index.ts +1 -2
  531. package/src/core/schema-stored/index.ts +3 -3
  532. package/src/core/schema-stored/schema.ts +3 -1
  533. package/src/core/schema-stored/storedSchemaRepository.ts +1 -1
  534. package/src/core/schema-view/index.ts +0 -1
  535. package/src/core/schema-view/view.ts +0 -31
  536. package/src/core/tree/persistedTreeTextFormat.ts +2 -2
  537. package/src/feature-libraries/forest-summary/format.ts +2 -2
  538. package/src/feature-libraries/index.ts +7 -1
  539. package/src/feature-libraries/mapTreeCursor.ts +3 -3
  540. package/src/feature-libraries/modular-schema/modularChangeFormat.ts +3 -3
  541. package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +38 -9
  542. package/src/feature-libraries/schema-edits/schemaChangeFormat.ts +3 -4
  543. package/src/feature-libraries/schema-index/codec.ts +80 -12
  544. package/src/feature-libraries/schema-index/{format.ts → formatV1.ts} +4 -4
  545. package/src/feature-libraries/schema-index/index.ts +7 -2
  546. package/src/feature-libraries/schema-index/schemaSummarizer.ts +9 -9
  547. package/src/index.ts +18 -1
  548. package/src/internalTypes.ts +0 -2
  549. package/src/jsonDomainSchema.ts +2 -2
  550. package/src/packageVersion.ts +1 -1
  551. package/src/serializableDomainSchema.ts +3 -3
  552. package/src/shared-tree/independentView.ts +4 -3
  553. package/src/shared-tree/index.ts +5 -6
  554. package/src/shared-tree/schematizeTree.ts +10 -40
  555. package/src/shared-tree/schematizingTreeView.ts +12 -17
  556. package/src/shared-tree/sharedTree.ts +67 -6
  557. package/src/shared-tree/{treeApi.ts → tree.ts} +75 -51
  558. package/src/shared-tree/{treeApiAlpha.ts → treeAlpha.ts} +28 -16
  559. package/src/shared-tree-core/branchCommitEnricher.ts +0 -1
  560. package/src/shared-tree-core/transactionEnricher.ts +4 -1
  561. package/src/simple-tree/api/conciseTree.ts +1 -1
  562. package/src/simple-tree/api/configuration.ts +353 -0
  563. package/src/simple-tree/api/getJsonSchema.ts +1 -1
  564. package/src/simple-tree/api/index.ts +23 -15
  565. package/src/simple-tree/api/{view.ts → schemaCompatibilityTester.ts} +8 -15
  566. package/src/simple-tree/api/schemaFactory.ts +139 -19
  567. package/src/simple-tree/api/schemaFactoryAlpha.ts +7 -5
  568. package/src/simple-tree/api/schemaFactoryRecursive.ts +102 -38
  569. package/src/simple-tree/api/schemaFromSimple.ts +2 -2
  570. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
  571. package/src/simple-tree/api/storedSchema.ts +32 -17
  572. package/src/simple-tree/api/tree.ts +38 -354
  573. package/src/simple-tree/api/{treeApiBeta.ts → treeBeta.ts} +20 -6
  574. package/src/simple-tree/api/treeChangeEvents.ts +84 -0
  575. package/src/simple-tree/api/treeNodeApi.ts +1 -1
  576. package/src/simple-tree/api/typesUnsafe.ts +15 -11
  577. package/src/simple-tree/arrayNode.ts +38 -5
  578. package/src/simple-tree/arrayNodeTypes.ts +8 -7
  579. package/src/simple-tree/core/getOrCreateNode.ts +1 -1
  580. package/src/simple-tree/core/index.ts +5 -4
  581. package/src/simple-tree/core/treeNode.ts +163 -0
  582. package/src/simple-tree/core/treeNodeKernel.ts +2 -1
  583. package/src/simple-tree/core/treeNodeSchema.ts +3 -1
  584. package/src/simple-tree/core/types.ts +0 -234
  585. package/src/simple-tree/core/withType.ts +1 -1
  586. package/src/simple-tree/index.ts +19 -2
  587. package/src/simple-tree/mapNode.ts +11 -3
  588. package/src/simple-tree/mapNodeTypes.ts +10 -7
  589. package/src/simple-tree/objectNode.ts +39 -15
  590. package/src/simple-tree/objectNodeTypes.ts +9 -5
  591. package/src/simple-tree/schemaTypes.ts +354 -25
  592. package/src/simple-tree/toStoredSchema.ts +42 -41
  593. package/src/simple-tree/treeNodeValid.ts +2 -2
  594. package/src/tableSchema.ts +1206 -434
  595. package/src/treeFactory.ts +56 -173
  596. package/src/util/typeUtils.ts +1 -1
  597. package/dist/core/schema-stored/format.d.ts.map +0 -1
  598. package/dist/core/schema-stored/format.js.map +0 -1
  599. package/dist/feature-libraries/schema-index/format.d.ts.map +0 -1
  600. package/dist/feature-libraries/schema-index/format.js.map +0 -1
  601. package/dist/shared-tree/treeApi.d.ts.map +0 -1
  602. package/dist/shared-tree/treeApi.js.map +0 -1
  603. package/dist/shared-tree/treeApiAlpha.d.ts.map +0 -1
  604. package/dist/shared-tree/treeApiAlpha.js.map +0 -1
  605. package/dist/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  606. package/dist/simple-tree/api/treeApiBeta.js.map +0 -1
  607. package/dist/simple-tree/api/view.d.ts.map +0 -1
  608. package/dist/simple-tree/api/view.js.map +0 -1
  609. package/lib/core/schema-stored/format.d.ts.map +0 -1
  610. package/lib/core/schema-stored/format.js.map +0 -1
  611. package/lib/feature-libraries/schema-index/format.d.ts.map +0 -1
  612. package/lib/feature-libraries/schema-index/format.js.map +0 -1
  613. package/lib/shared-tree/treeApi.d.ts.map +0 -1
  614. package/lib/shared-tree/treeApi.js.map +0 -1
  615. package/lib/shared-tree/treeApiAlpha.d.ts.map +0 -1
  616. package/lib/shared-tree/treeApiAlpha.js.map +0 -1
  617. package/lib/simple-tree/api/treeApiBeta.d.ts.map +0 -1
  618. package/lib/simple-tree/api/treeApiBeta.js.map +0 -1
  619. package/lib/simple-tree/api/view.d.ts.map +0 -1
  620. package/lib/simple-tree/api/view.js.map +0 -1
  621. /package/src/core/schema-stored/{format.ts → formatV1.ts} +0 -0
@@ -4,11 +4,12 @@
4
4
  */
5
5
 
6
6
  import { oob } from "@fluidframework/core-utils/internal";
7
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
7
8
 
8
9
  import { Tree } from "./shared-tree/index.js";
9
10
  import {
11
+ type FieldHasDefault,
10
12
  type ImplicitAllowedTypes,
11
- type ImplicitFieldSchema,
12
13
  type InsertableObjectFromSchemaRecord,
13
14
  type InsertableTreeNodeFromImplicitAllowedTypes,
14
15
  type NodeKind,
@@ -20,83 +21,187 @@ import {
20
21
  type TreeNodeSchema,
21
22
  type TreeNodeSchemaClass,
22
23
  type WithType,
24
+ type TreeFieldFromImplicitField,
25
+ type InsertableTreeFieldFromImplicitField,
26
+ type InternalTreeNode,
27
+ SchemaFactory,
28
+ type ImplicitAnnotatedFieldSchema,
29
+ type UnannotateImplicitFieldSchema,
23
30
  } from "./simple-tree/index.js";
24
31
 
25
- // Future improvement TODOs (ideally to be done before promoting these APIs to `@alpha`):
26
- // - Custom fields on Table/Row/Column (props pattern from Nick's demo)
27
- // - Overloads to make Column/Row schema optional when constructing Tables
32
+ // Future improvement TODOs:
33
+ // - Omit `cells` property from Row insertion type.
28
34
  // - Record-like type parameters / input parameters?
29
- // - Move `@system` types into separate / sub scope?
35
+ // - Omit `props` properties from Row and Column schemas when not provided?
36
+
37
+ // Longer-term work:
38
+ // - Add constraint APIs to make it possible to avoid situations that could yield "orphaned" cells.
30
39
 
31
40
  /**
32
- * Contains types and factories for creating schema to represent dynamic tabular data.
33
- * @privateRemarks TODO: document in more detail and add `@example`s.
34
- * @internal
41
+ * The sub-scope applied to user-provided {@link SchemaFactory}s by table schema factories.
35
42
  */
36
- export namespace TableSchema {
37
- const tableSchemaFactorySubScope = "table";
43
+ const tableSchemaFactorySubScope = "table";
38
44
 
39
- // #region Column
45
+ /**
46
+ * Not intended for use outside of this package.
47
+ *
48
+ * @privateRemarks
49
+ * This namespace is a collection of internal system types relate to {@link TableSchema}.
50
+ * This namespace should be strictly type-exported by the package.
51
+ * All members should be tagged with `@system`.
52
+ *
53
+ * @system @internal
54
+ */
55
+ export namespace System_TableSchema {
56
+ /**
57
+ * Default type used for column and row "props" fields.
58
+ * @privateRemarks
59
+ * Longer term, it would be better to simply omit "props" altogether by default.
60
+ * For now, this ensures that the user doesn't have to specify a "props" entry when initializing column/row nodes
61
+ * and ensures that they cannot set anything that might conflict with future evolutions of the schema.
62
+ * @system @internal
63
+ */
64
+ export type DefaultPropsType = ReturnType<typeof SchemaFactory.optional<[]>>;
40
65
 
41
66
  /**
42
- * A column in a table.
43
- * @remarks Implemented by the schema class returned from {@link TableSchema.createColumn}.
44
- * @sealed @internal
67
+ * A base interface for factory input options which include an schema factory.
68
+ * @remarks This interface should not be referenced directly.
69
+ * @privateRemarks This interface primarily exists to provide a single home for property documentation.
70
+ * @system @internal
45
71
  */
46
- export interface IColumn<TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes> {
72
+ export interface OptionsWithSchemaFactory<TSchemaFactory extends SchemaFactoryAlpha> {
47
73
  /**
48
- * The unique identifier of the column.
49
- * @remarks Uniquely identifies the node within the entire tree, not just the table.
74
+ * Schema factory with which the Column schema will be associated.
75
+ * @remarks Can be used to associate the resulting schema with an existing {@link SchemaFactory.scope|scope}.
50
76
  */
51
- readonly id: string;
77
+ readonly schemaFactory: TSchemaFactory;
78
+ }
52
79
 
80
+ /**
81
+ * A base interface for factory input options which include the table cell schema.
82
+ * @remarks This interface should not be referenced directly.
83
+ * @privateRemarks This interface primarily exists to provide a single home for property documentation.
84
+ * @system @internal
85
+ */
86
+ export interface OptionsWithCellSchema<TCellSchema extends ImplicitAllowedTypes> {
53
87
  /**
54
- * User-provided column properties.
88
+ * Schema for the table's cells.
55
89
  */
56
- get props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;
57
- set props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);
90
+ readonly cell: TCellSchema;
58
91
  }
59
92
 
93
+ // #region Column
94
+
95
+ /**
96
+ * Base options for creating table cow schema.
97
+ * @remarks Includes parameters common to all column factory overloads.
98
+ * @system @internal
99
+ */
100
+ export type CreateColumnOptionsBase<
101
+ TSchemaFactory extends SchemaFactoryAlpha = SchemaFactoryAlpha,
102
+ > = OptionsWithSchemaFactory<TSchemaFactory>;
103
+
60
104
  /**
61
105
  * Factory for creating new table column schema.
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
- * @internal
106
+ * @system @internal
68
107
  */
69
108
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
70
- export function createColumn<
109
+ export function createColumnInternal<
71
110
  const TInputScope extends string | undefined,
72
- const TPropsSchema extends ImplicitAllowedTypes,
111
+ const TPropsSchema extends ImplicitAnnotatedFieldSchema,
73
112
  >(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {
74
113
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
75
114
  type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
76
115
 
116
+ // Note: `columnFields` is broken into two parts to work around a TypeScript bug
117
+ // that results in broken `.d.ts` output.
118
+ // See definition of `ColumnInsertableType` below.
119
+ const columnFieldsBuiltInParts = {
120
+ id: schemaFactory.identifier,
121
+ } as const;
122
+ const columnFieldsPropsPart = {
123
+ props: propsSchema,
124
+ } as const;
125
+
77
126
  /**
78
127
  * {@link Column} fields.
79
- * @remarks Extracted for re-use in returned type signature defined later in this function.
128
+ *
129
+ * @remarks
130
+ * Extracted for re-use in returned type signature defined later in this function.
80
131
  * The implicit typing is intentional.
132
+ *
81
133
  * Note: ideally we would add a satisfies clause here to ensure that this satisfies
82
134
  * `Record<string, ImplicitFieldSchema>`, but doing so causes TypeScript to prematurely and incorrectly evaluate the type of `propsSchema`.
83
135
  * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
84
136
  */
85
137
  const columnFields = {
86
- id: schemaFactory.identifier,
87
- props: schemaFactory.required(propsSchema),
88
- } as const;
138
+ ...columnFieldsBuiltInParts,
139
+ ...columnFieldsPropsPart,
140
+ } as const; // satisfies Record<string, ImplicitFieldSchema>;
89
141
 
90
142
  /**
91
143
  * A column in a table.
92
144
  */
93
- class Column extends schemaFactory.object("Column", columnFields) {}
145
+ class Column
146
+ extends schemaFactory.objectAlpha("Column", columnFields, {
147
+ // Will make it easier to evolve this schema in the future.
148
+ allowUnknownOptionalFields: true,
149
+ })
150
+ implements TableSchema.Column<TPropsSchema> {}
94
151
 
95
152
  type ColumnValueType = TreeNode &
96
- IColumn<TPropsSchema> &
153
+ TableSchema.Column<TPropsSchema> &
97
154
  WithType<ScopedSchemaName<Scope, "Column">>;
98
155
 
99
- type ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;
156
+ // Note: ideally this type would just leverage `InsertableObjectFromSchemaRecord<typeof columnFields>`,
157
+ // but that results in broken `.d.ts` output due to a TypeScript bug.
158
+ // See: https://github.com/microsoft/TypeScript/issues/58688.
159
+ // Instead we extract and inline the typing of the "props" field here, which seems to sufficiently work around the issue.
160
+ // type ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;
161
+ type ColumnInsertableType = InsertableObjectFromSchemaRecord<
162
+ typeof columnFieldsBuiltInParts
163
+ > &
164
+ (FieldHasDefault<UnannotateImplicitFieldSchema<TPropsSchema>> extends true
165
+ ? // Note: The docs on the below properties are copied from `IColumn.props`' docs to ensure that the
166
+ // documentation appears in the data insertion scenario.
167
+ // The contents are duplicated instead of using `@inheritdoc`, as intellisense does not correctly
168
+ // support `@inheritDoc`.
169
+ // See: https://github.com/microsoft/TypeScript/issues/31267
170
+ {
171
+ /**
172
+ * The column's properties.
173
+ * @remarks This is a user-defined schema that can be used to store additional information about the column.
174
+ */
175
+ props?: InsertableTreeFieldFromImplicitField<
176
+ UnannotateImplicitFieldSchema<TPropsSchema>
177
+ >;
178
+ }
179
+ : {
180
+ /**
181
+ * The column's properties.
182
+ * @remarks This is a user-defined schema that can be used to store additional information about the column.
183
+ */
184
+ props: InsertableTreeFieldFromImplicitField<
185
+ UnannotateImplicitFieldSchema<TPropsSchema>
186
+ >;
187
+ });
188
+
189
+ // Modified version of `Column` that ensures the constructor (and `createFromInsertable`) are
190
+ // typed correctly in terms of our insertable type.
191
+ // This lets us be selective in our type-cast for the value returned from this function,
192
+ // preserving as much type-safety as we reasonably can.
193
+ type ColumnSchemaModifiedType = Omit<
194
+ // Use mapped type to omit the constructor
195
+ {
196
+ [Property in keyof typeof Column]: (typeof Column)[Property];
197
+ },
198
+ "createFromInsertable"
199
+ > &
200
+ (new (
201
+ parameters: InternalTreeNode | ColumnInsertableType,
202
+ ) => Column) & {
203
+ createFromInsertable(parameters: ColumnInsertableType): Column;
204
+ };
100
205
 
101
206
  // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
102
207
  // for the private brand field of TreeNode.
@@ -110,7 +215,7 @@ export namespace TableSchema {
110
215
  /* TInsertable */ object & ColumnInsertableType,
111
216
  /* ImplicitlyConstructable */ true,
112
217
  /* Info */ typeof columnFields
113
- > = Column;
218
+ > = Column as ColumnSchemaModifiedType;
114
219
 
115
220
  return ColumnSchemaType;
116
221
  }
@@ -120,91 +225,34 @@ export namespace TableSchema {
120
225
  * @sealed @system @internal
121
226
  */
122
227
  export type ColumnSchemaBase<
123
- TScope extends string | undefined,
124
- TPropsSchema extends ImplicitAllowedTypes,
125
- > = ReturnType<typeof createColumn<TScope, TPropsSchema>>;
228
+ TScope extends string | undefined = string | undefined,
229
+ TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
230
+ > = ReturnType<typeof createColumnInternal<TScope, TPropsSchema>>;
126
231
 
127
232
  // #endregion
128
233
 
129
234
  // #region Row
130
235
 
131
236
  /**
132
- * A row in a table.
133
- * @remarks Implemented by the schema class returned from {@link TableSchema.createRow}.
134
- * @sealed @internal
237
+ * Base options for creating table row schema.
238
+ * @remarks Includes parameters common to all row factory overloads.
239
+ * @system @internal
135
240
  */
136
- export interface IRow<
137
- TCellSchema extends ImplicitAllowedTypes,
138
- TPropsSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
139
- > {
140
- /**
141
- * The unique identifier of the row.
142
- * @remarks Uniquely identifies the node within the entire tree, not just the table.
143
- */
144
- readonly id: string;
145
-
146
- /**
147
- * Gets the cell in the specified column.
148
- * @returns The cell if it exists, otherwise undefined.
149
- */
150
- getCell(column: IColumn): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
151
- /**
152
- * Gets the cell in the specified column, denoted by column ID.
153
- * @returns The cell if it exists, otherwise undefined.
154
- */
155
- getCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
156
-
157
- /**
158
- * Sets the cell in the specified column.
159
- * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:1)} instead.
160
- */
161
- setCell(
162
- column: IColumn,
163
- value: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,
164
- ): void;
165
- /**
166
- * Sets the cell in the specified column, denoted by column ID.
167
- * @remarks To remove a cell, call {@link TableSchema.IRow.(removeCell:2)} instead.
168
- */
169
- setCell(
170
- columnId: string,
171
- value: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,
172
- ): void;
173
-
174
- /**
175
- * Removes the cell in the specified column.
176
- * @privateRemarks TODO: return removed cell
177
- */
178
- removeCell(column: IColumn): void;
179
- /**
180
- * Removes the cell in the specified column, denoted by column ID.
181
- * @privateRemarks TODO: return removed cell
182
- */
183
- removeCell(columnId: string): void;
184
-
185
- /**
186
- * User-provided row properties.
187
- */
188
- get props(): TreeNodeFromImplicitAllowedTypes<TPropsSchema>;
189
- set props(value: InsertableTreeNodeFromImplicitAllowedTypes<TPropsSchema>);
190
- }
241
+ export type CreateRowOptionsBase<
242
+ TSchemaFactory extends SchemaFactoryAlpha = SchemaFactoryAlpha,
243
+ TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
244
+ > = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
191
245
 
192
246
  /**
193
247
  * Factory for creating new table row schema.
194
248
  *
195
- * @privateRemarks
196
- * TODO:
197
- * - Add overloads to make propsSchema optional.
198
- * - Take field schema rather than node schema for `propsSchema`, in particular to allow making
199
- * the additional properties optional.
200
- *
201
249
  * @sealed @internal
202
250
  */
203
251
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
204
- export function createRow<
252
+ export function createRowInternal<
205
253
  const TInputScope extends string | undefined,
206
254
  const TCellSchema extends ImplicitAllowedTypes,
207
- const TPropsSchema extends ImplicitAllowedTypes,
255
+ const TPropsSchema extends ImplicitAnnotatedFieldSchema,
208
256
  >(
209
257
  inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
210
258
  cellSchema: TCellSchema,
@@ -216,6 +264,21 @@ export namespace TableSchema {
216
264
  type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
217
265
  type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;
218
266
 
267
+ // Note: `rowFields` is broken into two parts to work around a TypeScript bug
268
+ // that results in broken `.d.ts` output.
269
+ // See definition of `RowInsertableType` below.
270
+ const rowFieldsBuiltInParts = {
271
+ id: schemaFactory.identifier,
272
+ cells: schemaFactory.required(schemaFactory.map("Row.cells", cellSchema), {
273
+ metadata: {
274
+ description: "The cells of the table row, keyed by column ID.",
275
+ },
276
+ }),
277
+ } as const;
278
+ const rowFieldsPropsPart = {
279
+ props: propsSchema,
280
+ } as const;
281
+
219
282
  /**
220
283
  * {@link Row} fields.
221
284
  * @remarks Extracted for re-use in returned type signature defined later in this function.
@@ -225,44 +288,104 @@ export namespace TableSchema {
225
288
  * Likely related to the following issue: https://github.com/microsoft/TypeScript/issues/52394
226
289
  */
227
290
  const rowFields = {
228
- id: schemaFactory.identifier,
229
- cells: schemaFactory.map("Row.cells", cellSchema),
230
- props: schemaFactory.required(propsSchema),
231
- } as const;
291
+ ...rowFieldsBuiltInParts,
292
+ ...rowFieldsPropsPart,
293
+ } as const; // satisfies Record<string, ImplicitFieldSchema>;
232
294
 
233
295
  /**
234
296
  * The Row schema - this is a map of Cells where the key is the column id
235
297
  */
236
298
  class Row
237
- extends schemaFactory.object("Row", rowFields)
238
- implements IRow<TCellSchema, TPropsSchema>
299
+ extends schemaFactory.objectAlpha("Row", rowFields, {
300
+ // Will make it easier to evolve this schema in the future.
301
+ allowUnknownOptionalFields: true,
302
+ })
303
+ implements TableSchema.Row<TCellSchema, TPropsSchema>
239
304
  {
240
- public getCell(columnOrId: IColumn | string): CellValueType | undefined {
305
+ public getCell(columnOrId: TableSchema.Column | string): CellValueType | undefined {
241
306
  const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
242
307
  return this.cells.get(columnId) as CellValueType | undefined;
243
308
  }
244
309
 
245
310
  public setCell(
246
- columnOrId: IColumn | string,
311
+ columnOrId: TableSchema.Column | string,
247
312
  value: CellInsertableType | undefined,
248
313
  ): void {
314
+ // TODO: throw if column does not exist in the owning table.
315
+
249
316
  const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
250
317
  this.cells.set(columnId, value);
251
318
  }
252
319
 
253
- public removeCell(columnOrId: IColumn | string): void {
320
+ public removeCell(columnOrId: TableSchema.Column | string): CellValueType | undefined {
321
+ // TODO: throw if column does not exist in the owning table.
322
+
254
323
  const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
255
- if (!this.cells.has(columnId)) {
256
- return;
324
+
325
+ const cell: CellValueType | undefined = this.cells.get(columnId);
326
+ if (cell === undefined) {
327
+ return undefined;
257
328
  }
329
+
258
330
  this.cells.delete(columnId);
331
+ return cell;
259
332
  }
260
333
  }
261
334
 
262
335
  type RowValueType = TreeNode &
263
- IRow<TCellSchema, TPropsSchema> &
336
+ TableSchema.Row<TCellSchema, TPropsSchema> &
264
337
  WithType<ScopedSchemaName<Scope, "Row">>;
265
- type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;
338
+
339
+ // Note: ideally this type would just leverage `InsertableObjectFromSchemaRecord<typeof rowFields>`,
340
+ // but that results in broken `.d.ts` output due to a TypeScript bug.
341
+ // See: https://github.com/microsoft/TypeScript/issues/58688.
342
+ // Instead we extract and inline the typing of the "props" field here, which seems to sufficiently work around
343
+ // the issue.
344
+ // type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;
345
+ type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFieldsBuiltInParts> &
346
+ (FieldHasDefault<UnannotateImplicitFieldSchema<TPropsSchema>> extends true
347
+ ? // Note: The docs on the below properties are copied from `IRow.props`' docs to ensure that the
348
+ // documentation appears in the data insertion scenario.
349
+ // The contents are duplicated instead of using `@inheritdoc`, as intellisense does not correctly
350
+ // support `@inheritDoc`.
351
+ // See: https://github.com/microsoft/TypeScript/issues/31267
352
+ {
353
+ /**
354
+ * The row's properties.
355
+ * @remarks This is a user-defined schema that can be used to store additional information
356
+ * about the row.
357
+ */
358
+ props?: InsertableTreeFieldFromImplicitField<
359
+ UnannotateImplicitFieldSchema<TPropsSchema>
360
+ >;
361
+ }
362
+ : {
363
+ /**
364
+ * The row's properties.
365
+ * @remarks This is a user-defined schema that can be used to store additional information
366
+ * about the row.
367
+ */
368
+ props: InsertableTreeFieldFromImplicitField<
369
+ UnannotateImplicitFieldSchema<TPropsSchema>
370
+ >;
371
+ });
372
+
373
+ // Modified version of `Row` that ensures the constructor (and `createFromInsertable`) are
374
+ // typed correctly in terms of our insertable type.
375
+ // This lets us be selective in our type-cast for the value returned from this function,
376
+ // preserving as much type-safety as we reasonably can.
377
+ type RowSchemaModifiedType = Omit<
378
+ // Use mapped type to omit the constructor
379
+ {
380
+ [Property in keyof typeof Row]: (typeof Row)[Property];
381
+ },
382
+ "createFromInsertable"
383
+ > &
384
+ (new (
385
+ parameters: InternalTreeNode | RowInsertableType,
386
+ ) => Row) & {
387
+ createFromInsertable(parameters: RowInsertableType): Row;
388
+ };
266
389
 
267
390
  // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
268
391
  // for the private brand field of TreeNode.
@@ -276,7 +399,7 @@ export namespace TableSchema {
276
399
  /* TInsertable */ object & RowInsertableType,
277
400
  /* ImplicitlyConstructable */ true,
278
401
  /* Info */ typeof rowFields
279
- > = Row;
402
+ > = Row as RowSchemaModifiedType;
280
403
 
281
404
  return RowSchemaType;
282
405
  }
@@ -286,232 +409,24 @@ export namespace TableSchema {
286
409
  * @sealed @system @internal
287
410
  */
288
411
  export type RowSchemaBase<
289
- TScope extends string | undefined,
290
- TCellSchema extends ImplicitAllowedTypes,
291
- TPropsSchema extends ImplicitAllowedTypes,
292
- > = ReturnType<typeof createRow<TScope, TCellSchema, TPropsSchema>>;
412
+ TScope extends string | undefined = string | undefined,
413
+ TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
414
+ TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
415
+ > = ReturnType<typeof createRowInternal<TScope, TCellSchema, TPropsSchema>>;
293
416
 
294
417
  // #endregion
295
418
 
296
419
  // #region Table
297
420
 
298
421
  /**
299
- * A key to uniquely identify a cell in a table.
300
- * @sealed @internal
301
- */
302
- export interface CellKey {
303
- /**
304
- * {@link TableSchema.IColumn.id} of the containing {@link TableSchema.IColumn}.
305
- */
306
- readonly columnId: string;
307
-
308
- /**
309
- * {@link TableSchema.IRow.id} of the containing {@link TableSchema.IRow}.
310
- */
311
- readonly rowId: string;
312
- }
313
-
314
- /**
315
- * {@link TableSchema.ITable.insertColumn} parameters.
316
- * @sealed @internal
317
- */
318
- export interface InsertColumnParameters<TInsertableColumn> {
319
- /**
320
- * The index at which to insert the new column.
321
- * @remarks If not provided, the column will be appended to the end of the table.
322
- */
323
- readonly index?: number | undefined;
324
-
325
- /**
326
- * The column to insert.
327
- */
328
- readonly column: TInsertableColumn;
329
- }
330
-
331
- /**
332
- * {@link TableSchema.ITable.insertRows} parameters.
333
- * @sealed @internal
334
- */
335
- export interface InsertRowsParameters<TInsertableRow> {
336
- /**
337
- * The index at which to insert the new rows.
338
- * @remarks If not provided, the rows will be appended to the end of the table.
339
- */
340
- readonly index?: number | undefined;
341
-
342
- /**
343
- * The rows to insert.
344
- */
345
- readonly rows: TInsertableRow[];
346
- }
347
-
348
- /**
349
- * {@link TableSchema.ITable.setCell} parameters.
350
- * @sealed @internal
351
- */
352
- export interface SetCellParameters<TInsertableCell> {
353
- /**
354
- * The key to uniquely identify a cell in a table.
355
- */
356
- readonly key: CellKey;
357
-
358
- /**
359
- * The cell to set.
360
- */
361
- readonly cell: TInsertableCell;
362
- }
363
-
364
- /**
365
- * A table.
366
- * @sealed @internal
367
- */
368
- export interface ITable<
369
- TCellSchema extends ImplicitAllowedTypes,
370
- TColumnSchema extends ImplicitAllowedTypes,
371
- TRowSchema extends ImplicitAllowedTypes,
372
- > {
373
- /**
374
- * The table's columns.
375
- */
376
- readonly columns: TreeArrayNode<TColumnSchema>;
377
-
378
- /**
379
- * The table's rows.
380
- */
381
- readonly rows: TreeArrayNode<TRowSchema>;
382
-
383
- /**
384
- * Gets a table column by its {@link TableSchema.IRow.id}.
385
- */
386
- getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumnSchema> | undefined;
387
-
388
- /**
389
- * Gets a table row by its {@link TableSchema.IRow.id}.
390
- */
391
- getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRowSchema> | undefined;
392
-
393
- /**
394
- * Gets a cell in the table by column and row IDs.
395
- * @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.
396
- * @privateRemarks TODO: add overload that takes row and column nodes.
397
- */
398
- getCell(key: CellKey): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
399
-
400
- /**
401
- * Inserts a column into the table.
402
- * @throws Throws an error if the column is already in the tree, or if the specified index is out of range.
403
- */
404
- insertColumn(
405
- params: InsertColumnParameters<
406
- InsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>
407
- >,
408
- ): TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
409
-
410
- /**
411
- * Inserts 0 or more rows into the table.
412
- * @throws Throws an error if any of the rows are already in the tree, or if the specified index is out of range.
413
- */
414
- insertRows(
415
- params: InsertRowsParameters<InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>>,
416
- ): TreeNodeFromImplicitAllowedTypes<TRowSchema>[];
417
-
418
- /**
419
- * Sets the cell at the specified location in the table.
420
- * @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.
421
- * @privateRemarks TODO: add overload that takes column/row nodes?
422
- */
423
- setCell(
424
- params: SetCellParameters<InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>>,
425
- ): void;
426
-
427
- /**
428
- * Removes the specified column from the table.
429
- * @remarks Note: this does not remove any cells from the table's rows.
430
- * @privateRemarks
431
- * TODO:
432
- * - Policy for when the column is not in the table.
433
- * - Actually remove corresponding cells from table rows.
434
- */
435
- removeColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;
436
-
437
- /**
438
- * Removes 0 or more rows from the table.
439
- * @privateRemarks TODO: policy for when 1 or more rows are not in the table.
440
- */
441
- removeRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
442
-
443
- /**
444
- * Removes all rows from the table.
445
- */
446
- removeAllRows: () => void;
447
-
448
- /**
449
- * Removes the cell at the specified location in the table.
450
- * @privateRemarks TODO: add overload that takes column/row nodes?
451
- */
452
- removeCell: (key: CellKey) => void;
453
- }
454
-
455
- /**
456
- * Factory for creating new table schema without specifying row or column schema.
457
- * @internal
458
- */
459
- export function createTable<
460
- const TInputScope extends string | undefined,
461
- const TCell extends ImplicitAllowedTypes,
462
- >(
463
- inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
464
- _cellSchema: TCell,
465
- ): ReturnType<typeof createTableInternal<TInputScope, TCell>>;
466
- /**
467
- * Factory for creating new table schema without specifying row schema
468
- * @internal
469
- */
470
- export function createTable<
471
- const TInputScope extends string | undefined,
472
- const TCell extends ImplicitAllowedTypes,
473
- const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
474
- >(
475
- inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
476
- _cellSchema: TCell,
477
- columnSchema: TColumn,
478
- ): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn>>;
479
- /**
480
- * Factory for creating new table schema.
481
- * @internal
422
+ * Base options for creating table schema.
423
+ * @remarks Includes parameters common to all table factory overloads.
424
+ * @system @internal
482
425
  */
483
- export function createTable<
484
- const TInputScope extends string | undefined,
485
- const TCell extends ImplicitAllowedTypes,
486
- const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
487
- const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,
488
- >(
489
- inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
490
- _cellSchema: TCell,
491
- columnSchema: TColumn,
492
- rowSchema: TRow,
493
- ): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn, TRow>>;
494
- /** `createTable` implementation */
495
- export function createTable<
496
- const TInputScope extends string | undefined,
497
- const TCell extends ImplicitAllowedTypes,
498
- const TColumn extends ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
499
- const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes>,
500
- >(
501
- inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
502
- _cellSchema: TCell,
503
- columnSchema?: TColumn,
504
- rowSchema?: TRow,
505
- ): TreeNodeSchema {
506
- const column = columnSchema ?? createColumn(inputSchemaFactory, inputSchemaFactory.null);
507
- return createTableInternal(
508
- inputSchemaFactory,
509
- _cellSchema,
510
- column as TColumn,
511
- rowSchema ??
512
- (createRow(inputSchemaFactory, _cellSchema, inputSchemaFactory.null) as TRow),
513
- );
514
- }
426
+ export type TableFactoryOptionsBase<
427
+ TSchemaFactory extends SchemaFactoryAlpha = SchemaFactoryAlpha,
428
+ TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
429
+ > = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
515
430
 
516
431
  /**
517
432
  * Factory for creating new table schema.
@@ -520,33 +435,21 @@ export namespace TableSchema {
520
435
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
521
436
  export function createTableInternal<
522
437
  const TInputScope extends string | undefined,
523
- const TCell extends ImplicitAllowedTypes,
524
- const TColumn extends ColumnSchemaBase<
525
- TInputScope,
526
- ImplicitAllowedTypes
527
- > = ColumnSchemaBase<TInputScope, ImplicitAllowedTypes>,
528
- const TRow extends RowSchemaBase<TInputScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<
529
- TInputScope,
530
- TCell,
531
- ImplicitAllowedTypes
532
- >,
438
+ const TCellSchema extends ImplicitAllowedTypes,
439
+ const TColumnSchema extends ColumnSchemaBase<TInputScope>,
440
+ const TRowSchema extends RowSchemaBase<TInputScope, TCellSchema>,
533
441
  >(
534
442
  inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
535
- _cellSchema: TCell,
536
- columnSchema: TColumn,
537
- rowSchema: TRow,
443
+ _cellSchema: TCellSchema,
444
+ columnSchema: TColumnSchema,
445
+ rowSchema: TRowSchema,
538
446
  ) {
539
447
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
540
448
  type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
541
449
 
542
- type CellValueType = TreeNodeFromImplicitAllowedTypes<TCell>;
543
- type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCell>;
544
-
545
- type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumn>;
546
- type ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumn>;
547
-
548
- type RowValueType = TreeNodeFromImplicitAllowedTypes<TRow>;
549
- type RowInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TRow>;
450
+ type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
451
+ type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
452
+ type RowValueType = TreeNodeFromImplicitAllowedTypes<TRowSchema>;
550
453
 
551
454
  /**
552
455
  * {@link Table} fields.
@@ -556,14 +459,17 @@ export namespace TableSchema {
556
459
  const tableFields = {
557
460
  rows: schemaFactory.array("Table.rows", rowSchema),
558
461
  columns: schemaFactory.array("Table.columns", columnSchema),
559
- } as const satisfies Record<string, ImplicitFieldSchema>;
462
+ } as const satisfies Record<string, ImplicitAnnotatedFieldSchema>;
560
463
 
561
464
  /**
562
465
  * The Table schema
563
466
  */
564
467
  class Table
565
- extends schemaFactory.object("Table", tableFields)
566
- implements ITable<TCell, TColumn, TRow>
468
+ extends schemaFactory.objectAlpha("Table", tableFields, {
469
+ // Will make it easier to evolve this schema in the future.
470
+ allowUnknownOptionalFields: true,
471
+ })
472
+ implements TableSchema.Table<TCellSchema, TColumnSchema, TRowSchema>
567
473
  {
568
474
  public getColumn(id: string): ColumnValueType | undefined {
569
475
  // TypeScript is unable to narrow the types correctly here, hence the casts.
@@ -581,51 +487,130 @@ export namespace TableSchema {
581
487
  | undefined;
582
488
  }
583
489
 
584
- public getCell(key: CellKey): CellValueType | undefined {
585
- const { columnId, rowId } = key;
586
- const row = this.getRow(rowId);
587
- if (row !== undefined) {
588
- const column = this.getColumn(columnId);
589
- if (column !== undefined) {
590
- return row.getCell(column.id);
591
- }
490
+ public getCell(
491
+ key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
492
+ ): CellValueType | undefined {
493
+ const { column: columnOrId, row: rowOrId } = key;
494
+ const row = this._getRow(rowOrId);
495
+ if (row === undefined) {
496
+ return undefined;
497
+ }
498
+
499
+ const column = this._getColumn(columnOrId);
500
+ if (column === undefined) {
501
+ return undefined;
592
502
  }
593
- // If the cell does not exist return undefined
594
- return undefined;
503
+
504
+ return row.getCell(column);
595
505
  }
596
506
 
597
507
  public insertColumn({
598
508
  column,
599
509
  index,
600
- }: InsertColumnParameters<ColumnInsertableType>): ColumnValueType {
601
- if (index === undefined) {
602
- // TypeScript is unable to narrow the types correctly here, hence the cast.
510
+ }: TableSchema.InsertColumnParameters<TColumnSchema>): ColumnValueType {
511
+ const inserted = this.insertColumns({
512
+ columns: [column],
513
+ index,
514
+ });
515
+ return inserted[0] ?? oob();
516
+ }
517
+
518
+ public insertColumns({
519
+ columns,
520
+ index,
521
+ }: TableSchema.InsertColumnsParameters<TColumnSchema>): ColumnValueType[] {
522
+ // #region Input validation
523
+
524
+ // Ensure index is valid
525
+ if (index !== undefined) {
526
+ Table.validateInsertionIndex(index, this.columns);
527
+ }
528
+
529
+ // Check all of the columns being inserted an ensure the table does not already contain any with the same ID.
530
+ for (const column of columns) {
531
+ // TypeScript is unable to narrow the type of the column type correctly here, hence the casts below.
603
532
  // See: https://github.com/microsoft/TypeScript/issues/52144
533
+ const maybeId = (column as ColumnValueType).id;
534
+ if (maybeId !== undefined && this.containsColumnWithId(maybeId)) {
535
+ throw new UsageError(
536
+ `A column with ID "${(column as ColumnValueType).id}" already exists in the table.`,
537
+ );
538
+ }
539
+ }
540
+
541
+ // #endregion
542
+
543
+ // TypeScript is unable to narrow the column type correctly here, hence the casts below.
544
+ // See: https://github.com/microsoft/TypeScript/issues/52144
545
+ if (index === undefined) {
604
546
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
605
- this.columns.insertAtEnd(column as any);
547
+ this.columns.insertAtEnd(TreeArrayNode.spread(columns) as any);
606
548
  } else {
607
- // TypeScript is unable to narrow the types correctly here, hence the cast.
608
- // See: https://github.com/microsoft/TypeScript/issues/52144
609
549
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
610
- this.columns.insertAt(index, column as any);
550
+ this.columns.insertAt(index, TreeArrayNode.spread(columns) as any);
611
551
  }
612
552
 
613
- // Inserting the input node into the tree hydrates it, making it usable as a node.
614
- return column as ColumnValueType;
553
+ // Inserting the input nodes into the tree hydrates them, making them usable as nodes.
554
+ return columns as unknown as ColumnValueType[];
615
555
  }
616
556
 
617
- public insertRows({
557
+ public insertRow({
558
+ row,
618
559
  index,
619
- rows,
620
- }: InsertRowsParameters<RowInsertableType>): RowValueType[] {
560
+ }: TableSchema.InsertRowParameters<TRowSchema>): RowValueType {
561
+ const inserted = this.insertRows({
562
+ rows: [row],
563
+ index,
564
+ });
565
+ return inserted[0] ?? oob();
566
+ }
567
+
568
+ public insertRows({
569
+ index,
570
+ rows,
571
+ }: TableSchema.InsertRowsParameters<TRowSchema>): RowValueType[] {
572
+ // #region Input validation
573
+
574
+ // Ensure index is valid
575
+ if (index !== undefined) {
576
+ Table.validateInsertionIndex(index, this.rows);
577
+ }
578
+
579
+ // Note: TypeScript is unable to narrow the type of the row type correctly here, hence the casts below.
580
+ // See: https://github.com/microsoft/TypeScript/issues/52144
581
+ for (const newRow of rows) {
582
+ // Check all of the rows being inserted an ensure the table does not already contain any with the same ID.
583
+ const maybeId = (newRow as RowValueType).id;
584
+ if (maybeId !== undefined && this.containsRowWithId(maybeId)) {
585
+ throw new UsageError(
586
+ `A row with ID "${(newRow as RowValueType).id}" already exists in the table.`,
587
+ );
588
+ }
589
+
590
+ // If the row contains cells, verify that the table contains the columns for those cells.
591
+ // Note: we intentionally hide `cells` on `IRow` to avoid leaking the internal data representation as much as possible, so we have to cast here.
592
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
593
+ if ((newRow as any).cells !== undefined) {
594
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
595
+ const keys: string[] = Object.keys((newRow as any).cells);
596
+ for (const key of keys) {
597
+ if (!this.containsColumnWithId(key)) {
598
+ throw new UsageError(
599
+ `Attempted to insert row a cell under column ID "${key}", but the table does not contain a column with that ID.`,
600
+ );
601
+ }
602
+ }
603
+ }
604
+ }
605
+
606
+ // #endregion
607
+
608
+ // TypeScript is unable to narrow the row type correctly here, hence the casts below.
609
+ // See: https://github.com/microsoft/TypeScript/issues/52144
621
610
  if (index === undefined) {
622
- // TypeScript is unable to narrow the types correctly here, hence the cast.
623
- // See: https://github.com/microsoft/TypeScript/issues/52144
624
611
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
625
612
  this.rows.insertAtEnd(TreeArrayNode.spread(rows) as any);
626
613
  } else {
627
- // TypeScript is unable to narrow the types correctly here, hence the cast.
628
- // See: https://github.com/microsoft/TypeScript/issues/52144
629
614
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
630
615
  this.rows.insertAt(index, TreeArrayNode.spread(rows) as any);
631
616
  }
@@ -634,65 +619,204 @@ export namespace TableSchema {
634
619
  return rows as unknown as RowValueType[];
635
620
  }
636
621
 
637
- public setCell({ key, cell }: SetCellParameters<CellInsertableType>): void {
638
- const { columnId, rowId } = key;
639
- const row = this.getRow(rowId);
640
- if (row !== undefined) {
641
- const column = this.getColumn(columnId);
642
- if (column !== undefined) {
643
- row.setCell(column.id, cell);
644
- }
622
+ public setCell({
623
+ key,
624
+ cell,
625
+ }: TableSchema.SetCellParameters<TCellSchema, TColumnSchema, TRowSchema>): void {
626
+ const { column: columnOrId, row: rowOrId } = key;
627
+
628
+ const row = this._getRow(rowOrId);
629
+ if (row === undefined) {
630
+ const rowId = this._getRowId(rowOrId);
631
+ throw new UsageError(`No row with ID "${rowId}" exists in the table.`);
645
632
  }
633
+
634
+ const column = this._getColumn(columnOrId);
635
+ if (column === undefined) {
636
+ const columnId = this._getColumnId(columnOrId);
637
+ throw new UsageError(`No column with ID "${columnId}" exists in the table.`);
638
+ }
639
+
640
+ row.setCell(column, cell);
641
+ }
642
+
643
+ public removeColumns(
644
+ columns: readonly string[] | readonly ColumnValueType[],
645
+ ): ColumnValueType[] {
646
+ // If there are no columns to remove, do nothing
647
+ if (columns.length === 0) {
648
+ return [];
649
+ }
650
+
651
+ // If there is only one column to remove, remove it (and don't incur cost of transaction)
652
+ if (columns.length === 1) {
653
+ const removedColumn = this.removeColumn(columns[0] ?? oob());
654
+ return [removedColumn];
655
+ }
656
+
657
+ // If there are multiple columns to remove, remove them in a transaction.
658
+ const removedColumns: ColumnValueType[] = [];
659
+ Tree.runTransaction(this, () => {
660
+ // Note, throwing an error within a transaction will abort the entire transaction.
661
+ // So if we throw an error here for any row, no columns will be removed.
662
+ for (const columnToRemove of columns) {
663
+ const removedRow = this.removeColumn(columnToRemove);
664
+ removedColumns.push(removedRow);
665
+ }
666
+ });
667
+ return removedColumns;
646
668
  }
647
669
 
648
- public removeColumn(column: ColumnValueType): void {
649
- const index = this.columns.indexOf(column);
650
- // If the column is not in the table, do nothing
651
- if (index === -1) return;
670
+ public removeColumn(columnOrId: string | ColumnValueType): ColumnValueType {
671
+ const column = this._getColumn(columnOrId);
672
+ const index = column === undefined ? -1 : this.columns.indexOf(column);
673
+ if (index === -1) {
674
+ const columnId = this._getColumnId(columnOrId);
675
+ throw new UsageError(
676
+ `Specified column with ID "${columnId}" does not exist in the table.`,
677
+ );
678
+ }
652
679
  this.columns.removeAt(index);
680
+ return column as ColumnValueType;
681
+ }
682
+
683
+ public removeAllColumns(): ColumnValueType[] {
684
+ // TypeScript is unable to narrow the row type correctly here, hence the cast.
685
+ // See: https://github.com/microsoft/TypeScript/issues/52144
686
+ return this.removeColumns(this.columns as unknown as ColumnValueType[]);
653
687
  }
654
688
 
655
- public removeRows(rows: readonly RowValueType[]): void {
689
+ public removeRows(rows: readonly string[] | readonly RowValueType[]): RowValueType[] {
656
690
  // If there are no rows to remove, do nothing
657
691
  if (rows.length === 0) {
658
- return;
692
+ return [];
659
693
  }
660
694
 
661
- // If there is only one row to remove, remove it
695
+ // If there is only one row to remove, remove it (and don't incur cost of transaction)
662
696
  if (rows.length === 1) {
663
- const index = this.rows.indexOf(rows[0] ?? oob());
664
- this.rows.removeAt(index);
665
- return;
697
+ const removedRow = this.removeRow(rows[0] ?? oob());
698
+ return [removedRow];
666
699
  }
667
- // If there are multiple rows to remove, remove them in a transaction
668
- // This is to avoid the performance issues of deleting multiple rows at once
700
+
701
+ // If there are multiple rows to remove, remove them in a transaction.
702
+ const removedRows: RowValueType[] = [];
669
703
  Tree.runTransaction(this, () => {
670
- // Iterate over the rows and remove them
671
- for (const row of rows) {
672
- const index = this.rows.indexOf(row);
673
- this.rows.removeAt(index);
704
+ // Note, throwing an error within a transaction will abort the entire transaction.
705
+ // So if we throw an error here for any row, no rows will be removed.
706
+ for (const rowToRemove of rows) {
707
+ const removedRow = this.removeRow(rowToRemove);
708
+ removedRows.push(removedRow);
674
709
  }
675
710
  });
711
+ return removedRows;
676
712
  }
677
713
 
678
- public removeAllRows(): void {
679
- this.rows.removeRange();
714
+ public removeRow(rowOrId: string | RowValueType): RowValueType {
715
+ const rowToRemove = this._getRow(rowOrId);
716
+ const index = rowToRemove === undefined ? -1 : this.rows.indexOf(rowToRemove);
717
+
718
+ // If the row does not exist in the table, throw an error.
719
+ if (index === -1) {
720
+ const rowId = this._getRowId(rowOrId);
721
+ throw new UsageError(
722
+ `Specified row with ID "${rowId}" does not exist in the table.`,
723
+ );
724
+ }
725
+
726
+ this.rows.removeAt(index);
727
+ return rowToRemove as RowValueType;
680
728
  }
681
729
 
682
- public removeCell(key: CellKey): void {
683
- const { columnId, rowId } = key;
684
- const row = this.getRow(rowId);
685
- if (row !== undefined) {
686
- const column = this.getColumn(columnId);
687
- if (column !== undefined) {
688
- row.removeCell(column.id);
689
- }
730
+ public removeAllRows(): RowValueType[] {
731
+ // TypeScript is unable to narrow the row type correctly here, hence the cast.
732
+ // See: https://github.com/microsoft/TypeScript/issues/52144
733
+ return this.removeRows(this.rows as unknown as RowValueType[]);
734
+ }
735
+
736
+ public removeCell(
737
+ key: TableSchema.CellKey<TColumnSchema, TRowSchema>,
738
+ ): CellValueType | undefined {
739
+ const { column: columnOrId, row: rowOrId } = key;
740
+ const row = this._getRow(rowOrId);
741
+ if (row === undefined) {
742
+ const rowId = this._getRowId(rowOrId);
743
+ throw new UsageError(
744
+ `Specified row with ID "${rowId}" does not exist in the table.`,
745
+ );
746
+ }
747
+
748
+ const column = this._getColumn(columnOrId);
749
+ if (column === undefined) {
750
+ const columnId = this._getColumnId(columnOrId);
751
+ throw new UsageError(
752
+ `Specified column with ID "${columnId}" does not exist in the table.`,
753
+ );
754
+ }
755
+
756
+ const cell: CellValueType | undefined = row.getCell(column.id);
757
+ if (cell === undefined) {
758
+ return undefined;
759
+ }
760
+
761
+ row.removeCell(column.id);
762
+ return cell;
763
+ }
764
+
765
+ private _getColumn(columnOrId: string | ColumnValueType): ColumnValueType | undefined {
766
+ return typeof columnOrId === "string" ? this.getColumn(columnOrId) : columnOrId;
767
+ }
768
+
769
+ private _getColumnId(columnOrId: string | ColumnValueType): string {
770
+ return typeof columnOrId === "string" ? columnOrId : columnOrId.id;
771
+ }
772
+
773
+ private _getRow(rowOrId: string | RowValueType): RowValueType | undefined {
774
+ return typeof rowOrId === "string" ? this.getRow(rowOrId) : rowOrId;
775
+ }
776
+
777
+ private _getRowId(rowOrId: string | RowValueType): string {
778
+ return typeof rowOrId === "string" ? rowOrId : rowOrId.id;
779
+ }
780
+
781
+ private containsColumnWithId(columnId: string): boolean {
782
+ // TypeScript is unable to narrow the types correctly here, hence the cast.
783
+ // See: https://github.com/microsoft/TypeScript/issues/52144
784
+ return (
785
+ this.columns.find((column) => (column as TableSchema.Column).id === columnId) !==
786
+ undefined
787
+ );
788
+ }
789
+
790
+ private containsRowWithId(rowId: string): boolean {
791
+ // TypeScript is unable to narrow the types correctly here, hence the cast.
792
+ // See: https://github.com/microsoft/TypeScript/issues/52144
793
+ return this.rows.find((row) => (row as TableSchema.Row).id === rowId) !== undefined;
794
+ }
795
+
796
+ /**
797
+ * Ensure that the specified index is a valid location for item insertion in the destination list.
798
+ * @throws Throws a usage error if the destination is invalid.
799
+ */
800
+ private static validateInsertionIndex(
801
+ index: number,
802
+ destinationList: readonly unknown[],
803
+ ): void {
804
+ if (index < 0) {
805
+ throw new UsageError("The index must be greater than or equal to 0.");
806
+ }
807
+
808
+ if (index > destinationList.length) {
809
+ throw new UsageError("The index specified for insertion is out of bounds.");
810
+ }
811
+
812
+ if (!Number.isInteger(index)) {
813
+ throw new UsageError("The index must be an integer.");
690
814
  }
691
815
  }
692
816
  }
693
817
 
694
818
  type TableValueType = TreeNode &
695
- ITable<TCell, TColumn, TRow> &
819
+ TableSchema.Table<TCellSchema, TColumnSchema, TRowSchema> &
696
820
  WithType<ScopedSchemaName<Scope, "Table">>;
697
821
  type TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;
698
822
 
@@ -721,16 +845,664 @@ export namespace TableSchema {
721
845
  export type TableSchemaBase<
722
846
  TScope extends string | undefined,
723
847
  TCell extends ImplicitAllowedTypes,
724
- TColumn extends ColumnSchemaBase<TScope, ImplicitAllowedTypes> = ColumnSchemaBase<
725
- TScope,
726
- ImplicitAllowedTypes
727
- >,
728
- TRow extends RowSchemaBase<TScope, TCell, ImplicitAllowedTypes> = RowSchemaBase<
729
- TScope,
730
- TCell,
731
- ImplicitAllowedTypes
732
- >,
733
- > = ReturnType<typeof createTable<TScope, TCell, TColumn, TRow>>;
848
+ TColumn extends ColumnSchemaBase<TScope>,
849
+ TRow extends RowSchemaBase<TScope, TCell>,
850
+ > = ReturnType<typeof createTableInternal<TScope, TCell, TColumn, TRow>>;
851
+
852
+ // #endregion
853
+ }
854
+
855
+ /**
856
+ * Contains types and factories for creating schema to represent dynamic tabular data.
857
+ *
858
+ * @remarks
859
+ *
860
+ * Tables created using these APIs are...
861
+ *
862
+ * - sparse, meaning that cells may be omitted, and new rows are empty by default.
863
+ *
864
+ * - dynamic, meaning that their structure can be modified at runtime.
865
+ * Columns and rows can be inserted, removed, modified, and reordered.
866
+ * Cells can be inserted, removed, and modified.
867
+ *
868
+ * - row-major, meaning that operating on rows (including inserts, removal, moves, and traversal) is more efficient than operating on columns.
869
+ *
870
+ * Column and Row schema created using these APIs are extensible via the `props` field.
871
+ * This allows association of additional properties with column and row nodes.
872
+ *
873
+ * Note: for now it is possible for table cells to become "orphaned".
874
+ * That is, it is possible to enter a state where one or more rows contain cells with no corresponding column.
875
+ * To help avoid this situation, you can manually remove corresponding cells when removing columns.
876
+ * Either way, it is possible to enter such a state via the merging of edits.
877
+ * For example: one client might add a row while another concurrently removes a column, orphaning the cell where the column and row intersected.
878
+ *
879
+ * @example Using default Column and Row schema
880
+ *
881
+ * ```typescript
882
+ * class Cell extends schemaFactory.object("TableCell", {
883
+ * value: schemaFactory.string,
884
+ * }) {}
885
+ *
886
+ * class Table extends TableSchema.createTable({
887
+ * schemaFactory,
888
+ * cell: Cell,
889
+ * }) {}
890
+ *
891
+ * const table = new Table({
892
+ * columns: [{ id: "column-0" }],
893
+ * rows: [{ id: "row-0", cells: {} }],
894
+ * });
895
+ * ```
896
+ *
897
+ * @example Customizing Column and Row schema
898
+ *
899
+ * ```typescript
900
+ * class Cell extends schemaFactory.object("TableCell", {
901
+ * value: schemaFactory.string,
902
+ * }) {}
903
+ *
904
+ * class ColumnProps extends schemaFactory.object("TableColumnProps", {
905
+ * // Column label to display.
906
+ * label: schemaFactory.string,
907
+ * // The type of data represented by the cells. Default: string.
908
+ * dataType: schemaFactory.optional(schemaFactory.string),
909
+ * }) {}
910
+ *
911
+ * class Column extends TableSchema.createColumn({
912
+ * schemaFactory,
913
+ * props: ColumnProps,
914
+ * }) {}
915
+ *
916
+ * class Row extends TableSchema.createRow({
917
+ * schemaFactory,
918
+ * cell: Cell,
919
+ * }) {}
920
+ *
921
+ * class Table extends TableSchema.createTable({
922
+ * schemaFactory,
923
+ * cell: Cell,
924
+ * column: Column,
925
+ * row: Row,
926
+ * }) {}
927
+ *
928
+ * const table = new Table({
929
+ * columns: [
930
+ * new Column({ props: { label: "Entry", dataType: "string" } }),
931
+ * new Column({ props: { label: "Date", dataType: "date" } }),
932
+ * new Column({ props: { label: "Amount", dataType: "number" } }),
933
+ * ],
934
+ * rows: [],
935
+ * });
936
+ * ```
937
+ *
938
+ * @privateRemarks
939
+ * The above examples are backed by tests in `tableSchema.spec.ts`.
940
+ * Those tests and these examples should be kept in-sync to ensure that the examples are correct.
941
+ *
942
+ * @internal
943
+ */
944
+ export namespace TableSchema {
945
+ // #region Column
946
+
947
+ /**
948
+ * A column in a table.
949
+ * @remarks Implemented by the schema class returned from {@link TableSchema.(createColumn:2)}.
950
+ * @sealed @internal
951
+ */
952
+ export interface Column<
953
+ TProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
954
+ > {
955
+ /**
956
+ * The unique identifier of the column.
957
+ * @remarks Uniquely identifies the node within the entire tree, not just the table.
958
+ */
959
+ readonly id: string;
960
+
961
+ /**
962
+ * The column's properties.
963
+ * @remarks This is a user-defined schema that can be used to store additional information about the column.
964
+ * @privateRemarks
965
+ * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.
966
+ * If you update the docs here, please also update the inline type definitions.
967
+ */
968
+ get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
969
+ set props(value: InsertableTreeFieldFromImplicitField<
970
+ UnannotateImplicitFieldSchema<TProps>
971
+ >);
972
+ }
973
+
974
+ /**
975
+ * Factory for creating new table column schema.
976
+ * @internal
977
+ */
978
+ export function createColumn<const TScope extends string | undefined>({
979
+ schemaFactory,
980
+ }: System_TableSchema.CreateColumnOptionsBase<
981
+ SchemaFactoryAlpha<TScope>
982
+ >): System_TableSchema.ColumnSchemaBase<TScope, System_TableSchema.DefaultPropsType>;
983
+ /**
984
+ * Factory for creating new table column schema.
985
+ * @internal
986
+ */
987
+ export function createColumn<
988
+ const TScope extends string | undefined,
989
+ const TProps extends ImplicitAnnotatedFieldSchema,
990
+ >({
991
+ schemaFactory,
992
+ props,
993
+ }: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryAlpha<TScope>> & {
994
+ /**
995
+ * Optional column properties.
996
+ */
997
+ readonly props: TProps;
998
+ }): System_TableSchema.ColumnSchemaBase<TScope, TProps>;
999
+ /**
1000
+ * Overload implementation
1001
+ */
1002
+ export function createColumn({
1003
+ schemaFactory,
1004
+ props = SchemaFactory.optional(SchemaFactory.null),
1005
+ }: System_TableSchema.CreateColumnOptionsBase & {
1006
+ readonly props?: ImplicitAnnotatedFieldSchema;
1007
+ }): TreeNodeSchema {
1008
+ return System_TableSchema.createColumnInternal(schemaFactory, props);
1009
+ }
1010
+
1011
+ // #endregion
1012
+
1013
+ // #region Row
1014
+
1015
+ /**
1016
+ * A row in a table.
1017
+ * @remarks Implemented by the schema class returned from {@link TableSchema.(createRow:2)}.
1018
+ * @sealed @internal
1019
+ */
1020
+ export interface Row<
1021
+ TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
1022
+ TProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
1023
+ > {
1024
+ /**
1025
+ * The unique identifier of the row.
1026
+ * @remarks Uniquely identifies the node within the entire tree, not just the table.
1027
+ */
1028
+ readonly id: string;
1029
+
1030
+ /**
1031
+ * Gets the cell in the specified column.
1032
+ * @returns The cell if it exists, otherwise undefined.
1033
+ * @privateRemarks TODO: throw if the column does not belong to the same table as the row.
1034
+ */
1035
+ getCell(column: Column): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1036
+ /**
1037
+ * Gets the cell in the specified column, denoted by column ID.
1038
+ * @returns The cell if it exists, otherwise undefined.
1039
+ */
1040
+ getCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1041
+
1042
+ /**
1043
+ * Sets the cell in the specified column.
1044
+ * @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:1)} instead.
1045
+ * @privateRemarks TODO: Throw an error if the column does not exist in the table.
1046
+ */
1047
+ setCell(column: Column, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
1048
+ /**
1049
+ * Sets the cell in the specified column, denoted by column ID.
1050
+ * @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:2)} instead.
1051
+ */
1052
+ setCell(columnId: string, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
1053
+
1054
+ /**
1055
+ * Removes the cell in the specified column.
1056
+ * @returns The cell if it exists, otherwise undefined.
1057
+ * @privateRemarks TODO: Throw if the column does not belong to the same table as the row.
1058
+ */
1059
+ removeCell(column: Column): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1060
+ /**
1061
+ * Removes the cell in the specified column, denoted by column ID.
1062
+ * @returns The cell if it exists, otherwise undefined.
1063
+ */
1064
+ removeCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1065
+
1066
+ /**
1067
+ * The row's properties.
1068
+ * @remarks This is a user-defined schema that can be used to store additional information about the row.
1069
+ * @privateRemarks
1070
+ * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.
1071
+ * If you update the docs here, please also update the inline type definitions.
1072
+ */
1073
+ get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
1074
+ set props(value: InsertableTreeFieldFromImplicitField<
1075
+ UnannotateImplicitFieldSchema<TProps>
1076
+ >);
1077
+ }
1078
+
1079
+ /**
1080
+ * Factory for creating new table column schema.
1081
+ * @internal
1082
+ */
1083
+ export function createRow<
1084
+ const TScope extends string | undefined,
1085
+ const TCell extends ImplicitAllowedTypes,
1086
+ >({
1087
+ schemaFactory,
1088
+ cell,
1089
+ }: System_TableSchema.CreateRowOptionsBase<
1090
+ SchemaFactoryAlpha<TScope>,
1091
+ TCell
1092
+ >): System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
1093
+ /**
1094
+ * Factory for creating new table column schema.
1095
+ * @internal
1096
+ */
1097
+ export function createRow<
1098
+ const TScope extends string | undefined,
1099
+ const TCell extends ImplicitAllowedTypes,
1100
+ const TProps extends ImplicitAnnotatedFieldSchema,
1101
+ >({
1102
+ schemaFactory,
1103
+ cell,
1104
+ props,
1105
+ }: System_TableSchema.CreateRowOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1106
+ /**
1107
+ * Optional row properties.
1108
+ */
1109
+ readonly props: TProps;
1110
+ }): System_TableSchema.RowSchemaBase<TScope, TCell, TProps>;
1111
+ /**
1112
+ * Overload implementation
1113
+ */
1114
+ export function createRow({
1115
+ schemaFactory,
1116
+ cell,
1117
+ props = SchemaFactory.optional(SchemaFactory.null),
1118
+ }: System_TableSchema.CreateRowOptionsBase & {
1119
+ readonly props?: ImplicitAnnotatedFieldSchema;
1120
+ }): TreeNodeSchema {
1121
+ return System_TableSchema.createRowInternal(schemaFactory, cell, props);
1122
+ }
1123
+
1124
+ // #endregion
1125
+
1126
+ // #region Table
1127
+
1128
+ /**
1129
+ * A key to uniquely identify a cell within a table.
1130
+ * @internal
1131
+ */
1132
+ export interface CellKey<
1133
+ TColumn extends ImplicitAllowedTypes,
1134
+ TRow extends ImplicitAllowedTypes,
1135
+ > {
1136
+ /**
1137
+ * {@link TableSchema.Column} or {@link TableSchema.Column.id} at which the cell is located.
1138
+ */
1139
+ readonly column: string | TreeNodeFromImplicitAllowedTypes<TColumn>;
1140
+
1141
+ /**
1142
+ * {@link TableSchema.Row} or {@link TableSchema.Row.id} at which the cell is located.
1143
+ */
1144
+ readonly row: string | TreeNodeFromImplicitAllowedTypes<TRow>;
1145
+ }
1146
+
1147
+ /**
1148
+ * {@link TableSchema.Table.insertColumn} parameters.
1149
+ * @internal
1150
+ */
1151
+ export interface InsertColumnParameters<TColumn extends ImplicitAllowedTypes> {
1152
+ /**
1153
+ * The index at which to insert the new column.
1154
+ * @remarks If not provided, the column will be appended to the end of the table.
1155
+ */
1156
+ readonly index?: number | undefined;
1157
+
1158
+ /**
1159
+ * The column to insert.
1160
+ */
1161
+ readonly column: InsertableTreeNodeFromImplicitAllowedTypes<TColumn>;
1162
+ }
1163
+
1164
+ /**
1165
+ * {@link TableSchema.Table.insertColumns} parameters.
1166
+ * @internal
1167
+ */
1168
+ export interface InsertColumnsParameters<TColumn extends ImplicitAllowedTypes> {
1169
+ /**
1170
+ * The index at which to insert the new columns.
1171
+ * @remarks If not provided, the columns will be appended to the end of the table.
1172
+ */
1173
+ readonly index?: number | undefined;
1174
+
1175
+ /**
1176
+ * The columns to insert.
1177
+ */
1178
+ readonly columns: InsertableTreeNodeFromImplicitAllowedTypes<TColumn>[];
1179
+ }
1180
+
1181
+ /**
1182
+ * {@link TableSchema.Table.insertRow} parameters.
1183
+ * @internal
1184
+ */
1185
+ export interface InsertRowParameters<TRow extends ImplicitAllowedTypes> {
1186
+ /**
1187
+ * The index at which to insert the new row.
1188
+ * @remarks If not provided, the row will be appended to the end of the table.
1189
+ */
1190
+ readonly index?: number | undefined;
1191
+
1192
+ /**
1193
+ * The row to insert.
1194
+ */
1195
+ readonly row: InsertableTreeNodeFromImplicitAllowedTypes<TRow>;
1196
+ }
1197
+
1198
+ /**
1199
+ * {@link TableSchema.Table.insertRows} parameters.
1200
+ * @internal
1201
+ */
1202
+ export interface InsertRowsParameters<TRow extends ImplicitAllowedTypes> {
1203
+ /**
1204
+ * The index at which to insert the new rows.
1205
+ * @remarks If not provided, the rows will be appended to the end of the table.
1206
+ */
1207
+ readonly index?: number | undefined;
1208
+
1209
+ /**
1210
+ * The rows to insert.
1211
+ */
1212
+ readonly rows: InsertableTreeNodeFromImplicitAllowedTypes<TRow>[];
1213
+ }
1214
+
1215
+ /**
1216
+ * {@link TableSchema.Table.setCell} parameters.
1217
+ * @internal
1218
+ */
1219
+ export interface SetCellParameters<
1220
+ TCell extends ImplicitAllowedTypes,
1221
+ TColumn extends ImplicitAllowedTypes,
1222
+ TRow extends ImplicitAllowedTypes,
1223
+ > {
1224
+ /**
1225
+ * The key to uniquely identify a cell in a table.
1226
+ */
1227
+ readonly key: CellKey<TColumn, TRow>;
1228
+
1229
+ /**
1230
+ * The cell to set.
1231
+ */
1232
+ readonly cell: InsertableTreeNodeFromImplicitAllowedTypes<TCell>;
1233
+ }
1234
+
1235
+ /**
1236
+ * A table.
1237
+ * @sealed @internal
1238
+ */
1239
+ export interface Table<
1240
+ TCell extends ImplicitAllowedTypes,
1241
+ TColumn extends ImplicitAllowedTypes,
1242
+ TRow extends ImplicitAllowedTypes,
1243
+ > {
1244
+ /**
1245
+ * The table's columns.
1246
+ */
1247
+ readonly columns: TreeArrayNode<TColumn>;
1248
+
1249
+ /**
1250
+ * The table's rows.
1251
+ */
1252
+ readonly rows: TreeArrayNode<TRow>;
1253
+
1254
+ /**
1255
+ * Gets a table column by its {@link TableSchema.Column.id}.
1256
+ */
1257
+ getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumn> | undefined;
1258
+
1259
+ /**
1260
+ * Gets a table row by its {@link TableSchema.Row.id}.
1261
+ */
1262
+ getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRow> | undefined;
1263
+
1264
+ /**
1265
+ * Gets a cell in the table by column and row IDs.
1266
+ * @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.
1267
+ */
1268
+ getCell(key: CellKey<TColumn, TRow>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1269
+
1270
+ /**
1271
+ * Inserts a column into the table.
1272
+ *
1273
+ * @throws
1274
+ * Throws an error in the following cases:
1275
+ *
1276
+ * - The column, or a column with the same ID is already in the tree.
1277
+ *
1278
+ * - The specified index is out of range.
1279
+ *
1280
+ * No column is inserted in these cases.
1281
+ */
1282
+ insertColumn(
1283
+ params: InsertColumnParameters<TColumn>,
1284
+ ): TreeNodeFromImplicitAllowedTypes<TColumn>;
1285
+
1286
+ /**
1287
+ * Inserts 0 or more columns into the table.
1288
+ *
1289
+ * @throws
1290
+ * Throws an error in the following cases:
1291
+ *
1292
+ * - At least one column, or a column with the same ID is already in the tree.
1293
+ *
1294
+ * - The specified index is out of range.
1295
+ *
1296
+ * No columns are inserted in these cases.
1297
+ */
1298
+ insertColumns(
1299
+ params: InsertColumnsParameters<TColumn>,
1300
+ ): TreeNodeFromImplicitAllowedTypes<TColumn>[];
1301
+
1302
+ /**
1303
+ * Inserts a row into the table.
1304
+ *
1305
+ * @throws
1306
+ * Throws an error in the following cases:
1307
+ *
1308
+ * - The row, or a row with the same ID is already in the tree.
1309
+ *
1310
+ * - The row contains cells, but the table does not contain matching columns for one or more of those cells.
1311
+ *
1312
+ * - The specified index is out of range.
1313
+ *
1314
+ * No row is inserted in these cases.
1315
+ */
1316
+ insertRow(params: InsertRowParameters<TRow>): TreeNodeFromImplicitAllowedTypes<TRow>;
1317
+
1318
+ /**
1319
+ * Inserts 0 or more rows into the table.
1320
+ *
1321
+ * @throws
1322
+ * Throws an error in the following cases:
1323
+ *
1324
+ * - At least one row, or a row with the same ID is already in the tree.
1325
+ *
1326
+ * - The row contains cells, but the table does not contain matching columns for one or more of those cells.
1327
+ *
1328
+ * - The specified index is out of range.
1329
+ *
1330
+ * No rows are inserted in these cases.
1331
+ */
1332
+ insertRows(params: InsertRowsParameters<TRow>): TreeNodeFromImplicitAllowedTypes<TRow>[];
1333
+
1334
+ /**
1335
+ * Sets the cell at the specified location in the table.
1336
+ * @remarks To remove a cell, call {@link TableSchema.Table.removeCell} instead.
1337
+ */
1338
+ setCell(params: SetCellParameters<TCell, TColumn, TRow>): void;
1339
+
1340
+ /**
1341
+ * Removes the specified column from the table.
1342
+ *
1343
+ * @remarks
1344
+ * Note: this does not remove any cells from the table's rows.
1345
+ * To remove the corresponding cells, use {@link TableSchema.Table.removeCell}.
1346
+ *
1347
+ * @param column - The {@link TableSchema.Column | column} or {@link TableSchema.Column.id | column ID} to remove.
1348
+ * @throws Throws an error if the column is not in the table.
1349
+ * @privateRemarks TODO (future): Actually remove corresponding cells from table rows.
1350
+ */
1351
+ removeColumn(
1352
+ column: string | TreeNodeFromImplicitAllowedTypes<TColumn>,
1353
+ ): TreeNodeFromImplicitAllowedTypes<TColumn>;
1354
+
1355
+ /**
1356
+ * Removes 0 or more columns from the table.
1357
+ *
1358
+ * @remarks
1359
+ * Note: this does not remove any cells from the table's rows.
1360
+ * To remove the corresponding cells, use {@link TableSchema.Table.removeCell}.
1361
+ *
1362
+ * @param columns - The columns to remove.
1363
+ * @throws Throws an error if any of the columns are not in the table.
1364
+ * In this case, no columns are removed.
1365
+ */
1366
+ removeColumns(
1367
+ columns: readonly TreeNodeFromImplicitAllowedTypes<TColumn>[],
1368
+ ): TreeNodeFromImplicitAllowedTypes<TColumn>[];
1369
+ /**
1370
+ * Removes 0 or more columns from the table.
1371
+ *
1372
+ * @remarks
1373
+ * Note: this does not remove any cells from the table's rows.
1374
+ * To remove the corresponding cells, use {@link TableSchema.Table.removeCell}.
1375
+ *
1376
+ * @param columns - The columns to remove, specified by their {@link TableSchema.Column.id}.
1377
+ * @throws Throws an error if any of the columns are not in the table.
1378
+ * In this case, no columns are removed.
1379
+ */
1380
+ removeColumns(columns: readonly string[]): TreeNodeFromImplicitAllowedTypes<TColumn>[];
1381
+
1382
+ /**
1383
+ * Removes all columns from the table.
1384
+ * @returns The removed columns.
1385
+ */
1386
+ removeAllColumns(): TreeNodeFromImplicitAllowedTypes<TColumn>[];
1387
+
1388
+ /**
1389
+ * Removes the specified row from the table.
1390
+ * @param row - The {@link TableSchema.Row | row} or {@link TableSchema.Row.id | row ID} to remove.
1391
+ * @throws Throws an error if the row is not in the table.
1392
+ */
1393
+ removeRow(
1394
+ row: string | TreeNodeFromImplicitAllowedTypes<TRow>,
1395
+ ): TreeNodeFromImplicitAllowedTypes<TRow>;
1396
+
1397
+ /**
1398
+ * Removes 0 or more rows from the table.
1399
+ * @param rows - The rows to remove.
1400
+ * @throws Throws an error if any of the rows are not in the table.
1401
+ * In this case, no rows are removed.
1402
+ */
1403
+ removeRows(
1404
+ rows: readonly TreeNodeFromImplicitAllowedTypes<TRow>[],
1405
+ ): TreeNodeFromImplicitAllowedTypes<TRow>[];
1406
+ /**
1407
+ * Removes 0 or more rows from the table.
1408
+ * @param rows - The rows to remove, specified by their {@link TableSchema.Row.id}.
1409
+ * @throws Throws an error if any of the rows are not in the table.
1410
+ * In this case, no rows are removed.
1411
+ */
1412
+ removeRows(rows: readonly string[]): TreeNodeFromImplicitAllowedTypes<TRow>[];
1413
+
1414
+ /**
1415
+ * Removes all rows from the table.
1416
+ * @returns The removed rows.
1417
+ */
1418
+ removeAllRows(): TreeNodeFromImplicitAllowedTypes<TRow>[];
1419
+
1420
+ /**
1421
+ * Removes the cell at the specified location in the table.
1422
+ * @returns The cell if it exists, otherwise undefined.
1423
+ * @throws Throws an error if the location does not exist in the table.
1424
+ */
1425
+ removeCell(
1426
+ key: CellKey<TColumn, TRow>,
1427
+ ): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1428
+ }
1429
+
1430
+ /**
1431
+ * Factory for creating new table schema without specifying row or column schema.
1432
+ * @internal
1433
+ */
1434
+ export function createTable<
1435
+ const TScope extends string | undefined,
1436
+ const TCell extends ImplicitAllowedTypes,
1437
+ >({
1438
+ schemaFactory,
1439
+ cell,
1440
+ }: System_TableSchema.TableFactoryOptionsBase<
1441
+ SchemaFactoryAlpha<TScope>,
1442
+ TCell
1443
+ >): System_TableSchema.TableSchemaBase<
1444
+ TScope,
1445
+ TCell,
1446
+ System_TableSchema.ColumnSchemaBase<TScope, System_TableSchema.DefaultPropsType>,
1447
+ System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>
1448
+ >;
1449
+ /**
1450
+ * Factory for creating new table schema without specifying row schema.
1451
+ * @internal
1452
+ */
1453
+ export function createTable<
1454
+ const TScope extends string | undefined,
1455
+ const TCell extends ImplicitAllowedTypes,
1456
+ const TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,
1457
+ >({
1458
+ schemaFactory,
1459
+ cell,
1460
+ column,
1461
+ }: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1462
+ readonly column: TColumn;
1463
+ }): System_TableSchema.TableSchemaBase<
1464
+ TScope,
1465
+ TCell,
1466
+ TColumn,
1467
+ System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>
1468
+ >;
1469
+ /**
1470
+ * Factory for creating new table schema.
1471
+ * @internal
1472
+ */
1473
+ export function createTable<
1474
+ const TScope extends string | undefined,
1475
+ const TCell extends ImplicitAllowedTypes,
1476
+ const TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,
1477
+ const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>,
1478
+ >({
1479
+ schemaFactory,
1480
+ cell,
1481
+ column,
1482
+ row,
1483
+ }: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1484
+ readonly column: TColumn;
1485
+ readonly row: TRow;
1486
+ }): System_TableSchema.TableSchemaBase<TScope, TCell, TColumn, TRow>;
1487
+ /**
1488
+ * Overload implementation
1489
+ */
1490
+ export function createTable({
1491
+ schemaFactory,
1492
+ cell,
1493
+ column = createColumn({
1494
+ schemaFactory,
1495
+ }),
1496
+ row = createRow({
1497
+ schemaFactory,
1498
+ cell,
1499
+ }),
1500
+ }: System_TableSchema.TableFactoryOptionsBase & {
1501
+ readonly column?: System_TableSchema.ColumnSchemaBase;
1502
+ readonly row?: System_TableSchema.RowSchemaBase;
1503
+ }): TreeNodeSchema {
1504
+ return System_TableSchema.createTableInternal(schemaFactory, cell, column, row);
1505
+ }
734
1506
 
735
1507
  // #endregion
736
1508
  }