@fluidframework/tree 2.63.0 → 2.70.0-360753
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.
- package/api-report/tree.alpha.api.md +31 -27
- package/api-report/tree.beta.api.md +36 -1
- package/api-report/tree.legacy.beta.api.md +36 -1
- package/dist/alpha.d.ts +4 -4
- package/dist/beta.d.ts +4 -0
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +2 -2
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -10
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -4
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +9 -7
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +34 -11
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/legacy.d.ts +4 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializableDomainSchema.d.ts +12 -10
- package/dist/serializableDomainSchema.d.ts.map +1 -1
- package/dist/serializableDomainSchema.js +7 -7
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +2 -2
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +17 -13
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +8 -8
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +2 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js +8 -7
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +3 -2
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts +4 -3
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +3 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +4 -3
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +5 -5
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts +3 -10
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +3 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/dist/tableSchema.d.ts +37 -24
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +81 -54
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +1 -1
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/utils.d.ts +11 -2
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js.map +1 -1
- package/lib/alpha.d.ts +4 -4
- package/lib/beta.d.ts +4 -0
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts +2 -2
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +9 -10
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +5 -4
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +2 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +9 -7
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +34 -11
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/legacy.d.ts +4 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serializableDomainSchema.d.ts +12 -10
- package/lib/serializableDomainSchema.d.ts.map +1 -1
- package/lib/serializableDomainSchema.js +8 -8
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +2 -2
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +18 -14
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +8 -8
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +2 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js +8 -7
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts +3 -4
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +3 -2
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts +4 -3
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +3 -2
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +4 -3
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +5 -5
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts +3 -10
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +3 -2
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/lib/tableSchema.d.ts +37 -24
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +81 -54
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +1 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/utils.d.ts +11 -2
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js.map +1 -1
- package/package.json +21 -21
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +16 -14
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +8 -4
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +2 -0
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +65 -13
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +11 -11
- package/src/shared-tree/sharedTree.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +38 -22
- package/src/simple-tree/api/schemaFactoryAlpha.ts +8 -17
- package/src/simple-tree/api/schemaFactoryBeta.ts +17 -23
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -4
- package/src/simple-tree/node-kinds/map/mapNode.ts +5 -3
- package/src/simple-tree/node-kinds/object/objectNode.ts +8 -7
- package/src/simple-tree/node-kinds/record/recordNode.ts +6 -18
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +2 -2
- package/src/tableSchema.ts +143 -81
- package/src/treeFactory.ts +1 -0
- package/src/util/utils.ts +11 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { assert, debugAssert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
8
8
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
9
|
|
|
@@ -164,7 +164,7 @@ export interface ObjectSchemaOptionsAlpha<TCustomMetadata = unknown>
|
|
|
164
164
|
* @remarks Omits parameters that are not relevant for common use cases.
|
|
165
165
|
*/
|
|
166
166
|
export const defaultSchemaFactoryObjectOptions: Required<
|
|
167
|
-
|
|
167
|
+
Pick<ObjectSchemaOptions, "allowUnknownOptionalFields">
|
|
168
168
|
> = {
|
|
169
169
|
allowUnknownOptionalFields: false,
|
|
170
170
|
};
|
|
@@ -397,12 +397,9 @@ export class SchemaFactory<
|
|
|
397
397
|
true,
|
|
398
398
|
T
|
|
399
399
|
> {
|
|
400
|
-
return objectSchema(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
true,
|
|
404
|
-
defaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,
|
|
405
|
-
);
|
|
400
|
+
return objectSchema(scoped(this, name), fields, true, {
|
|
401
|
+
...defaultSchemaFactoryObjectOptions,
|
|
402
|
+
});
|
|
406
403
|
}
|
|
407
404
|
|
|
408
405
|
/**
|
|
@@ -474,15 +471,17 @@ export class SchemaFactory<
|
|
|
474
471
|
* This seems like a TypeScript bug getting variance backwards for overload return types since it's erroring when the relation between the overload
|
|
475
472
|
* and the implementation is type safe, and forcing an unsafe typing instead.
|
|
476
473
|
*/
|
|
477
|
-
public map<const T extends ImplicitAllowedTypes>(
|
|
474
|
+
public map<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
|
|
478
475
|
nameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),
|
|
479
476
|
allowedTypes?: T,
|
|
477
|
+
options?: NodeSchemaOptions<TCustomMetadata>,
|
|
480
478
|
): TreeNodeSchema<string, NodeKind.Map, TreeMapNode<T>, MapNodeInsertableData<T>, true, T> {
|
|
481
479
|
if (allowedTypes === undefined) {
|
|
482
480
|
const types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];
|
|
483
481
|
const fullName = structuralName("Map", types);
|
|
482
|
+
debugAssert(() => options === undefined || "No options for structural types");
|
|
484
483
|
return this.getStructuralType(fullName, types, () =>
|
|
485
|
-
this.namedMap(fullName, nameOrAllowedTypes as T, false, true),
|
|
484
|
+
this.namedMap(fullName, nameOrAllowedTypes as T, false, true, {}),
|
|
486
485
|
) as TreeNodeSchemaBoth<
|
|
487
486
|
string,
|
|
488
487
|
NodeKind.Map,
|
|
@@ -490,7 +489,8 @@ export class SchemaFactory<
|
|
|
490
489
|
MapNodeInsertableData<T>,
|
|
491
490
|
true,
|
|
492
491
|
T,
|
|
493
|
-
undefined
|
|
492
|
+
undefined,
|
|
493
|
+
TCustomMetadata
|
|
494
494
|
>;
|
|
495
495
|
}
|
|
496
496
|
// To actually have type safety, assign to the type this method should return before implicitly up-casting when returning.
|
|
@@ -501,8 +501,9 @@ export class SchemaFactory<
|
|
|
501
501
|
MapNodeInsertableData<T>,
|
|
502
502
|
true,
|
|
503
503
|
T,
|
|
504
|
-
undefined
|
|
505
|
-
|
|
504
|
+
undefined,
|
|
505
|
+
TCustomMetadata
|
|
506
|
+
> = this.namedMap(nameOrAllowedTypes as TName, allowedTypes, true, true, options ?? {});
|
|
506
507
|
return out;
|
|
507
508
|
}
|
|
508
509
|
|
|
@@ -515,11 +516,13 @@ export class SchemaFactory<
|
|
|
515
516
|
Name extends TName | string,
|
|
516
517
|
const T extends ImplicitAllowedTypes,
|
|
517
518
|
const ImplicitlyConstructable extends boolean,
|
|
519
|
+
const TCustomMetadata = unknown,
|
|
518
520
|
>(
|
|
519
521
|
name: Name,
|
|
520
522
|
allowedTypes: T,
|
|
521
523
|
customizable: boolean,
|
|
522
524
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
525
|
+
options: NodeSchemaOptionsAlpha<TCustomMetadata>,
|
|
523
526
|
): TreeNodeSchemaBoth<
|
|
524
527
|
ScopedSchemaName<TScope, Name>,
|
|
525
528
|
NodeKind.Map,
|
|
@@ -527,7 +530,8 @@ export class SchemaFactory<
|
|
|
527
530
|
MapNodeInsertableData<T>,
|
|
528
531
|
ImplicitlyConstructable,
|
|
529
532
|
T,
|
|
530
|
-
undefined
|
|
533
|
+
undefined,
|
|
534
|
+
TCustomMetadata
|
|
531
535
|
> {
|
|
532
536
|
return mapSchema(
|
|
533
537
|
scoped(this, name),
|
|
@@ -535,7 +539,7 @@ export class SchemaFactory<
|
|
|
535
539
|
implicitlyConstructable,
|
|
536
540
|
// The current policy is customizable nodes don't get fake prototypes.
|
|
537
541
|
!customizable,
|
|
538
|
-
|
|
542
|
+
options ?? {},
|
|
539
543
|
);
|
|
540
544
|
}
|
|
541
545
|
|
|
@@ -618,22 +622,25 @@ export class SchemaFactory<
|
|
|
618
622
|
* @privateRemarks
|
|
619
623
|
* This should return TreeNodeSchemaBoth: see note on "map" implementation for details.
|
|
620
624
|
*/
|
|
621
|
-
public array<const T extends ImplicitAllowedTypes>(
|
|
625
|
+
public array<const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
|
|
622
626
|
nameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),
|
|
623
627
|
allowedTypes?: T,
|
|
628
|
+
options?: NodeSchemaOptions<TCustomMetadata>,
|
|
624
629
|
): TreeNodeSchema<
|
|
625
630
|
ScopedSchemaName<TScope, string>,
|
|
626
631
|
NodeKind.Array,
|
|
627
632
|
TreeArrayNode<T>,
|
|
628
633
|
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
|
|
629
634
|
true,
|
|
630
|
-
T
|
|
635
|
+
T,
|
|
636
|
+
TCustomMetadata
|
|
631
637
|
> {
|
|
632
638
|
if (allowedTypes === undefined) {
|
|
633
639
|
const types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];
|
|
634
640
|
const fullName = structuralName("Array", types);
|
|
641
|
+
debugAssert(() => options === undefined || "No options for structural types");
|
|
635
642
|
return this.getStructuralType(fullName, types, () =>
|
|
636
|
-
this.namedArray(fullName, nameOrAllowedTypes as T, false, true),
|
|
643
|
+
this.namedArray(fullName, nameOrAllowedTypes as T, false, true, {}),
|
|
637
644
|
) as TreeNodeSchemaClass<
|
|
638
645
|
ScopedSchemaName<TScope, string>,
|
|
639
646
|
NodeKind.Array,
|
|
@@ -641,9 +648,11 @@ export class SchemaFactory<
|
|
|
641
648
|
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
|
|
642
649
|
true,
|
|
643
650
|
T,
|
|
644
|
-
undefined
|
|
651
|
+
undefined,
|
|
652
|
+
TCustomMetadata
|
|
645
653
|
>;
|
|
646
654
|
}
|
|
655
|
+
|
|
647
656
|
const out: TreeNodeSchemaBoth<
|
|
648
657
|
ScopedSchemaName<TScope, string>,
|
|
649
658
|
NodeKind.Array,
|
|
@@ -651,8 +660,9 @@ export class SchemaFactory<
|
|
|
651
660
|
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
|
|
652
661
|
true,
|
|
653
662
|
T,
|
|
654
|
-
undefined
|
|
655
|
-
|
|
663
|
+
undefined,
|
|
664
|
+
TCustomMetadata
|
|
665
|
+
> = this.namedArray(nameOrAllowedTypes as TName, allowedTypes, true, true, options ?? {});
|
|
656
666
|
return out;
|
|
657
667
|
}
|
|
658
668
|
|
|
@@ -698,11 +708,13 @@ export class SchemaFactory<
|
|
|
698
708
|
Name extends TName | string,
|
|
699
709
|
const T extends ImplicitAllowedTypes,
|
|
700
710
|
const ImplicitlyConstructable extends boolean,
|
|
711
|
+
const TCustomMetadata = unknown,
|
|
701
712
|
>(
|
|
702
713
|
name: Name,
|
|
703
714
|
allowedTypes: T,
|
|
704
715
|
customizable: boolean,
|
|
705
716
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
717
|
+
options: NodeSchemaOptionsAlpha<TCustomMetadata>,
|
|
706
718
|
): TreeNodeSchemaBoth<
|
|
707
719
|
ScopedSchemaName<TScope, Name>,
|
|
708
720
|
NodeKind.Array,
|
|
@@ -710,13 +722,15 @@ export class SchemaFactory<
|
|
|
710
722
|
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>,
|
|
711
723
|
ImplicitlyConstructable,
|
|
712
724
|
T,
|
|
713
|
-
undefined
|
|
725
|
+
undefined,
|
|
726
|
+
TCustomMetadata
|
|
714
727
|
> {
|
|
715
728
|
return arraySchema(
|
|
716
729
|
scoped(this, name),
|
|
717
730
|
allowedTypes,
|
|
718
731
|
implicitlyConstructable,
|
|
719
732
|
customizable,
|
|
733
|
+
options,
|
|
720
734
|
);
|
|
721
735
|
}
|
|
722
736
|
|
|
@@ -822,6 +836,7 @@ export class SchemaFactory<
|
|
|
822
836
|
allowedTypes as T & ImplicitAllowedTypes,
|
|
823
837
|
true,
|
|
824
838
|
false,
|
|
839
|
+
{},
|
|
825
840
|
);
|
|
826
841
|
|
|
827
842
|
return RecursiveArray as TreeNodeSchemaClass<
|
|
@@ -870,6 +885,7 @@ export class SchemaFactory<
|
|
|
870
885
|
// Setting this (implicitlyConstructable) to true seems to work ok currently, but not for other node kinds.
|
|
871
886
|
// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.
|
|
872
887
|
false,
|
|
888
|
+
{},
|
|
873
889
|
);
|
|
874
890
|
|
|
875
891
|
return MapSchema as TreeNodeSchemaClass<
|
|
@@ -218,15 +218,10 @@ export class SchemaFactoryAlpha<
|
|
|
218
218
|
*/
|
|
219
219
|
readonly createFromInsertable: unknown;
|
|
220
220
|
} {
|
|
221
|
-
return objectSchema(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
options?.allowUnknownOptionalFields ??
|
|
226
|
-
defaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,
|
|
227
|
-
options?.metadata,
|
|
228
|
-
options?.persistedMetadata,
|
|
229
|
-
);
|
|
221
|
+
return objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {
|
|
222
|
+
...defaultSchemaFactoryObjectOptions,
|
|
223
|
+
...(options ?? {}),
|
|
224
|
+
});
|
|
230
225
|
}
|
|
231
226
|
|
|
232
227
|
/**
|
|
@@ -408,8 +403,7 @@ export class SchemaFactoryAlpha<
|
|
|
408
403
|
allowedTypes,
|
|
409
404
|
true,
|
|
410
405
|
true,
|
|
411
|
-
options
|
|
412
|
-
options?.persistedMetadata,
|
|
406
|
+
options,
|
|
413
407
|
);
|
|
414
408
|
}
|
|
415
409
|
|
|
@@ -459,8 +453,7 @@ export class SchemaFactoryAlpha<
|
|
|
459
453
|
allowedTypes,
|
|
460
454
|
true,
|
|
461
455
|
true,
|
|
462
|
-
options
|
|
463
|
-
options?.persistedMetadata,
|
|
456
|
+
options ?? {},
|
|
464
457
|
);
|
|
465
458
|
}
|
|
466
459
|
|
|
@@ -510,8 +503,7 @@ export class SchemaFactoryAlpha<
|
|
|
510
503
|
info: allowedTypes,
|
|
511
504
|
customizable: true,
|
|
512
505
|
implicitlyConstructable: true,
|
|
513
|
-
|
|
514
|
-
persistedMetadata: options?.persistedMetadata,
|
|
506
|
+
nodeOptions: options,
|
|
515
507
|
});
|
|
516
508
|
}
|
|
517
509
|
|
|
@@ -535,8 +527,7 @@ export class SchemaFactoryAlpha<
|
|
|
535
527
|
// Setting this to true seems to work ok currently, but not for other node kinds.
|
|
536
528
|
// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.
|
|
537
529
|
implicitlyConstructable: false,
|
|
538
|
-
|
|
539
|
-
persistedMetadata: options?.persistedMetadata,
|
|
530
|
+
nodeOptions: options,
|
|
540
531
|
});
|
|
541
532
|
|
|
542
533
|
return RecordSchema as TreeNodeSchemaClass<
|
|
@@ -90,14 +90,10 @@ export class SchemaFactoryBeta<
|
|
|
90
90
|
true,
|
|
91
91
|
T
|
|
92
92
|
> {
|
|
93
|
-
return objectSchema(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
options?.allowUnknownOptionalFields ??
|
|
98
|
-
defaultSchemaFactoryObjectOptions.allowUnknownOptionalFields,
|
|
99
|
-
options?.metadata,
|
|
100
|
-
);
|
|
93
|
+
return objectSchema(scoped<TScope, TName, Name>(this, name), fields, true, {
|
|
94
|
+
...defaultSchemaFactoryObjectOptions,
|
|
95
|
+
...(options ?? {}),
|
|
96
|
+
});
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
public override objectRecursive<
|
|
@@ -192,6 +188,7 @@ export class SchemaFactoryBeta<
|
|
|
192
188
|
*
|
|
193
189
|
* @param name - Unique identifier for this schema within this factory's scope.
|
|
194
190
|
* @param allowedTypes - The types that may appear in the record.
|
|
191
|
+
* @param options - Additional options for the schema.
|
|
195
192
|
*
|
|
196
193
|
* @remarks
|
|
197
194
|
* The underlying data format for `Record` nodes is the same as that for `Map` nodes.
|
|
@@ -211,9 +208,14 @@ export class SchemaFactoryBeta<
|
|
|
211
208
|
*
|
|
212
209
|
* {@label NAMED}
|
|
213
210
|
*/
|
|
214
|
-
public record<
|
|
211
|
+
public record<
|
|
212
|
+
const Name extends TName,
|
|
213
|
+
const T extends ImplicitAllowedTypes,
|
|
214
|
+
const TCustomMetadata = unknown,
|
|
215
|
+
>(
|
|
215
216
|
name: Name,
|
|
216
217
|
allowedTypes: T,
|
|
218
|
+
options?: NodeSchemaOptions<TCustomMetadata>,
|
|
217
219
|
): TreeNodeSchemaClass<
|
|
218
220
|
/* Name */ ScopedSchemaName<TScope, Name>,
|
|
219
221
|
/* Kind */ NodeKind.Record,
|
|
@@ -221,7 +223,8 @@ export class SchemaFactoryBeta<
|
|
|
221
223
|
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
222
224
|
/* ImplicitlyConstructable */ true,
|
|
223
225
|
/* Info */ T,
|
|
224
|
-
/* TConstructorExtra */ undefined
|
|
226
|
+
/* TConstructorExtra */ undefined,
|
|
227
|
+
/* TCustomMetadata */ TCustomMetadata
|
|
225
228
|
>;
|
|
226
229
|
|
|
227
230
|
/**
|
|
@@ -233,6 +236,7 @@ export class SchemaFactoryBeta<
|
|
|
233
236
|
public record<const T extends ImplicitAllowedTypes>(
|
|
234
237
|
nameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),
|
|
235
238
|
maybeAllowedTypes?: T,
|
|
239
|
+
options?: NodeSchemaOptions,
|
|
236
240
|
): TreeNodeSchema<
|
|
237
241
|
/* Name */ ScopedSchemaName<TScope, string>,
|
|
238
242
|
/* Kind */ NodeKind.Record,
|
|
@@ -274,6 +278,7 @@ export class SchemaFactoryBeta<
|
|
|
274
278
|
maybeAllowedTypes,
|
|
275
279
|
/* customizable */ true,
|
|
276
280
|
/* implicitlyConstructable */ true,
|
|
281
|
+
options,
|
|
277
282
|
);
|
|
278
283
|
return out;
|
|
279
284
|
}
|
|
@@ -307,24 +312,13 @@ export class SchemaFactoryBeta<
|
|
|
307
312
|
/* Info */ T,
|
|
308
313
|
/* TConstructorExtra */ undefined
|
|
309
314
|
> {
|
|
310
|
-
|
|
315
|
+
return recordSchema({
|
|
311
316
|
identifier: scoped<TScope, TName, Name>(this, name),
|
|
312
317
|
info: allowedTypes,
|
|
313
318
|
customizable,
|
|
314
319
|
implicitlyConstructable,
|
|
315
|
-
|
|
320
|
+
nodeOptions: options,
|
|
316
321
|
});
|
|
317
|
-
|
|
318
|
-
return record as TreeNodeSchemaBoth<
|
|
319
|
-
/* Name */ ScopedSchemaName<TScope, Name>,
|
|
320
|
-
/* Kind */ NodeKind.Record,
|
|
321
|
-
/* TNode */ TreeRecordNode<T> &
|
|
322
|
-
WithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,
|
|
323
|
-
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
324
|
-
/* ImplicitlyConstructable */ ImplicitlyConstructable,
|
|
325
|
-
/* Info */ T,
|
|
326
|
-
/* TConstructorExtra */ undefined
|
|
327
|
-
>;
|
|
328
322
|
}
|
|
329
323
|
|
|
330
324
|
/**
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
getTreeNodeSchemaInitializedData,
|
|
60
60
|
getUnhydratedContext,
|
|
61
61
|
} from "../../createContext.js";
|
|
62
|
-
import type { System_Unsafe } from "../../api/index.js";
|
|
62
|
+
import type { NodeSchemaOptionsAlpha, System_Unsafe } from "../../api/index.js";
|
|
63
63
|
import type {
|
|
64
64
|
ArrayNodeCustomizableSchema,
|
|
65
65
|
ArrayNodePojoEmulationSchema,
|
|
@@ -1152,8 +1152,7 @@ export function arraySchema<
|
|
|
1152
1152
|
info: T,
|
|
1153
1153
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
1154
1154
|
customizable: boolean,
|
|
1155
|
-
|
|
1156
|
-
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
1155
|
+
nodeOptions: NodeSchemaOptionsAlpha<TCustomMetadata>,
|
|
1157
1156
|
) {
|
|
1158
1157
|
type Output = ArrayNodeCustomizableSchema<
|
|
1159
1158
|
TName,
|
|
@@ -1164,6 +1163,7 @@ export function arraySchema<
|
|
|
1164
1163
|
ArrayNodePojoEmulationSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &
|
|
1165
1164
|
TreeNodeSchemaCorePrivate;
|
|
1166
1165
|
|
|
1166
|
+
const persistedMetadata = nodeOptions?.persistedMetadata;
|
|
1167
1167
|
const normalizedTypes = normalizeAllowedTypes(info);
|
|
1168
1168
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
1169
1169
|
() => new Set(normalizedTypes.evaluate().map((type) => type.identifier)),
|
|
@@ -1252,7 +1252,8 @@ export function arraySchema<
|
|
|
1252
1252
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
1253
1253
|
return normalizedTypes.evaluateSet();
|
|
1254
1254
|
}
|
|
1255
|
-
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
1255
|
+
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
1256
|
+
nodeOptions.metadata ?? {};
|
|
1256
1257
|
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
1257
1258
|
persistedMetadata;
|
|
1258
1259
|
|
|
@@ -65,6 +65,7 @@ import type {
|
|
|
65
65
|
} from "./mapNodeTypes.js";
|
|
66
66
|
import { recordLikeDataToFlexContent } from "../common.js";
|
|
67
67
|
import { MapNodeStoredSchema } from "../../../core/index.js";
|
|
68
|
+
import type { NodeSchemaOptionsAlpha } from "../../api/index.js";
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* A map of string keys to tree objects.
|
|
@@ -268,8 +269,7 @@ export function mapSchema<
|
|
|
268
269
|
info: T,
|
|
269
270
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
270
271
|
useMapPrototype: boolean,
|
|
271
|
-
|
|
272
|
-
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
272
|
+
nodeOptions: NodeSchemaOptionsAlpha<TCustomMetadata> = {},
|
|
273
273
|
) {
|
|
274
274
|
const normalizedTypes = normalizeAllowedTypes(info);
|
|
275
275
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
@@ -277,6 +277,7 @@ export function mapSchema<
|
|
|
277
277
|
);
|
|
278
278
|
|
|
279
279
|
let privateData: TreeNodeSchemaPrivateData | undefined;
|
|
280
|
+
const persistedMetadata = nodeOptions.persistedMetadata;
|
|
280
281
|
|
|
281
282
|
class Schema extends CustomMapNodeBase<T> implements TreeMapNode<T> {
|
|
282
283
|
public static override prepareInstance<T2>(
|
|
@@ -319,7 +320,8 @@ export function mapSchema<
|
|
|
319
320
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
320
321
|
return normalizedTypes.evaluateSet();
|
|
321
322
|
}
|
|
322
|
-
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
323
|
+
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
324
|
+
nodeOptions.metadata ?? {};
|
|
323
325
|
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
324
326
|
persistedMetadata;
|
|
325
327
|
|
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
type InsertableContent,
|
|
88
88
|
} from "../../unhydratedFlexTreeFromInsertable.js";
|
|
89
89
|
import { convertField, convertFieldKind } from "../../toStoredSchema.js";
|
|
90
|
+
import type { ObjectSchemaOptionsAlpha } from "../../api/index.js";
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* Generates the properties for an ObjectNode from its field schema object.
|
|
@@ -415,9 +416,7 @@ export function objectSchema<
|
|
|
415
416
|
identifier: TName,
|
|
416
417
|
info: T,
|
|
417
418
|
implicitlyConstructable: ImplicitlyConstructable,
|
|
418
|
-
|
|
419
|
-
metadata?: NodeSchemaMetadata<TCustomMetadata>,
|
|
420
|
-
persistedMetadata?: JsonCompatibleReadOnlyObject | undefined,
|
|
419
|
+
nodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,
|
|
421
420
|
): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &
|
|
422
421
|
ObjectNodeSchemaInternalData &
|
|
423
422
|
TreeNodeSchemaCorePrivate {
|
|
@@ -471,7 +470,8 @@ export function objectSchema<
|
|
|
471
470
|
]),
|
|
472
471
|
);
|
|
473
472
|
public static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;
|
|
474
|
-
public static readonly allowUnknownOptionalFields: boolean =
|
|
473
|
+
public static readonly allowUnknownOptionalFields: boolean =
|
|
474
|
+
nodeOptions.allowUnknownOptionalFields ?? false;
|
|
475
475
|
|
|
476
476
|
public static override prepareInstance<T2>(
|
|
477
477
|
this: typeof TreeNodeValid<T2>,
|
|
@@ -561,9 +561,10 @@ export function objectSchema<
|
|
|
561
561
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
562
562
|
return lazyChildTypes.value;
|
|
563
563
|
}
|
|
564
|
-
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
564
|
+
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
565
|
+
nodeOptions.metadata ?? {};
|
|
565
566
|
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
566
|
-
persistedMetadata;
|
|
567
|
+
nodeOptions.persistedMetadata;
|
|
567
568
|
|
|
568
569
|
// eslint-disable-next-line import/no-deprecated
|
|
569
570
|
public get [typeNameSymbol](): TName {
|
|
@@ -592,7 +593,7 @@ export function objectSchema<
|
|
|
592
593
|
convertField(fieldSchema.schema, storedOptions),
|
|
593
594
|
);
|
|
594
595
|
}
|
|
595
|
-
return new ObjectNodeStoredSchema(fields, persistedMetadata);
|
|
596
|
+
return new ObjectNodeStoredSchema(fields, nodeOptions.persistedMetadata);
|
|
596
597
|
},
|
|
597
598
|
));
|
|
598
599
|
}
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
import { prepareForInsertion } from "../../prepareForInsertion.js";
|
|
58
58
|
import { recordLikeDataToFlexContent } from "../common.js";
|
|
59
59
|
import { MapNodeStoredSchema } from "../../../core/index.js";
|
|
60
|
+
import type { NodeSchemaOptionsAlpha } from "../../api/index.js";
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* Create a proxy which implements the {@link TreeRecordNode} API.
|
|
@@ -227,15 +228,7 @@ export interface RecordSchemaOptions<
|
|
|
227
228
|
|
|
228
229
|
readonly implicitlyConstructable: TImplicitlyConstructable;
|
|
229
230
|
|
|
230
|
-
|
|
231
|
-
* Optional ephemeral metadata for the object node schema.
|
|
232
|
-
*/
|
|
233
|
-
readonly metadata?: NodeSchemaMetadata<TCustomMetadata>;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Optional persisted metadata for the object node schema.
|
|
237
|
-
*/
|
|
238
|
-
readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
|
|
231
|
+
readonly nodeOptions?: NodeSchemaOptionsAlpha<TCustomMetadata>;
|
|
239
232
|
}
|
|
240
233
|
|
|
241
234
|
/**
|
|
@@ -258,14 +251,8 @@ export function recordSchema<
|
|
|
258
251
|
TCustomMetadata
|
|
259
252
|
>,
|
|
260
253
|
) {
|
|
261
|
-
const {
|
|
262
|
-
|
|
263
|
-
info,
|
|
264
|
-
customizable,
|
|
265
|
-
implicitlyConstructable,
|
|
266
|
-
metadata,
|
|
267
|
-
persistedMetadata,
|
|
268
|
-
} = options;
|
|
254
|
+
const { identifier, info, customizable, implicitlyConstructable, nodeOptions } = options;
|
|
255
|
+
const persistedMetadata = nodeOptions?.persistedMetadata;
|
|
269
256
|
|
|
270
257
|
const normalizedTypes = normalizeAllowedTypes(info);
|
|
271
258
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
@@ -369,7 +356,8 @@ export function recordSchema<
|
|
|
369
356
|
public static get childTypes(): ReadonlySet<TreeNodeSchema> {
|
|
370
357
|
return normalizedTypes.evaluateSet();
|
|
371
358
|
}
|
|
372
|
-
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
359
|
+
public static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =
|
|
360
|
+
nodeOptions?.metadata ?? {};
|
|
373
361
|
public static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =
|
|
374
362
|
persistedMetadata;
|
|
375
363
|
|
|
@@ -64,7 +64,7 @@ export interface RecordNodeCustomizableSchema<
|
|
|
64
64
|
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
65
65
|
/* ImplicitlyConstructable */ ImplicitlyConstructable,
|
|
66
66
|
/* Info */ T,
|
|
67
|
-
/* TConstructorExtra */
|
|
67
|
+
/* TConstructorExtra */ undefined,
|
|
68
68
|
/* TCustomMetadata */ TCustomMetadata
|
|
69
69
|
>,
|
|
70
70
|
SimpleRecordNodeSchema<TCustomMetadata> {}
|
|
@@ -85,7 +85,7 @@ export interface RecordNodePojoEmulationSchema<
|
|
|
85
85
|
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
86
86
|
/* ImplicitlyConstructable */ ImplicitlyConstructable,
|
|
87
87
|
/* Info */ T,
|
|
88
|
-
/* TConstructorExtra */
|
|
88
|
+
/* TConstructorExtra */ undefined,
|
|
89
89
|
/* TCustomMetadata */ TCustomMetadata
|
|
90
90
|
>,
|
|
91
91
|
SimpleRecordNodeSchema<TCustomMetadata> {}
|