@fluidframework/tree 2.40.0 → 2.41.0-338186

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 (198) hide show
  1. package/api-report/tree.alpha.api.md +1 -1
  2. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  3. package/dist/feature-libraries/default-schema/schemaChecker.js +0 -7
  4. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  5. package/dist/feature-libraries/flex-tree/context.d.ts +16 -14
  6. package/dist/feature-libraries/flex-tree/context.d.ts.map +1 -1
  7. package/dist/feature-libraries/flex-tree/context.js +12 -18
  8. package/dist/feature-libraries/flex-tree/context.js.map +1 -1
  9. package/dist/feature-libraries/flex-tree/index.d.ts +1 -1
  10. package/dist/feature-libraries/flex-tree/index.d.ts.map +1 -1
  11. package/dist/feature-libraries/flex-tree/index.js +1 -2
  12. package/dist/feature-libraries/flex-tree/index.js.map +1 -1
  13. package/dist/feature-libraries/flex-tree/lazyField.d.ts +1 -5
  14. package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  15. package/dist/feature-libraries/flex-tree/lazyField.js +2 -16
  16. package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
  17. package/dist/feature-libraries/flex-tree/utilities.d.ts +6 -6
  18. package/dist/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  19. package/dist/feature-libraries/flex-tree/utilities.js +6 -7
  20. package/dist/feature-libraries/flex-tree/utilities.js.map +1 -1
  21. package/dist/feature-libraries/index.d.ts +1 -1
  22. package/dist/feature-libraries/index.d.ts.map +1 -1
  23. package/dist/feature-libraries/index.js +1 -2
  24. package/dist/feature-libraries/index.js.map +1 -1
  25. package/dist/packageVersion.d.ts +1 -1
  26. package/dist/packageVersion.d.ts.map +1 -1
  27. package/dist/packageVersion.js +1 -1
  28. package/dist/packageVersion.js.map +1 -1
  29. package/dist/shared-tree/checkoutFlexTreeView.d.ts +7 -3
  30. package/dist/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  31. package/dist/shared-tree/checkoutFlexTreeView.js +11 -2
  32. package/dist/shared-tree/checkoutFlexTreeView.js.map +1 -1
  33. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  34. package/dist/shared-tree/schematizeTree.js +1 -1
  35. package/dist/shared-tree/schematizeTree.js.map +1 -1
  36. package/dist/shared-tree/schematizingTreeView.d.ts +3 -0
  37. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  38. package/dist/shared-tree/schematizingTreeView.js +13 -7
  39. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  40. package/dist/shared-tree/treeAlpha.d.ts +1 -4
  41. package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
  42. package/dist/shared-tree/treeAlpha.js +6 -1
  43. package/dist/shared-tree/treeAlpha.js.map +1 -1
  44. package/dist/simple-tree/api/create.d.ts +5 -1
  45. package/dist/simple-tree/api/create.d.ts.map +1 -1
  46. package/dist/simple-tree/api/create.js +10 -11
  47. package/dist/simple-tree/api/create.js.map +1 -1
  48. package/dist/simple-tree/api/index.d.ts +2 -2
  49. package/dist/simple-tree/api/index.d.ts.map +1 -1
  50. package/dist/simple-tree/api/index.js +2 -2
  51. package/dist/simple-tree/api/index.js.map +1 -1
  52. package/dist/simple-tree/api/storedSchema.d.ts +1 -8
  53. package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
  54. package/dist/simple-tree/api/storedSchema.js +3 -14
  55. package/dist/simple-tree/api/storedSchema.js.map +1 -1
  56. package/dist/simple-tree/arrayNode.d.ts.map +1 -1
  57. package/dist/simple-tree/arrayNode.js +3 -9
  58. package/dist/simple-tree/arrayNode.js.map +1 -1
  59. package/dist/simple-tree/core/unhydratedFlexTree.d.ts +4 -4
  60. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  61. package/dist/simple-tree/core/unhydratedFlexTree.js +9 -5
  62. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  63. package/dist/simple-tree/index.d.ts +3 -2
  64. package/dist/simple-tree/index.d.ts.map +1 -1
  65. package/dist/simple-tree/index.js +6 -4
  66. package/dist/simple-tree/index.js.map +1 -1
  67. package/dist/simple-tree/mapNode.d.ts.map +1 -1
  68. package/dist/simple-tree/mapNode.js +17 -20
  69. package/dist/simple-tree/mapNode.js.map +1 -1
  70. package/dist/simple-tree/objectNode.d.ts.map +1 -1
  71. package/dist/simple-tree/objectNode.js +2 -4
  72. package/dist/simple-tree/objectNode.js.map +1 -1
  73. package/dist/simple-tree/prepareForInsertion.d.ts +30 -0
  74. package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -0
  75. package/dist/simple-tree/prepareForInsertion.js +137 -0
  76. package/dist/simple-tree/prepareForInsertion.js.map +1 -0
  77. package/dist/simple-tree/proxies.d.ts +1 -12
  78. package/dist/simple-tree/proxies.d.ts.map +1 -1
  79. package/dist/simple-tree/proxies.js +10 -106
  80. package/dist/simple-tree/proxies.js.map +1 -1
  81. package/dist/simple-tree/toMapTree.d.ts +1 -1
  82. package/dist/simple-tree/toMapTree.js +1 -1
  83. package/dist/simple-tree/toMapTree.js.map +1 -1
  84. package/dist/tableSchema.d.ts +108 -59
  85. package/dist/tableSchema.d.ts.map +1 -1
  86. package/dist/tableSchema.js +93 -44
  87. package/dist/tableSchema.js.map +1 -1
  88. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  89. package/lib/feature-libraries/default-schema/schemaChecker.js +0 -7
  90. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  91. package/lib/feature-libraries/flex-tree/context.d.ts +16 -14
  92. package/lib/feature-libraries/flex-tree/context.d.ts.map +1 -1
  93. package/lib/feature-libraries/flex-tree/context.js +11 -16
  94. package/lib/feature-libraries/flex-tree/context.js.map +1 -1
  95. package/lib/feature-libraries/flex-tree/index.d.ts +1 -1
  96. package/lib/feature-libraries/flex-tree/index.d.ts.map +1 -1
  97. package/lib/feature-libraries/flex-tree/index.js +1 -1
  98. package/lib/feature-libraries/flex-tree/index.js.map +1 -1
  99. package/lib/feature-libraries/flex-tree/lazyField.d.ts +1 -5
  100. package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
  101. package/lib/feature-libraries/flex-tree/lazyField.js +1 -14
  102. package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
  103. package/lib/feature-libraries/flex-tree/utilities.d.ts +6 -6
  104. package/lib/feature-libraries/flex-tree/utilities.d.ts.map +1 -1
  105. package/lib/feature-libraries/flex-tree/utilities.js +6 -7
  106. package/lib/feature-libraries/flex-tree/utilities.js.map +1 -1
  107. package/lib/feature-libraries/index.d.ts +1 -1
  108. package/lib/feature-libraries/index.d.ts.map +1 -1
  109. package/lib/feature-libraries/index.js +1 -1
  110. package/lib/feature-libraries/index.js.map +1 -1
  111. package/lib/packageVersion.d.ts +1 -1
  112. package/lib/packageVersion.d.ts.map +1 -1
  113. package/lib/packageVersion.js +1 -1
  114. package/lib/packageVersion.js.map +1 -1
  115. package/lib/shared-tree/checkoutFlexTreeView.d.ts +7 -3
  116. package/lib/shared-tree/checkoutFlexTreeView.d.ts.map +1 -1
  117. package/lib/shared-tree/checkoutFlexTreeView.js +12 -3
  118. package/lib/shared-tree/checkoutFlexTreeView.js.map +1 -1
  119. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  120. package/lib/shared-tree/schematizeTree.js +1 -1
  121. package/lib/shared-tree/schematizeTree.js.map +1 -1
  122. package/lib/shared-tree/schematizingTreeView.d.ts +3 -0
  123. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  124. package/lib/shared-tree/schematizingTreeView.js +14 -8
  125. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  126. package/lib/shared-tree/treeAlpha.d.ts +1 -4
  127. package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
  128. package/lib/shared-tree/treeAlpha.js +7 -2
  129. package/lib/shared-tree/treeAlpha.js.map +1 -1
  130. package/lib/simple-tree/api/create.d.ts +5 -1
  131. package/lib/simple-tree/api/create.d.ts.map +1 -1
  132. package/lib/simple-tree/api/create.js +8 -10
  133. package/lib/simple-tree/api/create.js.map +1 -1
  134. package/lib/simple-tree/api/index.d.ts +2 -2
  135. package/lib/simple-tree/api/index.d.ts.map +1 -1
  136. package/lib/simple-tree/api/index.js +2 -2
  137. package/lib/simple-tree/api/index.js.map +1 -1
  138. package/lib/simple-tree/api/storedSchema.d.ts +1 -8
  139. package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
  140. package/lib/simple-tree/api/storedSchema.js +2 -12
  141. package/lib/simple-tree/api/storedSchema.js.map +1 -1
  142. package/lib/simple-tree/arrayNode.d.ts.map +1 -1
  143. package/lib/simple-tree/arrayNode.js +4 -10
  144. package/lib/simple-tree/arrayNode.js.map +1 -1
  145. package/lib/simple-tree/core/unhydratedFlexTree.d.ts +4 -4
  146. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  147. package/lib/simple-tree/core/unhydratedFlexTree.js +9 -5
  148. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  149. package/lib/simple-tree/index.d.ts +3 -2
  150. package/lib/simple-tree/index.d.ts.map +1 -1
  151. package/lib/simple-tree/index.js +3 -2
  152. package/lib/simple-tree/index.js.map +1 -1
  153. package/lib/simple-tree/mapNode.d.ts.map +1 -1
  154. package/lib/simple-tree/mapNode.js +3 -6
  155. package/lib/simple-tree/mapNode.js.map +1 -1
  156. package/lib/simple-tree/objectNode.d.ts.map +1 -1
  157. package/lib/simple-tree/objectNode.js +4 -6
  158. package/lib/simple-tree/objectNode.js.map +1 -1
  159. package/lib/simple-tree/prepareForInsertion.d.ts +30 -0
  160. package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -0
  161. package/lib/simple-tree/prepareForInsertion.js +131 -0
  162. package/lib/simple-tree/prepareForInsertion.js.map +1 -0
  163. package/lib/simple-tree/proxies.d.ts +1 -12
  164. package/lib/simple-tree/proxies.d.ts.map +1 -1
  165. package/lib/simple-tree/proxies.js +1 -96
  166. package/lib/simple-tree/proxies.js.map +1 -1
  167. package/lib/simple-tree/toMapTree.d.ts +1 -1
  168. package/lib/simple-tree/toMapTree.js +1 -1
  169. package/lib/simple-tree/toMapTree.js.map +1 -1
  170. package/lib/tableSchema.d.ts +108 -59
  171. package/lib/tableSchema.d.ts.map +1 -1
  172. package/lib/tableSchema.js +94 -45
  173. package/lib/tableSchema.js.map +1 -1
  174. package/lib/tsdoc-metadata.json +1 -1
  175. package/package.json +25 -25
  176. package/src/feature-libraries/default-schema/schemaChecker.ts +0 -8
  177. package/src/feature-libraries/flex-tree/context.ts +18 -20
  178. package/src/feature-libraries/flex-tree/index.ts +0 -1
  179. package/src/feature-libraries/flex-tree/lazyField.ts +2 -14
  180. package/src/feature-libraries/flex-tree/utilities.ts +8 -8
  181. package/src/feature-libraries/index.ts +0 -1
  182. package/src/packageVersion.ts +1 -1
  183. package/src/shared-tree/checkoutFlexTreeView.ts +10 -6
  184. package/src/shared-tree/schematizeTree.ts +1 -1
  185. package/src/shared-tree/schematizingTreeView.ts +14 -14
  186. package/src/shared-tree/treeAlpha.ts +21 -5
  187. package/src/simple-tree/api/create.ts +15 -15
  188. package/src/simple-tree/api/index.ts +6 -2
  189. package/src/simple-tree/api/storedSchema.ts +2 -19
  190. package/src/simple-tree/arrayNode.ts +9 -20
  191. package/src/simple-tree/core/unhydratedFlexTree.ts +10 -5
  192. package/src/simple-tree/index.ts +6 -5
  193. package/src/simple-tree/mapNode.ts +8 -12
  194. package/src/simple-tree/objectNode.ts +3 -12
  195. package/src/simple-tree/prepareForInsertion.ts +236 -0
  196. package/src/simple-tree/proxies.ts +2 -147
  197. package/src/simple-tree/toMapTree.ts +1 -1
  198. package/src/tableSchema.ts +310 -158
@@ -27,6 +27,7 @@ import {
27
27
  SchemaFactory,
28
28
  type ImplicitAnnotatedFieldSchema,
29
29
  type UnannotateImplicitFieldSchema,
30
+ isArrayNodeSchema,
30
31
  } from "./simple-tree/index.js";
31
32
 
32
33
  // Future improvement TODOs:
@@ -42,6 +43,54 @@ import {
42
43
  */
43
44
  const tableSchemaFactorySubScope = "table";
44
45
 
46
+ /**
47
+ * Gets the table containing the provided row/column node, if the node is part of a table.
48
+ * @remarks Assumes that the table is the grandparent of the row/column node.
49
+ */
50
+ function getParentTable(
51
+ rowOrColumnNode: TreeNode,
52
+ ):
53
+ | (TreeNode &
54
+ TableSchema.Table<
55
+ string | undefined,
56
+ ImplicitAllowedTypes,
57
+ System_TableSchema.ColumnSchemaBase,
58
+ System_TableSchema.RowSchemaBase
59
+ >)
60
+ | undefined {
61
+ const rowListNode = Tree.parent(rowOrColumnNode);
62
+ if (rowListNode === undefined || !isArrayNodeSchema(Tree.schema(rowListNode))) {
63
+ return undefined;
64
+ }
65
+ const tableNode = Tree.parent(rowListNode);
66
+ if (tableNode === undefined || !isTableNode(tableNode)) {
67
+ return undefined;
68
+ }
69
+
70
+ return tableNode;
71
+ }
72
+
73
+ /**
74
+ * A private symbol put on table schema to help identify them.
75
+ */
76
+ const tableSchemaSymbol: unique symbol = Symbol("tableNode");
77
+
78
+ /**
79
+ * Type-guard to determine if a node is a table node.
80
+ * @remarks Uses {@link tableSchemaSymbol} to identify table nodes.
81
+ */
82
+ function isTableNode(
83
+ node: TreeNode,
84
+ ): node is TreeNode &
85
+ TableSchema.Table<
86
+ string | undefined,
87
+ ImplicitAllowedTypes,
88
+ System_TableSchema.ColumnSchemaBase,
89
+ System_TableSchema.RowSchemaBase
90
+ > {
91
+ return tableSchemaSymbol in Tree.schema(node);
92
+ }
93
+
45
94
  /**
46
95
  * Not intended for use outside of this package.
47
96
  *
@@ -99,20 +148,28 @@ export namespace System_TableSchema {
99
148
  */
100
149
  export type CreateColumnOptionsBase<
101
150
  TSchemaFactory extends SchemaFactoryAlpha = SchemaFactoryAlpha,
102
- > = OptionsWithSchemaFactory<TSchemaFactory>;
151
+ TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
152
+ > = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
103
153
 
104
154
  /**
105
- * Factory for creating new table column schema.
155
+ * Factory for creating column schema.
106
156
  * @system @internal
107
157
  */
108
158
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
109
- export function createColumnInternal<
159
+ export function createColumnSchema<
110
160
  const TInputScope extends string | undefined,
161
+ const TCellSchema extends ImplicitAllowedTypes,
111
162
  const TPropsSchema extends ImplicitAnnotatedFieldSchema,
112
- >(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {
163
+ >(
164
+ inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
165
+ cellSchema: TCellSchema,
166
+ propsSchema: TPropsSchema,
167
+ ) {
113
168
  const schemaFactory = inputSchemaFactory.scopedFactory(tableSchemaFactorySubScope);
114
169
  type Scope = ScopedSchemaName<TInputScope, typeof tableSchemaFactorySubScope>;
115
170
 
171
+ type CellValueType = TreeNodeFromImplicitAllowedTypes<TCellSchema>;
172
+
116
173
  // Note: `columnFields` is broken into two parts to work around a TypeScript bug
117
174
  // that results in broken `.d.ts` output.
118
175
  // See definition of `ColumnInsertableType` below.
@@ -147,10 +204,36 @@ export namespace System_TableSchema {
147
204
  // Will make it easier to evolve this schema in the future.
148
205
  allowUnknownOptionalFields: true,
149
206
  })
150
- implements TableSchema.Column<TPropsSchema> {}
207
+ implements TableSchema.Column<TCellSchema, TPropsSchema>
208
+ {
209
+ public getCells(): {
210
+ rowId: string;
211
+ cell: CellValueType;
212
+ }[] {
213
+ const tableNode = getParentTable(this);
214
+ if (tableNode === undefined) {
215
+ throw new UsageError(`Column with ID "${this.id}" is not contained in a table.`);
216
+ }
217
+
218
+ const result = [];
219
+ for (const row of tableNode.rows) {
220
+ const cell = row.getCell(this.id);
221
+ if (cell !== undefined) {
222
+ if (!Tree.is(cell, cellSchema)) {
223
+ throw new UsageError(
224
+ "Parent table contains a cell with incompatible with this column.",
225
+ );
226
+ }
227
+
228
+ result.push({ rowId: row.id, cell: cell as CellValueType });
229
+ }
230
+ }
231
+ return result;
232
+ }
233
+ }
151
234
 
152
235
  type ColumnValueType = TreeNode &
153
- TableSchema.Column<TPropsSchema> &
236
+ TableSchema.Column<TCellSchema, TPropsSchema> &
154
237
  WithType<ScopedSchemaName<Scope, "Column">>;
155
238
 
156
239
  // Note: ideally this type would just leverage `InsertableObjectFromSchemaRecord<typeof columnFields>`,
@@ -226,8 +309,9 @@ export namespace System_TableSchema {
226
309
  */
227
310
  export type ColumnSchemaBase<
228
311
  TScope extends string | undefined = string | undefined,
312
+ TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
229
313
  TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
230
- > = ReturnType<typeof createColumnInternal<TScope, TPropsSchema>>;
314
+ > = ReturnType<typeof createColumnSchema<TScope, TCellSchema, TPropsSchema>>;
231
315
 
232
316
  // #endregion
233
317
 
@@ -244,12 +328,11 @@ export namespace System_TableSchema {
244
328
  > = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
245
329
 
246
330
  /**
247
- * Factory for creating new table row schema.
248
- *
331
+ * Factory for creating row schema.
249
332
  * @sealed @internal
250
333
  */
251
334
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
252
- export function createRowInternal<
335
+ export function createRowSchema<
253
336
  const TInputScope extends string | undefined,
254
337
  const TCellSchema extends ImplicitAllowedTypes,
255
338
  const TPropsSchema extends ImplicitAnnotatedFieldSchema,
@@ -302,13 +385,15 @@ export namespace System_TableSchema {
302
385
  })
303
386
  implements TableSchema.Row<TCellSchema, TPropsSchema>
304
387
  {
305
- public getCell(columnOrId: TableSchema.Column | string): CellValueType | undefined {
388
+ public getCell(
389
+ columnOrId: TableSchema.Column<TCellSchema> | string,
390
+ ): CellValueType | undefined {
306
391
  const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
307
392
  return this.cells.get(columnId) as CellValueType | undefined;
308
393
  }
309
394
 
310
395
  public setCell(
311
- columnOrId: TableSchema.Column | string,
396
+ columnOrId: TableSchema.Column<TCellSchema> | string,
312
397
  value: CellInsertableType | undefined,
313
398
  ): void {
314
399
  // TODO: throw if column does not exist in the owning table.
@@ -317,7 +402,9 @@ export namespace System_TableSchema {
317
402
  this.cells.set(columnId, value);
318
403
  }
319
404
 
320
- public removeCell(columnOrId: TableSchema.Column | string): CellValueType | undefined {
405
+ public removeCell(
406
+ columnOrId: TableSchema.Column<TCellSchema> | string,
407
+ ): CellValueType | undefined {
321
408
  // TODO: throw if column does not exist in the owning table.
322
409
 
323
410
  const columnId = typeof columnOrId === "string" ? columnOrId : columnOrId.id;
@@ -330,6 +417,22 @@ export namespace System_TableSchema {
330
417
  this.cells.delete(columnId);
331
418
  return cell;
332
419
  }
420
+
421
+ public getCells(): {
422
+ columnId: string;
423
+ cell: CellValueType;
424
+ }[] {
425
+ const result = [];
426
+ for (const [columnId, cell] of this.cells.entries()) {
427
+ if (cell !== undefined) {
428
+ result.push({
429
+ columnId,
430
+ cell,
431
+ });
432
+ }
433
+ }
434
+ return result;
435
+ }
333
436
  }
334
437
 
335
438
  type RowValueType = TreeNode &
@@ -412,7 +515,7 @@ export namespace System_TableSchema {
412
515
  TScope extends string | undefined = string | undefined,
413
516
  TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
414
517
  TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
415
- > = ReturnType<typeof createRowInternal<TScope, TCellSchema, TPropsSchema>>;
518
+ > = ReturnType<typeof createRowSchema<TScope, TCellSchema, TPropsSchema>>;
416
519
 
417
520
  // #endregion
418
521
 
@@ -429,14 +532,14 @@ export namespace System_TableSchema {
429
532
  > = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
430
533
 
431
534
  /**
432
- * Factory for creating new table schema.
535
+ * Factory for creating table schema.
433
536
  * @system @internal
434
537
  */
435
538
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
436
- export function createTableInternal<
539
+ export function createTableSchema<
437
540
  const TInputScope extends string | undefined,
438
541
  const TCellSchema extends ImplicitAllowedTypes,
439
- const TColumnSchema extends ColumnSchemaBase<TInputScope>,
542
+ const TColumnSchema extends ColumnSchemaBase<TInputScope, TCellSchema>,
440
543
  const TRowSchema extends RowSchemaBase<TInputScope, TCellSchema>,
441
544
  >(
442
545
  inputSchemaFactory: SchemaFactoryAlpha<TInputScope>,
@@ -469,8 +572,14 @@ export namespace System_TableSchema {
469
572
  // Will make it easier to evolve this schema in the future.
470
573
  allowUnknownOptionalFields: true,
471
574
  })
472
- implements TableSchema.Table<TCellSchema, TColumnSchema, TRowSchema>
575
+ implements TableSchema.Table<TInputScope, TCellSchema, TColumnSchema, TRowSchema>
473
576
  {
577
+ public static empty<TThis extends TableConstructorType>(
578
+ this: TThis,
579
+ ): InstanceType<TThis> {
580
+ return new this({ columns: [], rows: [] }) as InstanceType<TThis>;
581
+ }
582
+
474
583
  public getColumn(id: string): ColumnValueType | undefined {
475
584
  // TypeScript is unable to narrow the types correctly here, hence the casts.
476
585
  // See: https://github.com/microsoft/TypeScript/issues/52144
@@ -519,27 +628,11 @@ export namespace System_TableSchema {
519
628
  columns,
520
629
  index,
521
630
  }: TableSchema.InsertColumnsParameters<TColumnSchema>): ColumnValueType[] {
522
- // #region Input validation
523
-
524
631
  // Ensure index is valid
525
632
  if (index !== undefined) {
526
633
  Table.validateInsertionIndex(index, this.columns);
527
634
  }
528
635
 
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.
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
636
  // TypeScript is unable to narrow the column type correctly here, hence the casts below.
544
637
  // See: https://github.com/microsoft/TypeScript/issues/52144
545
638
  if (index === undefined) {
@@ -579,14 +672,6 @@ export namespace System_TableSchema {
579
672
  // Note: TypeScript is unable to narrow the type of the row type correctly here, hence the casts below.
580
673
  // See: https://github.com/microsoft/TypeScript/issues/52144
581
674
  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
675
  // If the row contains cells, verify that the table contains the columns for those cells.
591
676
  // 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
677
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -782,15 +867,19 @@ export namespace System_TableSchema {
782
867
  // TypeScript is unable to narrow the types correctly here, hence the cast.
783
868
  // See: https://github.com/microsoft/TypeScript/issues/52144
784
869
  return (
785
- this.columns.find((column) => (column as TableSchema.Column).id === columnId) !==
786
- undefined
870
+ this.columns.find(
871
+ (column) => (column as TableSchema.Column<TCellSchema>).id === columnId,
872
+ ) !== undefined
787
873
  );
788
874
  }
789
875
 
790
876
  private containsRowWithId(rowId: string): boolean {
791
877
  // TypeScript is unable to narrow the types correctly here, hence the cast.
792
878
  // See: https://github.com/microsoft/TypeScript/issues/52144
793
- return this.rows.find((row) => (row as TableSchema.Row).id === rowId) !== undefined;
879
+ return (
880
+ this.rows.find((row) => (row as TableSchema.Row<TCellSchema>).id === rowId) !==
881
+ undefined
882
+ );
794
883
  }
795
884
 
796
885
  /**
@@ -815,10 +904,18 @@ export namespace System_TableSchema {
815
904
  }
816
905
  }
817
906
 
907
+ // Set a private symbol on the schema class that marks it as having been generated by this factory.
908
+ // Column / Row functionality use this to validate that they are being used in a table.
909
+ // This is effectively a work-around that allows columns and rows to invoke table methods
910
+ // without having to pass the table as a parameter to their construction, which isn't possible.
911
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
912
+ (Table as any)[tableSchemaSymbol] = true;
913
+
818
914
  type TableValueType = TreeNode &
819
- TableSchema.Table<TCellSchema, TColumnSchema, TRowSchema> &
915
+ TableSchema.Table<TInputScope, TCellSchema, TColumnSchema, TRowSchema> &
820
916
  WithType<ScopedSchemaName<Scope, "Table">>;
821
917
  type TableInsertableType = InsertableObjectFromSchemaRecord<typeof tableFields>;
918
+ type TableConstructorType = new (data: TableInsertableType) => TableValueType;
822
919
 
823
920
  // Returning SingletonSchema without a type conversion results in TypeScript generating something like `readonly "__#124291@#brand": unknown;`
824
921
  // for the private brand field of TreeNode.
@@ -832,7 +929,12 @@ export namespace System_TableSchema {
832
929
  /* TInsertable */ object & TableInsertableType,
833
930
  /* ImplicitlyConstructable */ true,
834
931
  /* Info */ typeof tableFields
835
- > = Table;
932
+ > & {
933
+ /**
934
+ * Create an empty table.
935
+ */
936
+ empty<TThis extends TableConstructorType>(this: TThis): InstanceType<TThis>;
937
+ } = Table;
836
938
 
837
939
  // Return the table schema
838
940
  return TableSchemaType;
@@ -845,9 +947,9 @@ export namespace System_TableSchema {
845
947
  export type TableSchemaBase<
846
948
  TScope extends string | undefined,
847
949
  TCell extends ImplicitAllowedTypes,
848
- TColumn extends ColumnSchemaBase<TScope>,
950
+ TColumn extends ColumnSchemaBase<TScope, TCell>,
849
951
  TRow extends RowSchemaBase<TScope, TCell>,
850
- > = ReturnType<typeof createTableInternal<TScope, TCell, TColumn, TRow>>;
952
+ > = ReturnType<typeof createTableSchema<TScope, TCell, TColumn, TRow>>;
851
953
 
852
954
  // #endregion
853
955
  }
@@ -883,7 +985,7 @@ export namespace System_TableSchema {
883
985
  * value: schemaFactory.string,
884
986
  * }) {}
885
987
  *
886
- * class Table extends TableSchema.createTable({
988
+ * class Table extends TableSchema.table({
887
989
  * schemaFactory,
888
990
  * cell: Cell,
889
991
  * }) {}
@@ -908,17 +1010,18 @@ export namespace System_TableSchema {
908
1010
  * dataType: schemaFactory.optional(schemaFactory.string),
909
1011
  * }) {}
910
1012
  *
911
- * class Column extends TableSchema.createColumn({
1013
+ * class Column extends TableSchema.column({
912
1014
  * schemaFactory,
1015
+ * cell: Cell,
913
1016
  * props: ColumnProps,
914
1017
  * }) {}
915
1018
  *
916
- * class Row extends TableSchema.createRow({
1019
+ * class Row extends TableSchema.row({
917
1020
  * schemaFactory,
918
1021
  * cell: Cell,
919
1022
  * }) {}
920
1023
  *
921
- * class Table extends TableSchema.createTable({
1024
+ * class Table extends TableSchema.table({
922
1025
  * schemaFactory,
923
1026
  * cell: Cell,
924
1027
  * column: Column,
@@ -946,10 +1049,13 @@ export namespace TableSchema {
946
1049
 
947
1050
  /**
948
1051
  * A column in a table.
949
- * @remarks Implemented by the schema class returned from {@link TableSchema.(createColumn:2)}.
1052
+ * @remarks Implemented by the schema class returned from {@link TableSchema.(column:2)}.
1053
+ * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
1054
+ * @typeParam TProps - Additional properties to associate with the column.
950
1055
  * @sealed @internal
951
1056
  */
952
1057
  export interface Column<
1058
+ TCell extends ImplicitAllowedTypes,
953
1059
  TProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
954
1060
  > {
955
1061
  /**
@@ -962,50 +1068,66 @@ export namespace TableSchema {
962
1068
  * The column's properties.
963
1069
  * @remarks This is a user-defined schema that can be used to store additional information about the column.
964
1070
  * @privateRemarks
965
- * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.
1071
+ * Note: these docs are duplicated on the inline type definitions in {@link System_TableSchema.createColumnSchema}.
966
1072
  * If you update the docs here, please also update the inline type definitions.
967
1073
  */
968
1074
  get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
969
1075
  set props(value: InsertableTreeFieldFromImplicitField<
970
1076
  UnannotateImplicitFieldSchema<TProps>
971
1077
  >);
1078
+
1079
+ /**
1080
+ * Gets all of the populated cells in the column, keyed by their associated row IDs.
1081
+ * @throws Throws an error if the column is not in a table.
1082
+ */
1083
+ getCells(): readonly {
1084
+ rowId: string;
1085
+ cell: TreeNodeFromImplicitAllowedTypes<TCell>;
1086
+ }[];
972
1087
  }
973
1088
 
974
1089
  /**
975
1090
  * Factory for creating new table column schema.
1091
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1092
+ * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
976
1093
  * @internal
977
1094
  */
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>;
1095
+ export function column<
1096
+ const TScope extends string | undefined,
1097
+ const TCell extends ImplicitAllowedTypes,
1098
+ >(
1099
+ params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryAlpha<TScope>, TCell>,
1100
+ ): System_TableSchema.ColumnSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
983
1101
  /**
984
1102
  * Factory for creating new table column schema.
1103
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1104
+ * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
1105
+ * @typeParam TProps - Additional properties to associate with the column.
985
1106
  * @internal
986
1107
  */
987
- export function createColumn<
1108
+ export function column<
988
1109
  const TScope extends string | undefined,
1110
+ const TCell extends ImplicitAllowedTypes,
989
1111
  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>;
1112
+ >(
1113
+ params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1114
+ /**
1115
+ * Optional column properties.
1116
+ */
1117
+ readonly props: TProps;
1118
+ },
1119
+ ): System_TableSchema.ColumnSchemaBase<TScope, TCell, TProps>;
999
1120
  /**
1000
1121
  * Overload implementation
1001
1122
  */
1002
- export function createColumn({
1123
+ export function column({
1003
1124
  schemaFactory,
1125
+ cell,
1004
1126
  props = SchemaFactory.optional(SchemaFactory.null),
1005
1127
  }: System_TableSchema.CreateColumnOptionsBase & {
1006
1128
  readonly props?: ImplicitAnnotatedFieldSchema;
1007
1129
  }): TreeNodeSchema {
1008
- return System_TableSchema.createColumnInternal(schemaFactory, props);
1130
+ return System_TableSchema.createColumnSchema(schemaFactory, cell, props);
1009
1131
  }
1010
1132
 
1011
1133
  // #endregion
@@ -1014,11 +1136,13 @@ export namespace TableSchema {
1014
1136
 
1015
1137
  /**
1016
1138
  * A row in a table.
1017
- * @remarks Implemented by the schema class returned from {@link TableSchema.(createRow:2)}.
1139
+ * @remarks Implemented by the schema class returned from {@link TableSchema.(row:2)}.
1140
+ * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
1141
+ * @typeParam TProps - Additional properties to associate with the row.
1018
1142
  * @sealed @internal
1019
1143
  */
1020
1144
  export interface Row<
1021
- TCell extends ImplicitAllowedTypes = ImplicitAllowedTypes,
1145
+ TCell extends ImplicitAllowedTypes,
1022
1146
  TProps extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
1023
1147
  > {
1024
1148
  /**
@@ -1032,19 +1156,30 @@ export namespace TableSchema {
1032
1156
  * @returns The cell if it exists, otherwise undefined.
1033
1157
  * @privateRemarks TODO: throw if the column does not belong to the same table as the row.
1034
1158
  */
1035
- getCell(column: Column): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1159
+ getCell(column: Column<TCell>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1036
1160
  /**
1037
1161
  * Gets the cell in the specified column, denoted by column ID.
1038
1162
  * @returns The cell if it exists, otherwise undefined.
1039
1163
  */
1040
1164
  getCell(columnId: string): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1041
1165
 
1166
+ /**
1167
+ * Gets all of the populated cells in the row, keyed by their associated column IDs.
1168
+ */
1169
+ getCells(): readonly {
1170
+ columnId: string;
1171
+ cell: TreeNodeFromImplicitAllowedTypes<TCell>;
1172
+ }[];
1173
+
1042
1174
  /**
1043
1175
  * Sets the cell in the specified column.
1044
1176
  * @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:1)} instead.
1045
1177
  * @privateRemarks TODO: Throw an error if the column does not exist in the table.
1046
1178
  */
1047
- setCell(column: Column, value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>): void;
1179
+ setCell(
1180
+ column: Column<TCell>,
1181
+ value: InsertableTreeNodeFromImplicitAllowedTypes<TCell>,
1182
+ ): void;
1048
1183
  /**
1049
1184
  * Sets the cell in the specified column, denoted by column ID.
1050
1185
  * @remarks To remove a cell, call {@link TableSchema.Row.(removeCell:2)} instead.
@@ -1056,7 +1191,7 @@ export namespace TableSchema {
1056
1191
  * @returns The cell if it exists, otherwise undefined.
1057
1192
  * @privateRemarks TODO: Throw if the column does not belong to the same table as the row.
1058
1193
  */
1059
- removeCell(column: Column): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1194
+ removeCell(column: Column<TCell>): TreeNodeFromImplicitAllowedTypes<TCell> | undefined;
1060
1195
  /**
1061
1196
  * Removes the cell in the specified column, denoted by column ID.
1062
1197
  * @returns The cell if it exists, otherwise undefined.
@@ -1067,7 +1202,7 @@ export namespace TableSchema {
1067
1202
  * The row's properties.
1068
1203
  * @remarks This is a user-defined schema that can be used to store additional information about the row.
1069
1204
  * @privateRemarks
1070
- * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.
1205
+ * Note: these docs are duplicated on the inline type definitions in {@link System_TableSchema.createRowSchema}.
1071
1206
  * If you update the docs here, please also update the inline type definitions.
1072
1207
  */
1073
1208
  get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
@@ -1078,47 +1213,46 @@ export namespace TableSchema {
1078
1213
 
1079
1214
  /**
1080
1215
  * Factory for creating new table column schema.
1216
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1217
+ * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
1081
1218
  * @internal
1082
1219
  */
1083
- export function createRow<
1220
+ export function row<
1084
1221
  const TScope extends string | undefined,
1085
1222
  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>;
1223
+ >(
1224
+ params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryAlpha<TScope>, TCell>,
1225
+ ): System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
1093
1226
  /**
1094
- * Factory for creating new table column schema.
1227
+ * Factory for creating new table row schema.
1228
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1229
+ * @typeParam TCell - The type of the cells in the {@link TableSchema.Table}.
1230
+ * @typeParam TProps - Additional properties to associate with the row.
1095
1231
  * @internal
1096
1232
  */
1097
- export function createRow<
1233
+ export function row<
1098
1234
  const TScope extends string | undefined,
1099
1235
  const TCell extends ImplicitAllowedTypes,
1100
1236
  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>;
1237
+ >(
1238
+ params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1239
+ /**
1240
+ * Optional row properties.
1241
+ */
1242
+ readonly props: TProps;
1243
+ },
1244
+ ): System_TableSchema.RowSchemaBase<TScope, TCell, TProps>;
1111
1245
  /**
1112
1246
  * Overload implementation
1113
1247
  */
1114
- export function createRow({
1248
+ export function row({
1115
1249
  schemaFactory,
1116
1250
  cell,
1117
1251
  props = SchemaFactory.optional(SchemaFactory.null),
1118
1252
  }: System_TableSchema.CreateRowOptionsBase & {
1119
1253
  readonly props?: ImplicitAnnotatedFieldSchema;
1120
1254
  }): TreeNodeSchema {
1121
- return System_TableSchema.createRowInternal(schemaFactory, cell, props);
1255
+ return System_TableSchema.createRowSchema(schemaFactory, cell, props);
1122
1256
  }
1123
1257
 
1124
1258
  // #endregion
@@ -1234,12 +1368,17 @@ export namespace TableSchema {
1234
1368
 
1235
1369
  /**
1236
1370
  * A table.
1371
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1372
+ * @typeParam TCell - The type of the cells in the table.
1373
+ * @typeParam TColumn - The type of the columns in the table.
1374
+ * @typeParam TRow - The type of the rows in the table.
1237
1375
  * @sealed @internal
1238
1376
  */
1239
1377
  export interface Table<
1378
+ TScope extends string | undefined,
1240
1379
  TCell extends ImplicitAllowedTypes,
1241
- TColumn extends ImplicitAllowedTypes,
1242
- TRow extends ImplicitAllowedTypes,
1380
+ TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>,
1381
+ TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>,
1243
1382
  > {
1244
1383
  /**
1245
1384
  * The table's columns.
@@ -1270,14 +1409,9 @@ export namespace TableSchema {
1270
1409
  /**
1271
1410
  * Inserts a column into the table.
1272
1411
  *
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.
1412
+ * @throws Throws an error if the specified index is out of range.
1277
1413
  *
1278
- * - The specified index is out of range.
1279
- *
1280
- * No column is inserted in these cases.
1414
+ * No column is inserted in this case.
1281
1415
  */
1282
1416
  insertColumn(
1283
1417
  params: InsertColumnParameters<TColumn>,
@@ -1286,14 +1420,9 @@ export namespace TableSchema {
1286
1420
  /**
1287
1421
  * Inserts 0 or more columns into the table.
1288
1422
  *
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.
1423
+ * @throws Throws an error if the specified index is out of range.
1295
1424
  *
1296
- * No columns are inserted in these cases.
1425
+ * No columns are inserted in this case.
1297
1426
  */
1298
1427
  insertColumns(
1299
1428
  params: InsertColumnsParameters<TColumn>,
@@ -1305,8 +1434,6 @@ export namespace TableSchema {
1305
1434
  * @throws
1306
1435
  * Throws an error in the following cases:
1307
1436
  *
1308
- * - The row, or a row with the same ID is already in the tree.
1309
- *
1310
1437
  * - The row contains cells, but the table does not contain matching columns for one or more of those cells.
1311
1438
  *
1312
1439
  * - The specified index is out of range.
@@ -1321,8 +1448,6 @@ export namespace TableSchema {
1321
1448
  * @throws
1322
1449
  * Throws an error in the following cases:
1323
1450
  *
1324
- * - At least one row, or a row with the same ID is already in the tree.
1325
- *
1326
1451
  * - The row contains cells, but the table does not contain matching columns for one or more of those cells.
1327
1452
  *
1328
1453
  * - The specified index is out of range.
@@ -1428,80 +1553,107 @@ export namespace TableSchema {
1428
1553
  }
1429
1554
 
1430
1555
  /**
1431
- * Factory for creating new table schema without specifying row or column schema.
1556
+ * Factory for creating new table schema.
1557
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1558
+ * @typeParam TCell - The type of the cells in the table.
1432
1559
  * @internal
1433
1560
  */
1434
- export function createTable<
1561
+ export function table<
1435
1562
  const TScope extends string | undefined,
1436
1563
  const TCell extends ImplicitAllowedTypes,
1437
- >({
1438
- schemaFactory,
1439
- cell,
1440
- }: System_TableSchema.TableFactoryOptionsBase<
1441
- SchemaFactoryAlpha<TScope>,
1442
- TCell
1443
- >): System_TableSchema.TableSchemaBase<
1564
+ >(
1565
+ params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell>,
1566
+ ): System_TableSchema.TableSchemaBase<
1444
1567
  TScope,
1445
1568
  TCell,
1446
- System_TableSchema.ColumnSchemaBase<TScope, System_TableSchema.DefaultPropsType>,
1569
+ System_TableSchema.ColumnSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>,
1447
1570
  System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>
1448
1571
  >;
1449
1572
  /**
1450
- * Factory for creating new table schema without specifying row schema.
1573
+ * Factory for creating new table schema with custom column schema.
1574
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1575
+ * @typeParam TCell - The type of the cells in the table.
1576
+ * @typeParam TColumn - The type of the columns in the table.
1451
1577
  * @internal
1452
1578
  */
1453
- export function createTable<
1579
+ export function table<
1454
1580
  const TScope extends string | undefined,
1455
1581
  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<
1582
+ const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>,
1583
+ >(
1584
+ params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1585
+ readonly column: TColumn;
1586
+ },
1587
+ ): System_TableSchema.TableSchemaBase<
1464
1588
  TScope,
1465
1589
  TCell,
1466
1590
  TColumn,
1467
1591
  System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>
1468
1592
  >;
1469
1593
  /**
1470
- * Factory for creating new table schema.
1594
+ * Factory for creating new table schema with custom row schema.
1595
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1596
+ * @typeParam TCell - The type of the cells in the table.
1597
+ * @typeParam TRow - The type of the rows in the table.
1471
1598
  * @internal
1472
1599
  */
1473
- export function createTable<
1600
+ export function table<
1474
1601
  const TScope extends string | undefined,
1475
1602
  const TCell extends ImplicitAllowedTypes,
1476
- const TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,
1477
1603
  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>;
1604
+ >(
1605
+ params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1606
+ readonly row: TRow;
1607
+ },
1608
+ ): System_TableSchema.TableSchemaBase<
1609
+ TScope,
1610
+ TCell,
1611
+ System_TableSchema.ColumnSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>,
1612
+ TRow
1613
+ >;
1614
+ /**
1615
+ * Factory for creating new table schema with custom column and row schema.
1616
+ * @typeParam TScope - The {@link SchemaFactory.scope | schema factory scope}.
1617
+ * @typeParam TCell - The type of the cells in the table.
1618
+ * @typeParam TColumn - The type of the columns in the table.
1619
+ * @typeParam TRow - The type of the rows in the table.
1620
+ * @internal
1621
+ */
1622
+ export function table<
1623
+ const TScope extends string | undefined,
1624
+ const TCell extends ImplicitAllowedTypes,
1625
+ const TColumn extends System_TableSchema.ColumnSchemaBase<TScope, TCell>,
1626
+ const TRow extends System_TableSchema.RowSchemaBase<TScope, TCell>,
1627
+ >(
1628
+ params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1629
+ readonly column: TColumn;
1630
+ readonly row: TRow;
1631
+ },
1632
+ ): System_TableSchema.TableSchemaBase<TScope, TCell, TColumn, TRow>;
1487
1633
  /**
1488
1634
  * Overload implementation
1489
1635
  */
1490
- export function createTable({
1636
+ export function table({
1491
1637
  schemaFactory,
1492
- cell,
1493
- column = createColumn({
1638
+ cell: cellSchema,
1639
+ column: columnSchema = column({
1494
1640
  schemaFactory,
1641
+ cell: cellSchema,
1495
1642
  }),
1496
- row = createRow({
1643
+ row: rowSchema = row({
1497
1644
  schemaFactory,
1498
- cell,
1645
+ cell: cellSchema,
1499
1646
  }),
1500
1647
  }: System_TableSchema.TableFactoryOptionsBase & {
1501
1648
  readonly column?: System_TableSchema.ColumnSchemaBase;
1502
1649
  readonly row?: System_TableSchema.RowSchemaBase;
1503
1650
  }): TreeNodeSchema {
1504
- return System_TableSchema.createTableInternal(schemaFactory, cell, column, row);
1651
+ return System_TableSchema.createTableSchema(
1652
+ schemaFactory,
1653
+ cellSchema,
1654
+ columnSchema,
1655
+ rowSchema,
1656
+ );
1505
1657
  }
1506
1658
 
1507
1659
  // #endregion