@fluidframework/tree 2.31.1 → 2.33.0-333010

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/CHANGELOG.md +44 -0
  3. package/api-extractor/api-extractor.current.json +5 -1
  4. package/api-report/tree.alpha.api.md +44 -20
  5. package/dist/alpha.d.ts +6 -2
  6. package/dist/feature-libraries/flex-tree/context.d.ts +6 -1
  7. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  8. package/dist/feature-libraries/flex-tree/context.js +5 -2
  9. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  10. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  11. package/dist/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  12. package/dist/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  13. package/dist/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  14. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  15. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  16. package/dist/feature-libraries/flex-tree/index.js +1 -2
  17. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  18. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  19. package/dist/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  20. package/dist/feature-libraries/flex-tree/lazyEntity.js +9 -18
  21. package/dist/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  22. package/dist/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  23. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  24. package/dist/feature-libraries/flex-tree/lazyField.js +14 -14
  25. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  26. package/dist/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  27. package/dist/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  28. package/dist/feature-libraries/flex-tree/lazyNode.js +12 -12
  29. package/dist/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  30. package/dist/feature-libraries/index.d.ts +1 -1
  31. package/dist/feature-libraries/index.d.ts.map +1 -1
  32. package/dist/feature-libraries/index.js +1 -2
  33. package/dist/feature-libraries/index.js.map +1 -1
  34. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  35. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js +29 -25
  36. package/dist/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  37. package/dist/index.d.ts +2 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +5 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.d.ts.map +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  46. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  47. package/dist/shared-tree/checkoutFlexTreeView.js +4 -0
  48. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  49. package/dist/shared-tree/sharedTree.js +2 -2
  50. package/dist/shared-tree/sharedTree.js.map +1 -1
  51. package/dist/shared-tree/treeApiAlpha.d.ts +6 -6
  52. package/dist/shared-tree/treeApiAlpha.d.ts.map +1 -1
  53. package/dist/shared-tree/treeApiAlpha.js.map +1 -1
  54. package/dist/shared-tree-core/sharedTreeCore.d.ts +0 -6
  55. package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  56. package/dist/shared-tree-core/sharedTreeCore.js +0 -17
  57. package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
  58. package/dist/simple-tree/api/conciseTree.d.ts +2 -2
  59. package/dist/simple-tree/api/conciseTree.d.ts.map +1 -1
  60. package/dist/simple-tree/api/conciseTree.js.map +1 -1
  61. package/dist/simple-tree/api/customTree.d.ts +14 -12
  62. package/dist/simple-tree/api/customTree.d.ts.map +1 -1
  63. package/dist/simple-tree/api/customTree.js.map +1 -1
  64. package/dist/simple-tree/api/getJsonSchema.d.ts +21 -7
  65. package/dist/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  66. package/dist/simple-tree/api/getJsonSchema.js +8 -16
  67. package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
  68. package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -10
  69. package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  70. package/dist/simple-tree/api/getSimpleSchema.js +4 -16
  71. package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
  72. package/dist/simple-tree/api/index.d.ts +4 -3
  73. package/dist/simple-tree/api/index.d.ts.map +1 -1
  74. package/dist/simple-tree/api/index.js +2 -1
  75. package/dist/simple-tree/api/index.js.map +1 -1
  76. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  77. package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  78. package/dist/simple-tree/api/schemaFactoryAlpha.js +4 -0
  79. package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  80. package/dist/simple-tree/api/schemaFromSimple.d.ts +5 -2
  81. package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  82. package/dist/simple-tree/api/schemaFromSimple.js +24 -8
  83. package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
  84. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  85. package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  86. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +40 -28
  87. package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  88. package/dist/simple-tree/api/tree.d.ts +32 -5
  89. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  90. package/dist/simple-tree/api/tree.js +17 -1
  91. package/dist/simple-tree/api/tree.js.map +1 -1
  92. package/dist/simple-tree/api/verboseTree.d.ts +4 -28
  93. package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
  94. package/dist/simple-tree/api/verboseTree.js.map +1 -1
  95. package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  96. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  97. package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  98. package/dist/simple-tree/core/treeNodeKernel.d.ts +9 -2
  99. package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  100. package/dist/simple-tree/core/treeNodeKernel.js +46 -30
  101. package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
  102. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  103. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  104. package/dist/simple-tree/core/unhydratedFlexTree.js +15 -1
  105. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  106. package/dist/simple-tree/index.d.ts +1 -1
  107. package/dist/simple-tree/index.d.ts.map +1 -1
  108. package/dist/simple-tree/index.js +3 -2
  109. package/dist/simple-tree/index.js.map +1 -1
  110. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  111. package/dist/simple-tree/objectNode.js +3 -0
  112. package/dist/simple-tree/objectNode.js.map +1 -1
  113. package/dist/simple-tree/simpleSchema.d.ts +4 -11
  114. package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
  115. package/dist/simple-tree/simpleSchema.js.map +1 -1
  116. package/dist/tableSchema.d.ts +241 -0
  117. package/dist/tableSchema.d.ts.map +1 -0
  118. package/dist/tableSchema.js +238 -0
  119. package/dist/tableSchema.js.map +1 -0
  120. package/dist/treeFactory.d.ts +4 -4
  121. package/dist/treeFactory.d.ts.map +1 -1
  122. package/dist/treeFactory.js.map +1 -1
  123. package/dist/util/breakable.d.ts.map +1 -1
  124. package/dist/util/breakable.js +9 -7
  125. package/dist/util/breakable.js.map +1 -1
  126. package/lib/alpha.d.ts +6 -2
  127. package/lib/feature-libraries/flex-tree/context.d.ts +6 -1
  128. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  129. package/lib/feature-libraries/flex-tree/context.js +6 -3
  130. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  131. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts +8 -0
  132. package/lib/feature-libraries/flex-tree/flexTreeTypes.d.ts.map +1 -1
  133. package/lib/feature-libraries/flex-tree/flexTreeTypes.js +8 -0
  134. package/lib/feature-libraries/flex-tree/flexTreeTypes.js.map +1 -1
  135. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  136. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  137. package/lib/feature-libraries/flex-tree/index.js +1 -1
  138. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  139. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts +6 -15
  140. package/lib/feature-libraries/flex-tree/lazyEntity.d.ts.map +1 -1
  141. package/lib/feature-libraries/flex-tree/lazyEntity.js +8 -17
  142. package/lib/feature-libraries/flex-tree/lazyEntity.js.map +1 -1
  143. package/lib/feature-libraries/flex-tree/lazyField.d.ts +3 -3
  144. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  145. package/lib/feature-libraries/flex-tree/lazyField.js +15 -15
  146. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  147. package/lib/feature-libraries/flex-tree/lazyNode.d.ts +4 -4
  148. package/lib/feature-libraries/flex-tree/lazyNode.d.ts.map +1 -1
  149. package/lib/feature-libraries/flex-tree/lazyNode.js +13 -13
  150. package/lib/feature-libraries/flex-tree/lazyNode.js.map +1 -1
  151. package/lib/feature-libraries/index.d.ts +1 -1
  152. package/lib/feature-libraries/index.d.ts.map +1 -1
  153. package/lib/feature-libraries/index.js +1 -1
  154. package/lib/feature-libraries/index.js.map +1 -1
  155. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.d.ts.map +1 -1
  156. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js +28 -24
  157. package/lib/feature-libraries/node-identifier/nodeIdentifierManager.js.map +1 -1
  158. package/lib/index.d.ts +2 -1
  159. package/lib/index.d.ts.map +1 -1
  160. package/lib/index.js +2 -1
  161. package/lib/index.js.map +1 -1
  162. package/lib/packageVersion.d.ts +1 -1
  163. package/lib/packageVersion.d.ts.map +1 -1
  164. package/lib/packageVersion.js +1 -1
  165. package/lib/packageVersion.js.map +1 -1
  166. package/lib/shared-tree/checkoutFlexTreeView.d.ts +1 -0
  167. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  168. package/lib/shared-tree/checkoutFlexTreeView.js +4 -0
  169. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  170. package/lib/shared-tree/sharedTree.js +2 -2
  171. package/lib/shared-tree/sharedTree.js.map +1 -1
  172. package/lib/shared-tree/treeApiAlpha.d.ts +6 -6
  173. package/lib/shared-tree/treeApiAlpha.d.ts.map +1 -1
  174. package/lib/shared-tree/treeApiAlpha.js.map +1 -1
  175. package/lib/shared-tree-core/sharedTreeCore.d.ts +0 -6
  176. package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
  177. package/lib/shared-tree-core/sharedTreeCore.js +0 -17
  178. package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
  179. package/lib/simple-tree/api/conciseTree.d.ts +2 -2
  180. package/lib/simple-tree/api/conciseTree.d.ts.map +1 -1
  181. package/lib/simple-tree/api/conciseTree.js.map +1 -1
  182. package/lib/simple-tree/api/customTree.d.ts +14 -12
  183. package/lib/simple-tree/api/customTree.d.ts.map +1 -1
  184. package/lib/simple-tree/api/customTree.js.map +1 -1
  185. package/lib/simple-tree/api/getJsonSchema.d.ts +21 -7
  186. package/lib/simple-tree/api/getJsonSchema.d.ts.map +1 -1
  187. package/lib/simple-tree/api/getJsonSchema.js +8 -16
  188. package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
  189. package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -10
  190. package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
  191. package/lib/simple-tree/api/getSimpleSchema.js +4 -16
  192. package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
  193. package/lib/simple-tree/api/index.d.ts +4 -3
  194. package/lib/simple-tree/api/index.d.ts.map +1 -1
  195. package/lib/simple-tree/api/index.js +1 -1
  196. package/lib/simple-tree/api/index.js.map +1 -1
  197. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +17 -1
  198. package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
  199. package/lib/simple-tree/api/schemaFactoryAlpha.js +4 -0
  200. package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
  201. package/lib/simple-tree/api/schemaFromSimple.d.ts +5 -2
  202. package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
  203. package/lib/simple-tree/api/schemaFromSimple.js +24 -8
  204. package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
  205. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +11 -3
  206. package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
  207. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +41 -29
  208. package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
  209. package/lib/simple-tree/api/tree.d.ts +32 -5
  210. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  211. package/lib/simple-tree/api/tree.js +16 -1
  212. package/lib/simple-tree/api/tree.js.map +1 -1
  213. package/lib/simple-tree/api/verboseTree.d.ts +4 -28
  214. package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
  215. package/lib/simple-tree/api/verboseTree.js.map +1 -1
  216. package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
  217. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +7 -3
  218. package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
  219. package/lib/simple-tree/core/treeNodeKernel.d.ts +9 -2
  220. package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
  221. package/lib/simple-tree/core/treeNodeKernel.js +48 -32
  222. package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
  223. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +2 -1
  224. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  225. package/lib/simple-tree/core/unhydratedFlexTree.js +15 -1
  226. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  227. package/lib/simple-tree/index.d.ts +1 -1
  228. package/lib/simple-tree/index.d.ts.map +1 -1
  229. package/lib/simple-tree/index.js +1 -1
  230. package/lib/simple-tree/index.js.map +1 -1
  231. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  232. package/lib/simple-tree/objectNode.js +4 -1
  233. package/lib/simple-tree/objectNode.js.map +1 -1
  234. package/lib/simple-tree/simpleSchema.d.ts +4 -11
  235. package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
  236. package/lib/simple-tree/simpleSchema.js.map +1 -1
  237. package/lib/tableSchema.d.ts +241 -0
  238. package/lib/tableSchema.d.ts.map +1 -0
  239. package/lib/tableSchema.js +235 -0
  240. package/lib/tableSchema.js.map +1 -0
  241. package/lib/treeFactory.d.ts +4 -4
  242. package/lib/treeFactory.d.ts.map +1 -1
  243. package/lib/treeFactory.js.map +1 -1
  244. package/lib/util/breakable.d.ts.map +1 -1
  245. package/lib/util/breakable.js +9 -7
  246. package/lib/util/breakable.js.map +1 -1
  247. package/package.json +23 -22
  248. package/src/feature-libraries/flex-tree/context.ts +13 -3
  249. package/src/feature-libraries/flex-tree/flexTreeTypes.ts +8 -0
  250. package/src/feature-libraries/flex-tree/index.ts +0 -1
  251. package/src/feature-libraries/flex-tree/lazyEntity.ts +11 -21
  252. package/src/feature-libraries/flex-tree/lazyField.ts +17 -26
  253. package/src/feature-libraries/flex-tree/lazyNode.ts +13 -19
  254. package/src/feature-libraries/index.ts +0 -1
  255. package/src/feature-libraries/node-identifier/nodeIdentifierManager.ts +39 -38
  256. package/src/index.ts +6 -2
  257. package/src/packageVersion.ts +1 -1
  258. package/src/shared-tree/checkoutFlexTreeView.ts +6 -0
  259. package/src/shared-tree/sharedTree.ts +2 -2
  260. package/src/shared-tree/treeApiAlpha.ts +17 -15
  261. package/src/shared-tree-core/sharedTreeCore.ts +0 -23
  262. package/src/simple-tree/api/conciseTree.ts +4 -4
  263. package/src/simple-tree/api/customTree.ts +16 -14
  264. package/src/simple-tree/api/getJsonSchema.ts +25 -16
  265. package/src/simple-tree/api/getSimpleSchema.ts +4 -18
  266. package/src/simple-tree/api/index.ts +4 -2
  267. package/src/simple-tree/api/schemaFactoryAlpha.ts +18 -1
  268. package/src/simple-tree/api/schemaFromSimple.ts +45 -16
  269. package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +53 -34
  270. package/src/simple-tree/api/tree.ts +51 -4
  271. package/src/simple-tree/api/verboseTree.ts +7 -32
  272. package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +8 -3
  273. package/src/simple-tree/core/treeNodeKernel.ts +57 -35
  274. package/src/simple-tree/core/unhydratedFlexTree.ts +22 -5
  275. package/src/simple-tree/index.ts +4 -2
  276. package/src/simple-tree/objectNode.ts +4 -2
  277. package/src/simple-tree/simpleSchema.ts +4 -12
  278. package/src/tableSchema.ts +668 -0
  279. package/src/treeFactory.ts +4 -3
  280. package/src/util/breakable.ts +9 -6
@@ -0,0 +1,668 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { oob } from "@fluidframework/core-utils/internal";
7
+
8
+ import { Tree } from "./shared-tree/index.js";
9
+ import {
10
+ type ImplicitAllowedTypes,
11
+ type ImplicitFieldSchema,
12
+ type InsertableObjectFromSchemaRecord,
13
+ type InsertableTreeNodeFromImplicitAllowedTypes,
14
+ type NodeKind,
15
+ type SchemaFactoryAlpha,
16
+ type ScopedSchemaName,
17
+ TreeArrayNode,
18
+ type TreeNode,
19
+ type TreeNodeFromImplicitAllowedTypes,
20
+ type TreeNodeSchema,
21
+ type TreeNodeSchemaClass,
22
+ type WithType,
23
+ } from "./simple-tree/index.js";
24
+
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
28
+ // - Record-like type parameters / input parameters?
29
+ // - Move `@system` types into separate / sub scope?
30
+
31
+ /**
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
35
+ */
36
+ export namespace TableSchema {
37
+ const tableSchemaFactorySubScope = "table";
38
+
39
+ // #region Column
40
+
41
+ /**
42
+ * A column in a table.
43
+ * @remarks Implemented by the schema class returned from {@link TableSchema.createColumn}.
44
+ * @sealed @internal
45
+ */
46
+ export interface IColumn {
47
+ /**
48
+ * The unique identifier of the column.
49
+ * @remarks Uniquely identifies the node within the entire tree, not just the table.
50
+ */
51
+ readonly id: string;
52
+ }
53
+
54
+ /**
55
+ * Factory for creating new table column schema.
56
+ * @internal
57
+ */
58
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
59
+ export function createColumn<const TInputScope extends string | undefined>(
60
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
61
+ ) {
62
+ const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
63
+ type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
64
+
65
+ /**
66
+ * {@link Column} fields.
67
+ * @remarks Extracted for re-use in returned type signature defined later in this function.
68
+ * The implicit typing is intentional.
69
+ */
70
+ const columnFields = {
71
+ id: schemaFactory.identifier,
72
+ } as const satisfies Record<string, ImplicitFieldSchema>;
73
+
74
+ /**
75
+ * A column in a table.
76
+ */
77
+ class Column extends schemaFactory.object("Column", columnFields) implements IColumn {}
78
+
79
+ type ColumnValueType = TreeNode & IColumn & WithType<ScopedSchemaName<Scope, "Column">>;
80
+ type ColumnInsertableType = InsertableObjectFromSchemaRecord<typeof columnFields>;
81
+
82
+ // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
83
+ // for the private brand field of TreeNode.
84
+ // This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.
85
+ // This is avoided by doing this type conversion.
86
+ // The conversion is done via assignment instead of `as` to get stronger type safety.
87
+ const ColumnSchemaType: TreeNodeSchemaClass<
88
+ /* Name */ ScopedSchemaName<Scope, "Column">,
89
+ /* Kind */ NodeKind.Object,
90
+ /* TNode */ ColumnValueType,
91
+ /* TInsertable */ object & ColumnInsertableType,
92
+ /* ImplicitlyConstructable */ true,
93
+ /* Info */ typeof columnFields
94
+ > = Column;
95
+
96
+ return ColumnSchemaType;
97
+ }
98
+
99
+ /**
100
+ * Base column schema type.
101
+ * @sealed @system @internal
102
+ */
103
+ export type ColumnSchemaBase<TScope extends string | undefined> = ReturnType<
104
+ typeof createColumn<TScope>
105
+ >;
106
+
107
+ // #endregion
108
+
109
+ // #region Row
110
+
111
+ /**
112
+ * A row in a table.
113
+ * @remarks Implemented by the schema class returned from {@link TableSchema.createRow}.
114
+ * @sealed @internal
115
+ */
116
+ export interface IRow<
117
+ TCellSchema extends ImplicitAllowedTypes,
118
+ TColumnSchema extends ImplicitAllowedTypes,
119
+ > {
120
+ /**
121
+ * The unique identifier of the row.
122
+ * @remarks Uniquely identifies the node within the entire tree, not just the table.
123
+ */
124
+ readonly id: string;
125
+
126
+ /**
127
+ * Gets the cell in the specified column
128
+ * @returns The cell if it exists, otherwise undefined.
129
+ * @privateRemarks TODO: add overload that takes column ID.
130
+ */
131
+ getCell(
132
+ column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>,
133
+ ): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
134
+
135
+ /**
136
+ * Sets the cell in the specified column.
137
+ * @remarks To remove a cell, call {@link TableSchema.IRow.removeCell} instead.
138
+ * @privateRemarks TODO: add overload that takes column ID.
139
+ */
140
+ setCell(
141
+ column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>,
142
+ value: InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>,
143
+ ): void;
144
+
145
+ /**
146
+ * Removes the cell in the specified column.
147
+ * @privateRemarks TODO: add overload that takes column ID.
148
+ */
149
+ removeCell(column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>): void;
150
+ }
151
+
152
+ /**
153
+ * Factory for creating new table row schema.
154
+ * @privateRemarks TODO: add overloads to make column schema optional.
155
+ * @sealed @internal
156
+ */
157
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
158
+ export function createRow<
159
+ const TInputScope extends string | undefined,
160
+ const TCellSchema extends ImplicitAllowedTypes,
161
+ const TColumnSchema extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,
162
+ >(
163
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
164
+ cellSchema: TCellSchema,
165
+ _columnSchema: TColumnSchema,
166
+ ) {
167
+ const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
168
+ type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
169
+
170
+ type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
171
+ type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>;
172
+
173
+ type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
174
+
175
+ /**
176
+ * {@link Row} fields.
177
+ * @remarks Extracted for re-use in returned type signature defined later in this function.
178
+ * The implicit typing is intentional.
179
+ */
180
+ const rowFields = {
181
+ id: schemaFactory.identifier,
182
+ cells: schemaFactory.map("Row.cells", cellSchema),
183
+ } as const satisfies Record<string, ImplicitFieldSchema>;
184
+
185
+ /**
186
+ * The Row schema - this is a map of Cells where the key is the column id
187
+ */
188
+ class Row
189
+ extends schemaFactory.object("Row", rowFields)
190
+ implements IRow<TCellSchema, TColumnSchema>
191
+ {
192
+ public getCell(column: ColumnValueType): CellValueType | undefined {
193
+ return this.cells.get(column.id) as CellValueType | undefined;
194
+ }
195
+
196
+ public setCell(column: ColumnValueType, value: CellInsertableType | undefined): void {
197
+ this.cells.set(column.id, value);
198
+ }
199
+
200
+ public removeCell(column: ColumnValueType): void {
201
+ if (!this.cells.has(column.id)) return;
202
+ this.cells.delete(column.id);
203
+ }
204
+ }
205
+
206
+ type RowValueType = TreeNode &
207
+ IRow<TCellSchema, TColumnSchema> &
208
+ WithType<ScopedSchemaName<Scope, "Row">>;
209
+ type RowInsertableType = InsertableObjectFromSchemaRecord<typeof rowFields>;
210
+
211
+ // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
212
+ // for the private brand field of TreeNode.
213
+ // This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.
214
+ // This is avoided by doing this type conversion.
215
+ // The conversion is done via assignment instead of `as` to get stronger type safety.
216
+ const RowSchemaType: TreeNodeSchemaClass<
217
+ /* Name */ ScopedSchemaName<Scope, "Row">,
218
+ /* Kind */ NodeKind.Object,
219
+ /* TNode */ RowValueType,
220
+ /* TInsertable */ object & RowInsertableType,
221
+ /* ImplicitlyConstructable */ true,
222
+ /* Info */ typeof rowFields
223
+ > = Row;
224
+
225
+ return RowSchemaType;
226
+ }
227
+
228
+ /**
229
+ * Base row schema type.
230
+ * @sealed @system @internal
231
+ */
232
+ export type RowSchemaBase<
233
+ TScope extends string | undefined,
234
+ TCellSchema extends ImplicitAllowedTypes,
235
+ TColumnSchema extends ColumnSchemaBase<TScope> = ColumnSchemaBase<TScope>,
236
+ > = ReturnType<typeof createRow<TScope, TCellSchema, TColumnSchema>>;
237
+
238
+ // #endregion
239
+
240
+ // #region Table
241
+
242
+ /**
243
+ * A key to uniquely identify a cell in a table.
244
+ * @sealed @internal
245
+ */
246
+ export interface CellKey {
247
+ /**
248
+ * {@link TableSchema.IColumn.id} of the containing {@link TableSchema.IColumn}.
249
+ */
250
+ readonly columnId: string;
251
+
252
+ /**
253
+ * {@link TableSchema.IRow.id} of the containing {@link TableSchema.IRow}.
254
+ */
255
+ readonly rowId: string;
256
+ }
257
+
258
+ /**
259
+ * {@link TableSchema.ITable.insertColumn} parameters.
260
+ * @sealed @internal
261
+ */
262
+ export interface InsertColumnParameters<TInsertableColumn> {
263
+ /**
264
+ * The index at which to insert the new column.
265
+ * @remarks If not provided, the column will be appended to the end of the table.
266
+ */
267
+ readonly index?: number | undefined;
268
+
269
+ /**
270
+ * The column to insert.
271
+ */
272
+ readonly column: TInsertableColumn;
273
+ }
274
+
275
+ /**
276
+ * {@link TableSchema.ITable.insertRows} parameters.
277
+ * @sealed @internal
278
+ */
279
+ export interface InsertRowsParameters<TInsertableRow> {
280
+ /**
281
+ * The index at which to insert the new rows.
282
+ * @remarks If not provided, the rows will be appended to the end of the table.
283
+ */
284
+ readonly index?: number | undefined;
285
+
286
+ /**
287
+ * The rows to insert.
288
+ */
289
+ readonly rows: TInsertableRow[];
290
+ }
291
+
292
+ /**
293
+ * {@link TableSchema.ITable.setCell} parameters.
294
+ * @sealed @internal
295
+ */
296
+ export interface SetCellParameters<TInsertableCell> {
297
+ /**
298
+ * The key to uniquely identify a cell in a table.
299
+ */
300
+ readonly key: CellKey;
301
+
302
+ /**
303
+ * The cell to set.
304
+ */
305
+ readonly cell: TInsertableCell;
306
+ }
307
+
308
+ /**
309
+ * A table.
310
+ * @sealed @internal
311
+ */
312
+ export interface ITable<
313
+ TCellSchema extends ImplicitAllowedTypes,
314
+ TColumnSchema extends ImplicitAllowedTypes,
315
+ TRowSchema extends ImplicitAllowedTypes,
316
+ > {
317
+ /**
318
+ * The table's columns.
319
+ */
320
+ readonly columns: TreeArrayNode<TColumnSchema>;
321
+
322
+ /**
323
+ * The table's rows.
324
+ */
325
+ readonly rows: TreeArrayNode<TRowSchema>;
326
+
327
+ /**
328
+ * Gets a table column by its {@link TableSchema.IRow.id}.
329
+ */
330
+ getColumn(id: string): TreeNodeFromImplicitAllowedTypes<TColumnSchema> | undefined;
331
+
332
+ /**
333
+ * Gets a table row by its {@link TableSchema.IRow.id}.
334
+ */
335
+ getRow(id: string): TreeNodeFromImplicitAllowedTypes<TRowSchema> | undefined;
336
+
337
+ /**
338
+ * Gets a cell in the table by column and row IDs.
339
+ * @param key - A key that uniquely distinguishes a cell in the table, represented as a combination of the column ID and row ID.
340
+ * @privateRemarks TODO: add overload that takes row and column nodes.
341
+ */
342
+ getCell(key: CellKey): TreeNodeFromImplicitAllowedTypes<TCellSchema> | undefined;
343
+
344
+ /**
345
+ * Inserts a column into the table.
346
+ * @throws Throws an error if the column is already in the tree, or if the specified index is out of range.
347
+ */
348
+ insertColumn(
349
+ params: InsertColumnParameters<
350
+ InsertableTreeNodeFromImplicitAllowedTypes<TColumnSchema>
351
+ >,
352
+ ): TreeNodeFromImplicitAllowedTypes<TColumnSchema>;
353
+
354
+ /**
355
+ * Inserts 0 or more rows into the table.
356
+ * @throws Throws an error if any of the rows are already in the tree, or if the specified index is out of range.
357
+ */
358
+ insertRows(
359
+ params: InsertRowsParameters<InsertableTreeNodeFromImplicitAllowedTypes<TRowSchema>>,
360
+ ): TreeNodeFromImplicitAllowedTypes<TRowSchema>[];
361
+
362
+ /**
363
+ * Sets the cell at the specified location in the table.
364
+ * @remarks To remove a cell, call {@link TableSchema.ITable.removeCell} instead.
365
+ * @privateRemarks TODO: add overload that takes column/row nodes?
366
+ */
367
+ setCell(
368
+ params: SetCellParameters<InsertableTreeNodeFromImplicitAllowedTypes<TCellSchema>>,
369
+ ): void;
370
+
371
+ /**
372
+ * Removes the specified column from the table.
373
+ * @remarks Note: this does not remove any cells from the table's rows.
374
+ * @privateRemarks
375
+ * TODO:
376
+ * - Policy for when the column is not in the table.
377
+ * - Actually remove corresponding cells from table rows.
378
+ */
379
+ removeColumn: (column: TreeNodeFromImplicitAllowedTypes<TColumnSchema>) => void;
380
+
381
+ /**
382
+ * Removes 0 or more rows from the table.
383
+ * @privateRemarks TODO: policy for when 1 or more rows are not in the table.
384
+ */
385
+ removeRows: (rows: readonly TreeNodeFromImplicitAllowedTypes<TRowSchema>[]) => void;
386
+
387
+ /**
388
+ * Removes all rows from the table.
389
+ */
390
+ removeAllRows: () => void;
391
+
392
+ /**
393
+ * Removes the cell at the specified location in the table.
394
+ * @privateRemarks TODO: add overload that takes column/row nodes?
395
+ */
396
+ removeCell: (key: CellKey) => void;
397
+ }
398
+
399
+ /**
400
+ * Factory for creating new table schema without specifying row or column schema.
401
+ * @internal
402
+ */
403
+ export function createTable<
404
+ const TInputScope extends string | undefined,
405
+ const TCell extends ImplicitAllowedTypes,
406
+ >(
407
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
408
+ _cellSchema: TCell,
409
+ ): ReturnType<typeof createTableInternal<TInputScope, TCell>>;
410
+ /**
411
+ * Factory for creating new table schema without specifyint row schema
412
+ * @internal
413
+ */
414
+ export function createTable<
415
+ const TInputScope extends string | undefined,
416
+ const TCell extends ImplicitAllowedTypes,
417
+ const TColumn extends ColumnSchemaBase<TInputScope>,
418
+ >(
419
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
420
+ _cellSchema: TCell,
421
+ columnSchema: TColumn,
422
+ ): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn>>;
423
+ /**
424
+ * Factory for creating new table schema.
425
+ * @internal
426
+ */
427
+ export function createTable<
428
+ const TInputScope extends string | undefined,
429
+ const TCell extends ImplicitAllowedTypes,
430
+ const TColumn extends ColumnSchemaBase<TInputScope>,
431
+ const TRow extends RowSchemaBase<TInputScope, TCell, TColumn>,
432
+ >(
433
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
434
+ _cellSchema: TCell,
435
+ columnSchema: TColumn,
436
+ rowSchema: TRow,
437
+ ): ReturnType<typeof createTableInternal<TInputScope, TCell, TColumn, TRow>>;
438
+ export function createTable<
439
+ const TInputScope extends string | undefined,
440
+ const TCell extends ImplicitAllowedTypes,
441
+ const TColumn extends ColumnSchemaBase<TInputScope>,
442
+ const TRow extends RowSchemaBase<TInputScope, TCell, TColumn>,
443
+ >(
444
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
445
+ _cellSchema: TCell,
446
+ columnSchema?: TColumn,
447
+ rowSchema?: TRow,
448
+ ): TreeNodeSchema {
449
+ const column = columnSchema ?? createColumn(inputSchemaFactory);
450
+ return createTableInternal(
451
+ inputSchemaFactory,
452
+ _cellSchema,
453
+ column as TColumn,
454
+ rowSchema ?? (createRow(inputSchemaFactory, _cellSchema, column) as TRow),
455
+ );
456
+ }
457
+
458
+ /**
459
+ * Factory for creating new table schema.
460
+ * @system @internal
461
+ */
462
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
463
+ export function createTableInternal<
464
+ const TInputScope extends string | undefined,
465
+ const TCell extends ImplicitAllowedTypes,
466
+ const TColumn extends ColumnSchemaBase<TInputScope> = ColumnSchemaBase<TInputScope>,
467
+ const TRow extends RowSchemaBase<TInputScope, TCell, TColumn> = RowSchemaBase<
468
+ TInputScope,
469
+ TCell,
470
+ TColumn
471
+ >,
472
+ >(
473
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
474
+ _cellSchema: TCell,
475
+ columnSchema: TColumn,
476
+ rowSchema: TRow,
477
+ ) {
478
+ const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
479
+ type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
480
+
481
+ type CellValueType = TreeNodeFromImplicitAllowedTypes<TCell>;
482
+ type CellInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TCell>;
483
+
484
+ type ColumnValueType = TreeNodeFromImplicitAllowedTypes<TColumn>;
485
+ type ColumnInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TColumn>;
486
+
487
+ type RowValueType = TreeNodeFromImplicitAllowedTypes<TRow>;
488
+ type RowInsertableType = InsertableTreeNodeFromImplicitAllowedTypes<TRow>;
489
+
490
+ /**
491
+ * {@link Table} fields.
492
+ * @remarks Extracted for re-use in returned type signature defined later in this function.
493
+ * The implicit typing is intentional.
494
+ */
495
+ const tableFields = {
496
+ rows: schemaFactory.array("Table.rows", rowSchema),
497
+ columns: schemaFactory.array("Table.columns", columnSchema),
498
+ } as const satisfies Record<string, ImplicitFieldSchema>;
499
+
500
+ /**
501
+ * The Table schema
502
+ */
503
+ class Table
504
+ extends schemaFactory.object("Table", tableFields)
505
+ implements ITable<TCell, TColumn, TRow>
506
+ {
507
+ public getColumn(id: string): ColumnValueType | undefined {
508
+ // TypeScript is unable to narrow the types correctly here, hence the casts.
509
+ // See: https://github.com/microsoft/TypeScript/issues/52144
510
+ return this.columns.find((column) => (column as ColumnValueType).id === id) as
511
+ | ColumnValueType
512
+ | undefined;
513
+ }
514
+
515
+ public getRow(id: string): RowValueType | undefined {
516
+ // TypeScript is unable to narrow the types correctly here, hence the casts.
517
+ // See: https://github.com/microsoft/TypeScript/issues/52144
518
+ return this.rows.find((_row) => (_row as RowValueType).id === id) as
519
+ | RowValueType
520
+ | undefined;
521
+ }
522
+
523
+ public getCell(key: CellKey): CellValueType | undefined {
524
+ const { columnId, rowId } = key;
525
+ const row = this.getRow(rowId);
526
+ if (row !== undefined) {
527
+ const column = this.getColumn(columnId);
528
+ if (column !== undefined) {
529
+ return row.getCell(column);
530
+ }
531
+ }
532
+ // If the cell does not exist return undefined
533
+ return undefined;
534
+ }
535
+
536
+ public insertColumn({
537
+ column,
538
+ index,
539
+ }: InsertColumnParameters<ColumnInsertableType>): ColumnValueType {
540
+ if (index === undefined) {
541
+ // TypeScript is unable to narrow the types correctly here, hence the cast.
542
+ // See: https://github.com/microsoft/TypeScript/issues/52144
543
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
544
+ this.columns.insertAtEnd(column as any);
545
+ } else {
546
+ // TypeScript is unable to narrow the types correctly here, hence the cast.
547
+ // See: https://github.com/microsoft/TypeScript/issues/52144
548
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
549
+ this.columns.insertAt(index, column as any);
550
+ }
551
+
552
+ // Inserting the input node into the tree hydrates it, making it usable as a node.
553
+ return column as ColumnValueType;
554
+ }
555
+
556
+ public insertRows({
557
+ index,
558
+ rows,
559
+ }: InsertRowsParameters<RowInsertableType>): RowValueType[] {
560
+ if (index === undefined) {
561
+ // TypeScript is unable to narrow the types correctly here, hence the cast.
562
+ // See: https://github.com/microsoft/TypeScript/issues/52144
563
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
564
+ this.rows.insertAtEnd(TreeArrayNode.spread(rows) as any);
565
+ } else {
566
+ // TypeScript is unable to narrow the types correctly here, hence the cast.
567
+ // See: https://github.com/microsoft/TypeScript/issues/52144
568
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
569
+ this.rows.insertAt(index, TreeArrayNode.spread(rows) as any);
570
+ }
571
+
572
+ // Inserting the input nodes into the tree hydrates them, making them usable as nodes.
573
+ return rows as unknown as RowValueType[];
574
+ }
575
+
576
+ public setCell({ key, cell }: SetCellParameters<CellInsertableType>): void {
577
+ const { columnId, rowId } = key;
578
+ const row = this.getRow(rowId);
579
+ if (row !== undefined) {
580
+ const column = this.getColumn(columnId);
581
+ if (column !== undefined) {
582
+ row.setCell(column, cell);
583
+ }
584
+ }
585
+ }
586
+
587
+ public removeColumn(column: ColumnValueType): void {
588
+ const index = this.columns.indexOf(column);
589
+ // If the column is not in the table, do nothing
590
+ if (index === -1) return;
591
+ this.columns.removeAt(index);
592
+ }
593
+
594
+ public removeRows(rows: readonly RowValueType[]): void {
595
+ // If there are no rows to remove, do nothing
596
+ if (rows.length === 0) {
597
+ return;
598
+ }
599
+
600
+ // If there is only one row to remove, remove it
601
+ if (rows.length === 1) {
602
+ const index = this.rows.indexOf(rows[0] ?? oob());
603
+ this.rows.removeAt(index);
604
+ return;
605
+ }
606
+ // If there are multiple rows to remove, remove them in a transaction
607
+ // This is to avoid the performance issues of deleting multiple rows at once
608
+ Tree.runTransaction(this, () => {
609
+ // Iterate over the rows and remove them
610
+ for (const row of rows) {
611
+ const index = this.rows.indexOf(row);
612
+ this.rows.removeAt(index);
613
+ }
614
+ });
615
+ }
616
+
617
+ public removeAllRows(): void {
618
+ this.rows.removeRange();
619
+ }
620
+
621
+ public removeCell(key: CellKey): void {
622
+ const { columnId, rowId } = key;
623
+ const row = this.getRow(rowId);
624
+ if (row !== undefined) {
625
+ const column = this.getColumn(columnId);
626
+ if (column !== undefined) {
627
+ row.removeCell(column);
628
+ }
629
+ }
630
+ }
631
+ }
632
+
633
+ type TableValueType = TreeNode &
634
+ ITable<TCell, TColumn, TRow> &
635
+ WithType<ScopedSchemaName<Scope, "Table">>;
636
+ type TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;
637
+
638
+ // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
639
+ // for the private brand field of TreeNode.
640
+ // This numeric id doesn't seem to be stable over incremental builds, and thus causes diffs in the API extractor reports.
641
+ // This is avoided by doing this type conversion.
642
+ // The conversion is done via assignment instead of `as` to get stronger type safety.
643
+ const TableSchemaType: TreeNodeSchemaClass<
644
+ /* Name */ ScopedSchemaName<Scope, "Table">,
645
+ /* Kind */ NodeKind.Object,
646
+ /* TNode */ TableValueType,
647
+ /* TInsertable */ object & TableInsertableType,
648
+ /* ImplicitlyConstructable */ true,
649
+ /* Info */ typeof tableFields
650
+ > = Table;
651
+
652
+ // Return the table schema
653
+ return TableSchemaType;
654
+ }
655
+
656
+ /**
657
+ * Base row schema type.
658
+ * @sealed @system @internal
659
+ */
660
+ export type TableSchemaBase<
661
+ TScope extends string | undefined,
662
+ TCell extends ImplicitAllowedTypes,
663
+ TColumn extends ColumnSchemaBase<TScope> = ColumnSchemaBase<TScope>,
664
+ TRow extends RowSchemaBase<TScope, TCell, TColumn> = RowSchemaBase<TScope, TCell, TColumn>,
665
+ > = ReturnType<typeof createTable<TScope, TCell, TColumn, TRow>>;
666
+
667
+ // #endregion
668
+ }
@@ -17,6 +17,7 @@ import {
17
17
 
18
18
  import {
19
19
  SharedTree as SharedTreeImpl,
20
+ type ISharedTree,
20
21
  type SharedTreeOptions,
21
22
  type SharedTreeOptionsInternal,
22
23
  } from "./shared-tree/index.js";
@@ -27,7 +28,7 @@ import { SharedTreeFactoryType, SharedTreeAttributes } from "./sharedTreeAttribu
27
28
  /**
28
29
  * A channel factory that creates an {@link ITree}.
29
30
  */
30
- export class TreeFactory implements IChannelFactory<ITree> {
31
+ export class TreeFactory implements IChannelFactory<ISharedTree> {
31
32
  public static Type: string = SharedTreeFactoryType;
32
33
  public readonly type: string = SharedTreeFactoryType;
33
34
 
@@ -40,13 +41,13 @@ export class TreeFactory implements IChannelFactory<ITree> {
40
41
  id: string,
41
42
  services: IChannelServices,
42
43
  channelAttributes: Readonly<IChannelAttributes>,
43
- ): Promise<SharedTreeImpl> {
44
+ ): Promise<ISharedTree> {
44
45
  const tree = new SharedTreeImpl(id, runtime, channelAttributes, this.options);
45
46
  await tree.load(services);
46
47
  return tree;
47
48
  }
48
49
 
49
- public create(runtime: IFluidDataStoreRuntime, id: string): SharedTreeImpl {
50
+ public create(runtime: IFluidDataStoreRuntime, id: string): ISharedTree {
50
51
  const tree = new SharedTreeImpl(id, runtime, this.attributes, this.options);
51
52
  tree.initializeLocal();
52
53
  return tree;