@fluidframework/tree 2.40.0 → 2.41.0-337492

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 (47) hide show
  1. package/dist/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  2. package/dist/feature-libraries/default-schema/schemaChecker.js +0 -7
  3. package/dist/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  4. package/dist/packageVersion.d.ts +1 -1
  5. package/dist/packageVersion.d.ts.map +1 -1
  6. package/dist/packageVersion.js +1 -1
  7. package/dist/packageVersion.js.map +1 -1
  8. package/dist/shared-tree/schematizeTree.d.ts +1 -1
  9. package/dist/shared-tree/schematizeTree.js +1 -1
  10. package/dist/shared-tree/schematizeTree.js.map +1 -1
  11. package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
  12. package/dist/shared-tree/schematizingTreeView.js +3 -2
  13. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  14. package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  15. package/dist/simple-tree/core/unhydratedFlexTree.js +5 -1
  16. package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  17. package/dist/tableSchema.d.ts +24 -25
  18. package/dist/tableSchema.d.ts.map +1 -1
  19. package/dist/tableSchema.js +24 -25
  20. package/dist/tableSchema.js.map +1 -1
  21. package/lib/feature-libraries/default-schema/schemaChecker.d.ts.map +1 -1
  22. package/lib/feature-libraries/default-schema/schemaChecker.js +0 -7
  23. package/lib/feature-libraries/default-schema/schemaChecker.js.map +1 -1
  24. package/lib/packageVersion.d.ts +1 -1
  25. package/lib/packageVersion.d.ts.map +1 -1
  26. package/lib/packageVersion.js +1 -1
  27. package/lib/packageVersion.js.map +1 -1
  28. package/lib/shared-tree/schematizeTree.d.ts +1 -1
  29. package/lib/shared-tree/schematizeTree.js +1 -1
  30. package/lib/shared-tree/schematizeTree.js.map +1 -1
  31. package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
  32. package/lib/shared-tree/schematizingTreeView.js +3 -2
  33. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  34. package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
  35. package/lib/simple-tree/core/unhydratedFlexTree.js +5 -1
  36. package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
  37. package/lib/tableSchema.d.ts +24 -25
  38. package/lib/tableSchema.d.ts.map +1 -1
  39. package/lib/tableSchema.js +24 -25
  40. package/lib/tableSchema.js.map +1 -1
  41. package/package.json +20 -20
  42. package/src/feature-libraries/default-schema/schemaChecker.ts +0 -8
  43. package/src/packageVersion.ts +1 -1
  44. package/src/shared-tree/schematizeTree.ts +1 -1
  45. package/src/shared-tree/schematizingTreeView.ts +3 -2
  46. package/src/simple-tree/core/unhydratedFlexTree.ts +6 -1
  47. package/src/tableSchema.ts +74 -88
@@ -159,7 +159,7 @@ function normalizeNewFieldContent(
159
159
  * This function should only be called when the tree is uninitialized (no schema or content).
160
160
  * @remarks
161
161
  *
162
- * If the proposed schema (from `treeContent`) is not compatible with the emptry tree, this function handles using an intermediate schema
162
+ * If the proposed schema (from `treeContent`) is not compatible with the empty tree, this function handles using an intermediate schema
163
163
  * which supports the empty tree as well as the final tree content.
164
164
  */
165
165
  export function initialize(checkout: ITreeCheckout, treeContent: TreeStoredContent): void {
@@ -173,19 +173,20 @@ export class SchematizingSimpleTreeView<
173
173
  }
174
174
 
175
175
  this.runSchemaEdit(() => {
176
+ const schema = this.viewSchema.viewSchemaAsStored;
176
177
  const mapTree = mapTreeFromNodeData(
177
178
  content as InsertableContent | undefined,
178
179
  this.rootFieldSchema,
179
180
  this.nodeKeyManager,
180
181
  {
181
- schema: this.checkout.storedSchema,
182
+ schema,
182
183
  policy: this.schemaPolicy,
183
184
  },
184
185
  );
185
186
 
186
187
  prepareContentForHydration(mapTree, this.checkout.forest);
187
188
  initialize(this.checkout, {
188
- schema: this.viewSchema.viewSchemaAsStored,
189
+ schema,
189
190
  initialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),
190
191
  });
191
192
  });
@@ -597,7 +597,12 @@ function getOrCreateField(
597
597
  return new UnhydratedTreeSequenceField(parent.simpleContext, schema, key, parent, onEdit);
598
598
  }
599
599
 
600
- return new UnhydratedFlexTreeField(parent.simpleContext, schema, key, parent, onEdit);
600
+ // TODO: this seems to used by unknown optional fields. They should probably use "optional" not "Forbidden" schema.
601
+ if (schema === FieldKinds.forbidden.identifier) {
602
+ return new UnhydratedFlexTreeField(parent.simpleContext, schema, key, parent, onEdit);
603
+ }
604
+
605
+ return fail("unsupported field kind");
601
606
  }
602
607
 
603
608
  // #endregion Caching and unboxing utilities
@@ -102,11 +102,11 @@ export namespace System_TableSchema {
102
102
  > = OptionsWithSchemaFactory<TSchemaFactory>;
103
103
 
104
104
  /**
105
- * Factory for creating new table column schema.
105
+ * Factory for creating column schema.
106
106
  * @system @internal
107
107
  */
108
108
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
109
- export function createColumnInternal<
109
+ export function createColumnSchema<
110
110
  const TInputScope extends string | undefined,
111
111
  const TPropsSchema extends ImplicitAnnotatedFieldSchema,
112
112
  >(inputSchemaFactory: SchemaFactoryAlpha<TInputScope>, propsSchema: TPropsSchema) {
@@ -227,7 +227,7 @@ export namespace System_TableSchema {
227
227
  export type ColumnSchemaBase<
228
228
  TScope extends string | undefined = string | undefined,
229
229
  TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
230
- > = ReturnType<typeof createColumnInternal<TScope, TPropsSchema>>;
230
+ > = ReturnType<typeof createColumnSchema<TScope, TPropsSchema>>;
231
231
 
232
232
  // #endregion
233
233
 
@@ -244,12 +244,11 @@ export namespace System_TableSchema {
244
244
  > = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
245
245
 
246
246
  /**
247
- * Factory for creating new table row schema.
248
- *
247
+ * Factory for creating row schema.
249
248
  * @sealed @internal
250
249
  */
251
250
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
252
- export function createRowInternal<
251
+ export function createRowSchema<
253
252
  const TInputScope extends string | undefined,
254
253
  const TCellSchema extends ImplicitAllowedTypes,
255
254
  const TPropsSchema extends ImplicitAnnotatedFieldSchema,
@@ -412,7 +411,7 @@ export namespace System_TableSchema {
412
411
  TScope extends string | undefined = string | undefined,
413
412
  TCellSchema extends ImplicitAllowedTypes = ImplicitAllowedTypes,
414
413
  TPropsSchema extends ImplicitAnnotatedFieldSchema = ImplicitAnnotatedFieldSchema,
415
- > = ReturnType<typeof createRowInternal<TScope, TCellSchema, TPropsSchema>>;
414
+ > = ReturnType<typeof createRowSchema<TScope, TCellSchema, TPropsSchema>>;
416
415
 
417
416
  // #endregion
418
417
 
@@ -429,11 +428,11 @@ export namespace System_TableSchema {
429
428
  > = OptionsWithSchemaFactory<TSchemaFactory> & OptionsWithCellSchema<TCell>;
430
429
 
431
430
  /**
432
- * Factory for creating new table schema.
431
+ * Factory for creating table schema.
433
432
  * @system @internal
434
433
  */
435
434
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- Return type is too complex to be reasonable to specify
436
- export function createTableInternal<
435
+ export function createTableSchema<
437
436
  const TInputScope extends string | undefined,
438
437
  const TCellSchema extends ImplicitAllowedTypes,
439
438
  const TColumnSchema extends ColumnSchemaBase<TInputScope>,
@@ -847,7 +846,7 @@ export namespace System_TableSchema {
847
846
  TCell extends ImplicitAllowedTypes,
848
847
  TColumn extends ColumnSchemaBase<TScope>,
849
848
  TRow extends RowSchemaBase<TScope, TCell>,
850
- > = ReturnType<typeof createTableInternal<TScope, TCell, TColumn, TRow>>;
849
+ > = ReturnType<typeof createTableSchema<TScope, TCell, TColumn, TRow>>;
851
850
 
852
851
  // #endregion
853
852
  }
@@ -883,7 +882,7 @@ export namespace System_TableSchema {
883
882
  * value: schemaFactory.string,
884
883
  * }) {}
885
884
  *
886
- * class Table extends TableSchema.createTable({
885
+ * class Table extends TableSchema.table({
887
886
  * schemaFactory,
888
887
  * cell: Cell,
889
888
  * }) {}
@@ -908,17 +907,17 @@ export namespace System_TableSchema {
908
907
  * dataType: schemaFactory.optional(schemaFactory.string),
909
908
  * }) {}
910
909
  *
911
- * class Column extends TableSchema.createColumn({
910
+ * class Column extends TableSchema.column({
912
911
  * schemaFactory,
913
912
  * props: ColumnProps,
914
913
  * }) {}
915
914
  *
916
- * class Row extends TableSchema.createRow({
915
+ * class Row extends TableSchema.row({
917
916
  * schemaFactory,
918
917
  * cell: Cell,
919
918
  * }) {}
920
919
  *
921
- * class Table extends TableSchema.createTable({
920
+ * class Table extends TableSchema.table({
922
921
  * schemaFactory,
923
922
  * cell: Cell,
924
923
  * column: Column,
@@ -946,7 +945,7 @@ export namespace TableSchema {
946
945
 
947
946
  /**
948
947
  * A column in a table.
949
- * @remarks Implemented by the schema class returned from {@link TableSchema.(createColumn:2)}.
948
+ * @remarks Implemented by the schema class returned from {@link TableSchema.(column:2)}.
950
949
  * @sealed @internal
951
950
  */
952
951
  export interface Column<
@@ -962,7 +961,7 @@ export namespace TableSchema {
962
961
  * The column's properties.
963
962
  * @remarks This is a user-defined schema that can be used to store additional information about the column.
964
963
  * @privateRemarks
965
- * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.
964
+ * Note: these docs are duplicated on the inline type definitions in {@link System_TableSchema.createColumnSchema}.
966
965
  * If you update the docs here, please also update the inline type definitions.
967
966
  */
968
967
  get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
@@ -975,37 +974,34 @@ export namespace TableSchema {
975
974
  * Factory for creating new table column schema.
976
975
  * @internal
977
976
  */
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>;
977
+ export function column<const TScope extends string | undefined>(
978
+ params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryAlpha<TScope>>,
979
+ ): System_TableSchema.ColumnSchemaBase<TScope, System_TableSchema.DefaultPropsType>;
983
980
  /**
984
981
  * Factory for creating new table column schema.
985
982
  * @internal
986
983
  */
987
- export function createColumn<
984
+ export function column<
988
985
  const TScope extends string | undefined,
989
986
  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>;
987
+ >(
988
+ params: System_TableSchema.CreateColumnOptionsBase<SchemaFactoryAlpha<TScope>> & {
989
+ /**
990
+ * Optional column properties.
991
+ */
992
+ readonly props: TProps;
993
+ },
994
+ ): System_TableSchema.ColumnSchemaBase<TScope, TProps>;
999
995
  /**
1000
996
  * Overload implementation
1001
997
  */
1002
- export function createColumn({
998
+ export function column({
1003
999
  schemaFactory,
1004
1000
  props = SchemaFactory.optional(SchemaFactory.null),
1005
1001
  }: System_TableSchema.CreateColumnOptionsBase & {
1006
1002
  readonly props?: ImplicitAnnotatedFieldSchema;
1007
1003
  }): TreeNodeSchema {
1008
- return System_TableSchema.createColumnInternal(schemaFactory, props);
1004
+ return System_TableSchema.createColumnSchema(schemaFactory, props);
1009
1005
  }
1010
1006
 
1011
1007
  // #endregion
@@ -1067,7 +1063,7 @@ export namespace TableSchema {
1067
1063
  * The row's properties.
1068
1064
  * @remarks This is a user-defined schema that can be used to store additional information about the row.
1069
1065
  * @privateRemarks
1070
- * Note: these docs are duplicated on the inline type definitions in {@link createColumn}.
1066
+ * Note: these docs are duplicated on the inline type definitions in {@link System_TableSchema.createRowSchema}.
1071
1067
  * If you update the docs here, please also update the inline type definitions.
1072
1068
  */
1073
1069
  get props(): TreeFieldFromImplicitField<UnannotateImplicitFieldSchema<TProps>>;
@@ -1080,45 +1076,39 @@ export namespace TableSchema {
1080
1076
  * Factory for creating new table column schema.
1081
1077
  * @internal
1082
1078
  */
1083
- export function createRow<
1079
+ export function row<
1084
1080
  const TScope extends string | undefined,
1085
1081
  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>;
1082
+ >(
1083
+ params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryAlpha<TScope>, TCell>,
1084
+ ): System_TableSchema.RowSchemaBase<TScope, TCell, System_TableSchema.DefaultPropsType>;
1093
1085
  /**
1094
- * Factory for creating new table column schema.
1086
+ * Factory for creating new table row schema.
1095
1087
  * @internal
1096
1088
  */
1097
- export function createRow<
1089
+ export function row<
1098
1090
  const TScope extends string | undefined,
1099
1091
  const TCell extends ImplicitAllowedTypes,
1100
1092
  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>;
1093
+ >(
1094
+ params: System_TableSchema.CreateRowOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1095
+ /**
1096
+ * Optional row properties.
1097
+ */
1098
+ readonly props: TProps;
1099
+ },
1100
+ ): System_TableSchema.RowSchemaBase<TScope, TCell, TProps>;
1111
1101
  /**
1112
1102
  * Overload implementation
1113
1103
  */
1114
- export function createRow({
1104
+ export function row({
1115
1105
  schemaFactory,
1116
1106
  cell,
1117
1107
  props = SchemaFactory.optional(SchemaFactory.null),
1118
1108
  }: System_TableSchema.CreateRowOptionsBase & {
1119
1109
  readonly props?: ImplicitAnnotatedFieldSchema;
1120
1110
  }): TreeNodeSchema {
1121
- return System_TableSchema.createRowInternal(schemaFactory, cell, props);
1111
+ return System_TableSchema.createRowSchema(schemaFactory, cell, props);
1122
1112
  }
1123
1113
 
1124
1114
  // #endregion
@@ -1431,16 +1421,12 @@ export namespace TableSchema {
1431
1421
  * Factory for creating new table schema without specifying row or column schema.
1432
1422
  * @internal
1433
1423
  */
1434
- export function createTable<
1424
+ export function table<
1435
1425
  const TScope extends string | undefined,
1436
1426
  const TCell extends ImplicitAllowedTypes,
1437
- >({
1438
- schemaFactory,
1439
- cell,
1440
- }: System_TableSchema.TableFactoryOptionsBase<
1441
- SchemaFactoryAlpha<TScope>,
1442
- TCell
1443
- >): System_TableSchema.TableSchemaBase<
1427
+ >(
1428
+ params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell>,
1429
+ ): System_TableSchema.TableSchemaBase<
1444
1430
  TScope,
1445
1431
  TCell,
1446
1432
  System_TableSchema.ColumnSchemaBase<TScope, System_TableSchema.DefaultPropsType>,
@@ -1450,17 +1436,15 @@ export namespace TableSchema {
1450
1436
  * Factory for creating new table schema without specifying row schema.
1451
1437
  * @internal
1452
1438
  */
1453
- export function createTable<
1439
+ export function table<
1454
1440
  const TScope extends string | undefined,
1455
1441
  const TCell extends ImplicitAllowedTypes,
1456
1442
  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<
1443
+ >(
1444
+ params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1445
+ readonly column: TColumn;
1446
+ },
1447
+ ): System_TableSchema.TableSchemaBase<
1464
1448
  TScope,
1465
1449
  TCell,
1466
1450
  TColumn,
@@ -1470,38 +1454,40 @@ export namespace TableSchema {
1470
1454
  * Factory for creating new table schema.
1471
1455
  * @internal
1472
1456
  */
1473
- export function createTable<
1457
+ export function table<
1474
1458
  const TScope extends string | undefined,
1475
1459
  const TCell extends ImplicitAllowedTypes,
1476
1460
  const TColumn extends System_TableSchema.ColumnSchemaBase<TScope>,
1477
1461
  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>;
1462
+ >(
1463
+ params: System_TableSchema.TableFactoryOptionsBase<SchemaFactoryAlpha<TScope>, TCell> & {
1464
+ readonly column: TColumn;
1465
+ readonly row: TRow;
1466
+ },
1467
+ ): System_TableSchema.TableSchemaBase<TScope, TCell, TColumn, TRow>;
1487
1468
  /**
1488
1469
  * Overload implementation
1489
1470
  */
1490
- export function createTable({
1471
+ export function table({
1491
1472
  schemaFactory,
1492
- cell,
1493
- column = createColumn({
1473
+ cell: cellSchema,
1474
+ column: columnSchema = column({
1494
1475
  schemaFactory,
1495
1476
  }),
1496
- row = createRow({
1477
+ row: rowSchema = row({
1497
1478
  schemaFactory,
1498
- cell,
1479
+ cell: cellSchema,
1499
1480
  }),
1500
1481
  }: System_TableSchema.TableFactoryOptionsBase & {
1501
1482
  readonly column?: System_TableSchema.ColumnSchemaBase;
1502
1483
  readonly row?: System_TableSchema.RowSchemaBase;
1503
1484
  }): TreeNodeSchema {
1504
- return System_TableSchema.createTableInternal(schemaFactory, cell, column, row);
1485
+ return System_TableSchema.createTableSchema(
1486
+ schemaFactory,
1487
+ cellSchema,
1488
+ columnSchema,
1489
+ rowSchema,
1490
+ );
1505
1491
  }
1506
1492
 
1507
1493
  // #endregion