@fluidframework/tree 2.33.1 → 2.40.0-336023
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/.vscode/settings.json +2 -0
- package/api-report/tree.alpha.api.md +120 -50
- package/api-report/tree.beta.api.md +31 -27
- package/api-report/tree.legacy.alpha.api.md +24 -23
- package/api-report/tree.legacy.public.api.md +24 -23
- package/api-report/tree.public.api.md +24 -23
- package/dist/alpha.d.ts +16 -1
- package/dist/beta.d.ts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +0 -1
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +2 -2
- package/dist/jsonDomainSchema.js +2 -2
- package/dist/jsonDomainSchema.js.map +1 -1
- package/dist/legacy.d.ts +2 -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/public.d.ts +2 -0
- package/dist/serializableDomainSchema.d.ts +3 -3
- package/dist/serializableDomainSchema.js +2 -2
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/independentView.d.ts +1 -1
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +3 -2
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +4 -4
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +4 -4
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +2 -3
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +3 -3
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +4 -4
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/{treeApi.d.ts → tree.d.ts} +34 -34
- package/dist/shared-tree/tree.d.ts.map +1 -0
- package/dist/shared-tree/{treeApi.js → tree.js} +6 -6
- package/dist/shared-tree/tree.js.map +1 -0
- package/dist/shared-tree/{treeApiAlpha.d.ts → treeAlpha.d.ts} +22 -14
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -0
- package/dist/shared-tree/{treeApiAlpha.js → treeAlpha.js} +4 -3
- package/dist/shared-tree/treeAlpha.js.map +1 -0
- package/dist/simple-tree/api/conciseTree.d.ts +1 -1
- package/dist/simple-tree/api/conciseTree.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +177 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -0
- package/dist/simple-tree/api/configuration.js +163 -0
- package/dist/simple-tree/api/configuration.js.map +1 -0
- package/dist/simple-tree/api/getJsonSchema.js +2 -2
- package/dist/simple-tree/api/getJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +7 -4
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +8 -7
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
- package/dist/simple-tree/api/{view.js → schemaCompatibilityTester.js} +9 -9
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
- package/dist/simple-tree/api/schemaFactory.d.ts +16 -10
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +20 -12
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +2 -2
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +3 -3
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +3 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +5 -174
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js +1 -156
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/{lib/simple-tree/api/treeApiBeta.d.ts → dist/simple-tree/api/treeBeta.d.ts} +13 -5
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -0
- package/dist/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
- package/dist/simple-tree/api/treeBeta.js.map +1 -0
- package/dist/simple-tree/api/typesUnsafe.d.ts +4 -9
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/arrayNode.d.ts +2 -2
- package/dist/simple-tree/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/arrayNode.js +3 -2
- package/dist/simple-tree/arrayNode.js.map +1 -1
- package/dist/simple-tree/arrayNodeTypes.d.ts +3 -3
- package/dist/simple-tree/arrayNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/arrayNodeTypes.js.map +1 -1
- package/dist/simple-tree/index.d.ts +3 -3
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +2 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/mapNode.d.ts +2 -2
- package/dist/simple-tree/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/mapNode.js +1 -1
- package/dist/simple-tree/mapNode.js.map +1 -1
- package/dist/simple-tree/mapNodeTypes.d.ts +3 -3
- package/dist/simple-tree/mapNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/mapNodeTypes.js.map +1 -1
- package/dist/simple-tree/objectNode.d.ts +18 -5
- package/dist/simple-tree/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/objectNode.js +4 -3
- package/dist/simple-tree/objectNode.js.map +1 -1
- package/dist/simple-tree/objectNodeTypes.d.ts +4 -4
- package/dist/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +163 -13
- package/dist/simple-tree/schemaTypes.d.ts.map +1 -1
- package/dist/simple-tree/schemaTypes.js +107 -8
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +2 -2
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/tableSchema.d.ts +197 -86
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +100 -45
- package/dist/tableSchema.js.map +1 -1
- package/dist/util/typeUtils.d.ts +1 -1
- package/dist/util/typeUtils.js.map +1 -1
- package/lib/alpha.d.ts +16 -1
- package/lib/beta.d.ts +2 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +0 -1
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +2 -2
- package/lib/jsonDomainSchema.js +2 -2
- package/lib/jsonDomainSchema.js.map +1 -1
- package/lib/legacy.d.ts +2 -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/public.d.ts +2 -0
- package/lib/serializableDomainSchema.d.ts +3 -3
- package/lib/serializableDomainSchema.js +2 -2
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/independentView.d.ts +1 -1
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +3 -2
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -2
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +4 -4
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +2 -3
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +3 -3
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +5 -5
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/{treeApi.d.ts → tree.d.ts} +34 -34
- package/lib/shared-tree/tree.d.ts.map +1 -0
- package/lib/shared-tree/{treeApi.js → tree.js} +5 -5
- package/lib/shared-tree/tree.js.map +1 -0
- package/lib/shared-tree/{treeApiAlpha.d.ts → treeAlpha.d.ts} +22 -14
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -0
- package/lib/shared-tree/{treeApiAlpha.js → treeAlpha.js} +4 -3
- package/lib/shared-tree/treeAlpha.js.map +1 -0
- package/lib/simple-tree/api/conciseTree.d.ts +1 -1
- package/lib/simple-tree/api/conciseTree.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +177 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -0
- package/lib/simple-tree/api/configuration.js +157 -0
- package/lib/simple-tree/api/configuration.js.map +1 -0
- package/lib/simple-tree/api/getJsonSchema.js +1 -1
- package/lib/simple-tree/api/getJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +7 -4
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +4 -3
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/{view.d.ts → schemaCompatibilityTester.d.ts} +8 -10
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -0
- package/lib/simple-tree/api/{view.js → schemaCompatibilityTester.js} +7 -7
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -0
- package/lib/simple-tree/api/schemaFactory.d.ts +16 -10
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +20 -12
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +12 -6
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +2 -2
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +67 -4
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +3 -3
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +3 -2
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +5 -174
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js +0 -152
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/{dist/simple-tree/api/treeApiBeta.d.ts → lib/simple-tree/api/treeBeta.d.ts} +13 -5
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -0
- package/lib/simple-tree/api/{treeApiBeta.js → treeBeta.js} +5 -4
- package/lib/simple-tree/api/treeBeta.js.map +1 -0
- package/lib/simple-tree/api/typesUnsafe.d.ts +4 -9
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/arrayNode.d.ts +2 -2
- package/lib/simple-tree/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/arrayNode.js +4 -3
- package/lib/simple-tree/arrayNode.js.map +1 -1
- package/lib/simple-tree/arrayNodeTypes.d.ts +3 -3
- package/lib/simple-tree/arrayNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/arrayNodeTypes.js.map +1 -1
- package/lib/simple-tree/index.d.ts +3 -3
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/mapNode.d.ts +2 -2
- package/lib/simple-tree/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/mapNode.js +2 -2
- package/lib/simple-tree/mapNode.js.map +1 -1
- package/lib/simple-tree/mapNodeTypes.d.ts +3 -3
- package/lib/simple-tree/mapNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/mapNodeTypes.js.map +1 -1
- package/lib/simple-tree/objectNode.d.ts +18 -5
- package/lib/simple-tree/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/objectNode.js +5 -4
- package/lib/simple-tree/objectNode.js.map +1 -1
- package/lib/simple-tree/objectNodeTypes.d.ts +4 -4
- package/lib/simple-tree/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/schemaTypes.d.ts +163 -13
- package/lib/simple-tree/schemaTypes.d.ts.map +1 -1
- package/lib/simple-tree/schemaTypes.js +96 -8
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +2 -2
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/tableSchema.d.ts +197 -86
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +100 -45
- package/lib/tableSchema.js.map +1 -1
- package/lib/util/typeUtils.d.ts +1 -1
- package/lib/util/typeUtils.js.map +1 -1
- package/package.json +20 -20
- package/src/index.ts +17 -1
- package/src/internalTypes.ts +0 -2
- package/src/jsonDomainSchema.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +3 -3
- package/src/shared-tree/independentView.ts +1 -1
- package/src/shared-tree/index.ts +3 -6
- package/src/shared-tree/schematizeTree.ts +5 -5
- package/src/shared-tree/schematizingTreeView.ts +11 -8
- package/src/shared-tree/{treeApi.ts → tree.ts} +51 -51
- package/src/shared-tree/{treeApiAlpha.ts → treeAlpha.ts} +22 -13
- package/src/simple-tree/api/conciseTree.ts +1 -1
- package/src/simple-tree/api/configuration.ts +353 -0
- package/src/simple-tree/api/getJsonSchema.ts +1 -1
- package/src/simple-tree/api/index.ts +21 -15
- package/src/simple-tree/api/{view.ts → schemaCompatibilityTester.ts} +8 -15
- package/src/simple-tree/api/schemaFactory.ts +130 -19
- package/src/simple-tree/api/schemaFactoryAlpha.ts +7 -5
- package/src/simple-tree/api/schemaFactoryRecursive.ts +102 -38
- package/src/simple-tree/api/schemaFromSimple.ts +2 -2
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
- package/src/simple-tree/api/storedSchema.ts +8 -4
- package/src/simple-tree/api/tree.ts +13 -354
- package/src/simple-tree/api/{treeApiBeta.ts → treeBeta.ts} +17 -5
- package/src/simple-tree/api/typesUnsafe.ts +15 -11
- package/src/simple-tree/arrayNode.ts +10 -5
- package/src/simple-tree/arrayNodeTypes.ts +8 -7
- package/src/simple-tree/index.ts +17 -1
- package/src/simple-tree/mapNode.ts +11 -3
- package/src/simple-tree/mapNodeTypes.ts +10 -7
- package/src/simple-tree/objectNode.ts +39 -15
- package/src/simple-tree/objectNodeTypes.ts +9 -5
- package/src/simple-tree/schemaTypes.ts +353 -25
- package/src/simple-tree/treeNodeValid.ts +2 -2
- package/src/tableSchema.ts +749 -445
- package/src/util/typeUtils.ts +1 -1
- package/dist/shared-tree/treeApi.d.ts.map +0 -1
- package/dist/shared-tree/treeApi.js.map +0 -1
- package/dist/shared-tree/treeApiAlpha.d.ts.map +0 -1
- package/dist/shared-tree/treeApiAlpha.js.map +0 -1
- package/dist/simple-tree/api/treeApiBeta.d.ts.map +0 -1
- package/dist/simple-tree/api/treeApiBeta.js.map +0 -1
- package/dist/simple-tree/api/view.d.ts.map +0 -1
- package/dist/simple-tree/api/view.js.map +0 -1
- package/lib/shared-tree/treeApi.d.ts.map +0 -1
- package/lib/shared-tree/treeApi.js.map +0 -1
- package/lib/shared-tree/treeApiAlpha.d.ts.map +0 -1
- package/lib/shared-tree/treeApiAlpha.js.map +0 -1
- package/lib/simple-tree/api/treeApiBeta.d.ts.map +0 -1
- package/lib/simple-tree/api/treeApiBeta.js.map +0 -1
- package/lib/simple-tree/api/view.d.ts.map +0 -1
- package/lib/simple-tree/api/view.js.map +0 -1
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
7
6
|
import type { IFluidLoadable, IDisposable, Listenable } from "@fluidframework/core-interfaces";
|
|
8
|
-
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
7
|
|
|
10
8
|
import type {
|
|
11
9
|
CommitMetadata,
|
|
@@ -19,28 +17,17 @@ import type {
|
|
|
19
17
|
TreeAlpha,
|
|
20
18
|
} from "../../shared-tree/index.js";
|
|
21
19
|
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type UnsafeUnknownSchema,
|
|
31
|
-
FieldKind,
|
|
32
|
-
markSchemaMostDerived,
|
|
33
|
-
normalizeFieldSchema,
|
|
20
|
+
import type {
|
|
21
|
+
ImplicitFieldSchema,
|
|
22
|
+
InsertableField,
|
|
23
|
+
InsertableTreeFieldFromImplicitField,
|
|
24
|
+
ReadableField,
|
|
25
|
+
ReadSchema,
|
|
26
|
+
TreeFieldFromImplicitField,
|
|
27
|
+
UnsafeUnknownSchema,
|
|
34
28
|
} from "../schemaTypes.js";
|
|
35
|
-
import { NodeKind, type TreeNodeSchema } from "../core/index.js";
|
|
36
|
-
import { toStoredSchema } from "../toStoredSchema.js";
|
|
37
|
-
import { LeafNodeSchema } from "../leafNodeSchema.js";
|
|
38
|
-
import { isObjectNodeSchema, type ObjectNodeSchema } from "../objectNodeTypes.js";
|
|
39
|
-
import { getOrCreate } from "../../util/index.js";
|
|
40
|
-
import type { MakeNominal } from "../../util/index.js";
|
|
41
|
-
import { walkFieldSchema } from "../walkFieldSchema.js";
|
|
42
29
|
import type { VerboseTree } from "./verboseTree.js";
|
|
43
|
-
import type {
|
|
30
|
+
import type { SimpleTreeSchema } from "../simpleSchema.js";
|
|
44
31
|
import type {
|
|
45
32
|
RunTransactionParams,
|
|
46
33
|
TransactionCallbackStatus,
|
|
@@ -48,12 +35,14 @@ import type {
|
|
|
48
35
|
TransactionResultExt,
|
|
49
36
|
VoidTransactionCallbackStatus,
|
|
50
37
|
} from "./transactionTypes.js";
|
|
38
|
+
import type { TreeViewConfiguration } from "./configuration.js";
|
|
39
|
+
|
|
51
40
|
/**
|
|
52
41
|
* A tree from which a {@link TreeView} can be created.
|
|
53
42
|
*
|
|
54
43
|
* @privateRemarks
|
|
55
44
|
* TODO:
|
|
56
|
-
* Add stored key versions of {@link TreeAlpha.(exportVerbose:2)}, {@link TreeAlpha.(exportConcise:2)} and {@link TreeAlpha.exportCompressed} here so tree content can be accessed without a view schema.
|
|
45
|
+
* Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.
|
|
57
46
|
* Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).
|
|
58
47
|
* Maybe rename "exportJsonSchema" to align on "concise" terminology.
|
|
59
48
|
* Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).
|
|
@@ -99,7 +88,7 @@ export interface ITree extends ViewableTree, IFluidLoadable {}
|
|
|
99
88
|
*/
|
|
100
89
|
export interface ITreeAlpha extends ITree {
|
|
101
90
|
/**
|
|
102
|
-
* Exports root in the same format as {@link TreeAlpha.(exportVerbose:1)} using stored keys.
|
|
91
|
+
* Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.
|
|
103
92
|
* @remarks
|
|
104
93
|
* This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).
|
|
105
94
|
*/
|
|
@@ -113,336 +102,6 @@ export interface ITreeAlpha extends ITree {
|
|
|
113
102
|
exportSimpleSchema(): SimpleTreeSchema;
|
|
114
103
|
}
|
|
115
104
|
|
|
116
|
-
/**
|
|
117
|
-
* Options when constructing a tree view.
|
|
118
|
-
* @public
|
|
119
|
-
*/
|
|
120
|
-
export interface ITreeConfigurationOptions {
|
|
121
|
-
/**
|
|
122
|
-
* If `true`, the tree will validate new content against its stored schema at insertion time
|
|
123
|
-
* and throw an error if the new content doesn't match the expected schema.
|
|
124
|
-
*
|
|
125
|
-
* @defaultValue `false`.
|
|
126
|
-
*
|
|
127
|
-
* @remarks Enabling schema validation has a performance penalty when inserting new content into the tree because
|
|
128
|
-
* additional checks are done. Enable this option only in scenarios where you are ok with that operation being a
|
|
129
|
-
* bit slower.
|
|
130
|
-
*/
|
|
131
|
-
enableSchemaValidation?: boolean;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.
|
|
135
|
-
* @defaultValue `false`.
|
|
136
|
-
*
|
|
137
|
-
* @remarks
|
|
138
|
-
* When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.
|
|
139
|
-
*
|
|
140
|
-
* This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous.
|
|
141
|
-
* This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and {@link @fluidframework/core-interfaces#IFluidHandle}s.
|
|
142
|
-
* It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible).
|
|
143
|
-
* Currently these cases can cause ambiguity in a union:
|
|
144
|
-
*
|
|
145
|
-
* - More than one ArrayNode type: it's impossible to tell which array type is intended in the case of empty arrays (`[]`).
|
|
146
|
-
*
|
|
147
|
-
* - More than one MapNode type: it's impossible to tell which map type is intended in the case of an empty map (`{}`).
|
|
148
|
-
*
|
|
149
|
-
* - Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.
|
|
150
|
-
*
|
|
151
|
-
* - Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.
|
|
152
|
-
*
|
|
153
|
-
* - ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.
|
|
154
|
-
*
|
|
155
|
-
* This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible.
|
|
156
|
-
* This check may become more permissive over time.
|
|
157
|
-
*
|
|
158
|
-
* @example Ambiguous schema (with `preventAmbiguity: false`), and how to disambiguate it using {@link Unhydrated} nodes:
|
|
159
|
-
* ```typescript
|
|
160
|
-
* const schemaFactory = new SchemaFactory("com.example");
|
|
161
|
-
* class Feet extends schemaFactory.object("Feet", { length: schemaFactory.number }) {}
|
|
162
|
-
* class Meters extends schemaFactory.object("Meters", { length: schemaFactory.number }) {}
|
|
163
|
-
* const config = new TreeViewConfiguration({
|
|
164
|
-
* // This combination of schema can lead to ambiguous cases and will error if `preventAmbiguity` is true.
|
|
165
|
-
* schema: [Feet, Meters],
|
|
166
|
-
* preventAmbiguity: false,
|
|
167
|
-
* });
|
|
168
|
-
* const view = tree.viewWith(config);
|
|
169
|
-
* // This is invalid since it is ambiguous which type of node is being constructed:
|
|
170
|
-
* // view.initialize({ length: 5 });
|
|
171
|
-
* // To work, an explicit type can be provided by using an {@link Unhydrated} Node:
|
|
172
|
-
* view.initialize(new Meters({ length: 5 }));
|
|
173
|
-
* ```
|
|
174
|
-
*
|
|
175
|
-
* @example Schema disambiguated by adjusting field names, validated with `preventAmbiguity: true:`
|
|
176
|
-
* ```typescript
|
|
177
|
-
* const schemaFactory = new SchemaFactory("com.example");
|
|
178
|
-
* class Feet extends schemaFactory.object("Feet", { length: schemaFactory.number }) {}
|
|
179
|
-
* class Meters extends schemaFactory.object("Meters", {
|
|
180
|
-
* // To avoid ambiguity when parsing unions of Feet and Meters, this renames the length field to "meters".
|
|
181
|
-
* // To preserve compatibility with existing data from the ambiguous case,
|
|
182
|
-
* // `{ key: "length" }` is set, so when persisted in the tree "length" is used as the field name.
|
|
183
|
-
* meters: schemaFactory.required(schemaFactory.number, { key: "length" }),
|
|
184
|
-
* }) {}
|
|
185
|
-
* const config = new TreeViewConfiguration({
|
|
186
|
-
* // This combination of schema is not ambiguous because `Feet` and `Meters` have different required keys.
|
|
187
|
-
* schema: [Feet, Meters],
|
|
188
|
-
* preventAmbiguity: true,
|
|
189
|
-
* });
|
|
190
|
-
* const view = tree.viewWith(config);
|
|
191
|
-
* // This now works, since the field is sufficient to determine this is a `Meters` node.
|
|
192
|
-
* view.initialize({ meters: 5 });
|
|
193
|
-
* ```
|
|
194
|
-
*
|
|
195
|
-
* @privateRemarks
|
|
196
|
-
* In the future, we can support lossless round tripping via the canonical JSON-like representation above when unambiguous.
|
|
197
|
-
* This could be done via methods added to `Tree` to export and import such objects, which would give us a place to explicitly define the type of this representation.
|
|
198
|
-
*
|
|
199
|
-
* To make this more permissive in the future we can:
|
|
200
|
-
*
|
|
201
|
-
* - Make toMapTree more permissive (ex: allow disambiguation based on leaf type)
|
|
202
|
-
* - Update this check to more tightly match toMapTree
|
|
203
|
-
* - Add options to help schema authors disambiguate their types, such as "constant fields" which are not persisted, and always have a constant value.
|
|
204
|
-
*
|
|
205
|
-
* The above examples exist in executable form in this files tests, and should be updated there then copied back here.
|
|
206
|
-
*/
|
|
207
|
-
readonly preventAmbiguity?: boolean;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const defaultTreeConfigurationOptions: Required<ITreeConfigurationOptions> = {
|
|
211
|
-
enableSchemaValidation: false,
|
|
212
|
-
preventAmbiguity: false,
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Property-bag configuration for {@link TreeViewConfiguration} construction.
|
|
217
|
-
* @public
|
|
218
|
-
*/
|
|
219
|
-
export interface ITreeViewConfiguration<
|
|
220
|
-
TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
|
|
221
|
-
> extends ITreeConfigurationOptions {
|
|
222
|
-
/**
|
|
223
|
-
* The schema which the application wants to view the tree with.
|
|
224
|
-
*/
|
|
225
|
-
readonly schema: TSchema;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Configuration for {@link ViewableTree.viewWith}.
|
|
230
|
-
* @sealed @public
|
|
231
|
-
*/
|
|
232
|
-
export class TreeViewConfiguration<
|
|
233
|
-
const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
|
|
234
|
-
> implements Required<ITreeViewConfiguration<TSchema>>
|
|
235
|
-
{
|
|
236
|
-
protected _typeCheck!: MakeNominal;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* {@inheritDoc ITreeViewConfiguration.schema}
|
|
240
|
-
*/
|
|
241
|
-
public readonly schema: TSchema;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* {@inheritDoc ITreeConfigurationOptions.enableSchemaValidation}
|
|
245
|
-
*/
|
|
246
|
-
public readonly enableSchemaValidation: boolean;
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* {@inheritDoc ITreeConfigurationOptions.preventAmbiguity}
|
|
250
|
-
*/
|
|
251
|
-
public readonly preventAmbiguity: boolean;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Construct a new {@link TreeViewConfiguration}.
|
|
255
|
-
*
|
|
256
|
-
* @param props - Property bag of configuration options.
|
|
257
|
-
*
|
|
258
|
-
* @remarks
|
|
259
|
-
* Performing this construction deeply validates the provided schema.
|
|
260
|
-
* This means that when this constructor is called, all {@link LazyItem} {@link TreeNodeSchema} references will be evaluated (using {@link evaluateLazySchema}).
|
|
261
|
-
* This means that the declarations for all transitively reachable {@link TreeNodeSchema} must be available at this time.
|
|
262
|
-
*
|
|
263
|
-
* For example, a schema reachable from this configuration cannot reference this configuration during its declaration,
|
|
264
|
-
* since this would be a cyclic dependency that will cause an error when constructing this configuration.
|
|
265
|
-
*/
|
|
266
|
-
public constructor(props: ITreeViewConfiguration<TSchema>) {
|
|
267
|
-
const config = { ...defaultTreeConfigurationOptions, ...props };
|
|
268
|
-
this.schema = config.schema;
|
|
269
|
-
this.enableSchemaValidation = config.enableSchemaValidation;
|
|
270
|
-
this.preventAmbiguity = config.preventAmbiguity;
|
|
271
|
-
|
|
272
|
-
// Ambiguity errors are lower priority to report than invalid schema errors, so collect these in an array and report them all at once.
|
|
273
|
-
const ambiguityErrors: string[] = [];
|
|
274
|
-
|
|
275
|
-
walkFieldSchema(config.schema, {
|
|
276
|
-
// Ensure all reachable schema are marked as most derived.
|
|
277
|
-
// This ensures if multiple schema extending the same schema factory generated class are present (or have been constructed, or get constructed in the future),
|
|
278
|
-
// an error is reported.
|
|
279
|
-
|
|
280
|
-
node: (schema) => markSchemaMostDerived(schema, true),
|
|
281
|
-
allowedTypes(types): void {
|
|
282
|
-
if (config.preventAmbiguity) {
|
|
283
|
-
checkUnion(types, ambiguityErrors);
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
if (ambiguityErrors.length !== 0) {
|
|
289
|
-
// Duplicate errors are common since when two types conflict, both orders error:
|
|
290
|
-
const deduplicated = new Set(ambiguityErrors);
|
|
291
|
-
throw new UsageError(`Ambiguous schema found:\n${[...deduplicated].join("\n")}`);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Eagerly perform this conversion to surface errors sooner.
|
|
295
|
-
toStoredSchema(config.schema);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* {@link TreeViewConfiguration} extended with some alpha APIs.
|
|
301
|
-
* @sealed @alpha
|
|
302
|
-
*/
|
|
303
|
-
export class TreeViewConfigurationAlpha<
|
|
304
|
-
const TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
|
|
305
|
-
>
|
|
306
|
-
extends TreeViewConfiguration<TSchema>
|
|
307
|
-
implements TreeSchema
|
|
308
|
-
{
|
|
309
|
-
/**
|
|
310
|
-
* {@inheritDoc TreeSchema.root}
|
|
311
|
-
*/
|
|
312
|
-
public readonly root: FieldSchemaAlpha;
|
|
313
|
-
/**
|
|
314
|
-
* {@inheritDoc TreeSchema.definitions}
|
|
315
|
-
*/
|
|
316
|
-
public readonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
|
|
317
|
-
|
|
318
|
-
public constructor(props: ITreeViewConfiguration<TSchema>) {
|
|
319
|
-
super(props);
|
|
320
|
-
this.root = normalizeFieldSchema(props.schema);
|
|
321
|
-
const definitions = new Map<string, SimpleNodeSchema & TreeNodeSchema>();
|
|
322
|
-
walkFieldSchema(props.schema, {
|
|
323
|
-
node: (schema) =>
|
|
324
|
-
definitions.set(schema.identifier, schema as SimpleNodeSchema & TreeNodeSchema),
|
|
325
|
-
});
|
|
326
|
-
this.definitions = definitions;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* {@link TreeViewConfigurationAlpha}
|
|
332
|
-
* @sealed @alpha
|
|
333
|
-
*/
|
|
334
|
-
export interface TreeSchema extends SimpleTreeSchema {
|
|
335
|
-
/**
|
|
336
|
-
* {@inheritDoc SimpleTreeSchema.root}
|
|
337
|
-
*/
|
|
338
|
-
readonly root: FieldSchemaAlpha;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* {@inheritDoc SimpleTreeSchema.definitions}
|
|
342
|
-
*/
|
|
343
|
-
readonly definitions: ReadonlyMap<string, SimpleNodeSchema & TreeNodeSchema>;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Pretty print a set of types for use in error messages.
|
|
348
|
-
*/
|
|
349
|
-
function formatTypes(allowed: Iterable<TreeNodeSchema>): string {
|
|
350
|
-
// Use JSON.stringify to quote and escape identifiers.
|
|
351
|
-
// Don't just use a single array JSON.stringify since that omits spaces between items
|
|
352
|
-
return `[${Array.from(allowed, (s) => JSON.stringify(s.identifier)).join(", ")}]`;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Detect cases documented in {@link ITreeConfigurationOptions.preventAmbiguity}.
|
|
357
|
-
*/
|
|
358
|
-
export function checkUnion(union: Iterable<TreeNodeSchema>, errors: string[]): void {
|
|
359
|
-
const checked: Set<TreeNodeSchema> = new Set();
|
|
360
|
-
const maps: TreeNodeSchema[] = [];
|
|
361
|
-
const arrays: TreeNodeSchema[] = [];
|
|
362
|
-
|
|
363
|
-
const objects: ObjectNodeSchema[] = [];
|
|
364
|
-
// Map from key to schema using that key
|
|
365
|
-
const allObjectKeys: Map<string, Set<TreeNodeSchema>> = new Map();
|
|
366
|
-
|
|
367
|
-
for (const schema of union) {
|
|
368
|
-
if (checked.has(schema)) {
|
|
369
|
-
throw new UsageError(`Duplicate schema in allowed types: ${schema.identifier}`);
|
|
370
|
-
}
|
|
371
|
-
checked.add(schema);
|
|
372
|
-
|
|
373
|
-
if (schema instanceof LeafNodeSchema) {
|
|
374
|
-
// nothing to do
|
|
375
|
-
} else if (isObjectNodeSchema(schema)) {
|
|
376
|
-
objects.push(schema);
|
|
377
|
-
for (const key of schema.fields.keys()) {
|
|
378
|
-
getOrCreate(allObjectKeys, key, () => new Set()).add(schema);
|
|
379
|
-
}
|
|
380
|
-
} else if (schema.kind === NodeKind.Array) {
|
|
381
|
-
arrays.push(schema);
|
|
382
|
-
} else {
|
|
383
|
-
assert(schema.kind === NodeKind.Map, 0x9e7 /* invalid schema */);
|
|
384
|
-
maps.push(schema);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (arrays.length > 1) {
|
|
389
|
-
errors.push(
|
|
390
|
-
`More than one kind of array allowed within union (${formatTypes(arrays)}). This would require type disambiguation which is not supported by arrays during import or export.`,
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (maps.length > 1) {
|
|
395
|
-
errors.push(
|
|
396
|
-
`More than one kind of map allowed within union (${formatTypes(maps)}). This would require type disambiguation which is not supported by maps during import or export.`,
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (maps.length > 0 && arrays.length > 0) {
|
|
401
|
-
errors.push(
|
|
402
|
-
`Both a map and an array allowed within union (${formatTypes([...arrays, ...maps])}). Both can be implicitly constructed from iterables like arrays, which are ambiguous when the array is empty.`,
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (objects.length > 0 && maps.length > 0) {
|
|
407
|
-
errors.push(
|
|
408
|
-
`Both a object and a map allowed within union (${formatTypes([...objects, ...maps])}). Both can be constructed from objects and can be ambiguous.`,
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Check for objects which fully overlap:
|
|
413
|
-
for (const schema of objects) {
|
|
414
|
-
// All objects which might be ambiguous relative to `schema`.
|
|
415
|
-
const possiblyAmbiguous = new Set(objects);
|
|
416
|
-
|
|
417
|
-
// A schema can't be ambiguous with itself
|
|
418
|
-
possiblyAmbiguous.delete(schema);
|
|
419
|
-
|
|
420
|
-
// For each field of schema, remove schema from possiblyAmbiguous that do not have that field
|
|
421
|
-
for (const [key, field] of schema.fields) {
|
|
422
|
-
if (field.kind === FieldKind.Required) {
|
|
423
|
-
const withKey = allObjectKeys.get(key) ?? fail(0xb35 /* missing schema */);
|
|
424
|
-
for (const candidate of possiblyAmbiguous) {
|
|
425
|
-
if (!withKey.has(candidate)) {
|
|
426
|
-
possiblyAmbiguous.delete(candidate);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (possiblyAmbiguous.size > 0) {
|
|
433
|
-
// TODO: make this check more permissive.
|
|
434
|
-
// Allow using the type of the field to disambiguate, at least for leaf types.
|
|
435
|
-
// Add "constant" fields which can be used to disambiguate even more cases without adding persisted data: maybe make them optional in constructor?
|
|
436
|
-
// Consider separating unambiguous implicit construction format from constructor arguments at type level, allowing constructor to superset the implicit construction options (ex: optional constant fields).
|
|
437
|
-
// The policy here however must remain at least as conservative as shallowCompatibilityTest in src/simple-tree/toMapTree.ts.
|
|
438
|
-
|
|
439
|
-
errors.push(
|
|
440
|
-
`The required fields of ${JSON.stringify(schema.identifier)} are insufficient to differentiate it from the following types: ${formatTypes(possiblyAmbiguous)}. For objects to be considered unambiguous, each must have required fields that do not all occur on any other object in the union.`,
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
105
|
/**
|
|
447
106
|
* A collection of functionality associated with a (version-control-style) branch of a SharedTree.
|
|
448
107
|
* @remarks A `TreeBranch` allows for the {@link TreeBranch.fork | creation of branches} and for those branches to later be {@link TreeBranch.merge | merged}.
|
|
@@ -16,6 +16,9 @@ import { treeNodeApi } from "./treeNodeApi.js";
|
|
|
16
16
|
import { createFromCursor } from "./create.js";
|
|
17
17
|
import type { ImplicitFieldSchema, TreeFieldFromImplicitField } from "../schemaTypes.js";
|
|
18
18
|
|
|
19
|
+
// Tests for this file are grouped with those for treeNodeApi.ts as that is where this functionality will eventually land,
|
|
20
|
+
// and where most of the actual implementation is for much of it.
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
* Data included for {@link TreeChangeEventsBeta.nodeChanged}.
|
|
21
24
|
* @sealed @beta
|
|
@@ -89,10 +92,12 @@ export interface TreeChangeEventsBeta<TNode extends TreeNode = TreeNode>
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
/**
|
|
92
|
-
* Extensions to {@link Tree} which are not yet stable.
|
|
93
|
-
* @
|
|
95
|
+
* Extensions to {@link (Tree:interface)} which are not yet stable.
|
|
96
|
+
* @remarks
|
|
97
|
+
* Use via the {@link (TreeBeta:variable)} singleton.
|
|
98
|
+
* @system @sealed @beta
|
|
94
99
|
*/
|
|
95
|
-
export
|
|
100
|
+
export interface TreeBeta {
|
|
96
101
|
/**
|
|
97
102
|
* Register an event listener on the given node.
|
|
98
103
|
* @param node - The node whose events should be subscribed to.
|
|
@@ -142,7 +147,14 @@ export const TreeBeta: {
|
|
|
142
147
|
// replaceIdentifiers?: true;
|
|
143
148
|
// },
|
|
144
149
|
// ): TreeFieldFromImplicitField<TSchema>;
|
|
145
|
-
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Extensions to {@link (Tree:variable)} which are not yet stable.
|
|
154
|
+
* @see {@link (TreeBeta:interface)}.
|
|
155
|
+
* @beta
|
|
156
|
+
*/
|
|
157
|
+
export const TreeBeta: TreeBeta = {
|
|
146
158
|
on<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(
|
|
147
159
|
node: TNode,
|
|
148
160
|
eventName: K,
|
|
@@ -153,7 +165,7 @@ export const TreeBeta: {
|
|
|
153
165
|
clone<const TSchema extends ImplicitFieldSchema>(
|
|
154
166
|
node: TreeFieldFromImplicitField<TSchema>,
|
|
155
167
|
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
156
|
-
|
|
168
|
+
// The only non-TreeNode cases are {@link TreeLeafValue} and `undefined` (for an empty optional field) which can be returned as is.
|
|
157
169
|
if (!isTreeNode(node)) {
|
|
158
170
|
return node;
|
|
159
171
|
}
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
IsUnion,
|
|
8
|
+
RestrictiveStringRecord,
|
|
9
|
+
UnionToIntersection,
|
|
10
|
+
} from "../../util/index.js";
|
|
7
11
|
|
|
8
12
|
import type {
|
|
9
13
|
ApplyKind,
|
|
@@ -239,16 +243,16 @@ export namespace System_Unsafe {
|
|
|
239
243
|
* of the JsonAsTree schema.
|
|
240
244
|
* @system @public
|
|
241
245
|
*/
|
|
242
|
-
export type InsertableTreeNodeFromAllowedTypesUnsafe<TList extends AllowedTypesUnsafe> =
|
|
243
|
-
TList
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
export type InsertableTreeNodeFromAllowedTypesUnsafe<TList extends AllowedTypesUnsafe> =
|
|
247
|
+
IsUnion<TList> extends true
|
|
248
|
+
? never
|
|
249
|
+
: {
|
|
250
|
+
readonly [Property in keyof TList]: TList[Property] extends LazyItem<
|
|
251
|
+
infer TSchema extends TreeNodeSchemaUnsafe
|
|
252
|
+
>
|
|
253
|
+
? InsertableTypedNodeUnsafe<TSchema>
|
|
254
|
+
: never;
|
|
255
|
+
}[number];
|
|
252
256
|
|
|
253
257
|
/**
|
|
254
258
|
* {@link Unenforced} version of {@link InsertableTypedNode}.
|
|
@@ -16,11 +16,14 @@ import {
|
|
|
16
16
|
import { prepareContentForHydration } from "./proxies.js";
|
|
17
17
|
import {
|
|
18
18
|
normalizeAllowedTypes,
|
|
19
|
+
unannotateImplicitAllowedTypes,
|
|
19
20
|
type ImplicitAllowedTypes,
|
|
21
|
+
type ImplicitAnnotatedAllowedTypes,
|
|
20
22
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
21
23
|
type NodeSchemaMetadata,
|
|
22
24
|
type TreeLeafValue,
|
|
23
25
|
type TreeNodeFromImplicitAllowedTypes,
|
|
26
|
+
type UnannotateImplicitAllowedTypes,
|
|
24
27
|
} from "./schemaTypes.js";
|
|
25
28
|
import {
|
|
26
29
|
type WithType,
|
|
@@ -1064,7 +1067,7 @@ abstract class CustomArrayNodeBase<const T extends ImplicitAllowedTypes>
|
|
|
1064
1067
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
1065
1068
|
export function arraySchema<
|
|
1066
1069
|
TName extends string,
|
|
1067
|
-
const T extends
|
|
1070
|
+
const T extends ImplicitAnnotatedAllowedTypes,
|
|
1068
1071
|
const ImplicitlyConstructable extends boolean,
|
|
1069
1072
|
const TCustomMetadata = unknown,
|
|
1070
1073
|
>(
|
|
@@ -1082,7 +1085,9 @@ export function arraySchema<
|
|
|
1082
1085
|
> &
|
|
1083
1086
|
ArrayNodePojoEmulationSchema<TName, T, ImplicitlyConstructable, TCustomMetadata>;
|
|
1084
1087
|
|
|
1085
|
-
const
|
|
1088
|
+
const unannotatedTypes = unannotateImplicitAllowedTypes(info);
|
|
1089
|
+
|
|
1090
|
+
const lazyChildTypes = new Lazy(() => normalizeAllowedTypes(unannotatedTypes));
|
|
1086
1091
|
const lazyAllowedTypesIdentifiers = new Lazy(
|
|
1087
1092
|
() => new Set([...lazyChildTypes.value].map((type) => type.identifier)),
|
|
1088
1093
|
);
|
|
@@ -1091,7 +1096,7 @@ export function arraySchema<
|
|
|
1091
1096
|
|
|
1092
1097
|
// This class returns a proxy from its constructor to handle numeric indexing.
|
|
1093
1098
|
// Alternatively it could extend a normal class which gets tons of numeric properties added.
|
|
1094
|
-
class Schema extends CustomArrayNodeBase<T
|
|
1099
|
+
class Schema extends CustomArrayNodeBase<UnannotateImplicitAllowedTypes<T>> {
|
|
1095
1100
|
public static override prepareInstance<T2>(
|
|
1096
1101
|
this: typeof TreeNodeValid<T2>,
|
|
1097
1102
|
instance: TreeNodeValid<T2>,
|
|
@@ -1178,8 +1183,8 @@ export function arraySchema<
|
|
|
1178
1183
|
return Schema.constructorCached?.constructor as unknown as Output;
|
|
1179
1184
|
}
|
|
1180
1185
|
|
|
1181
|
-
protected get simpleSchema(): T {
|
|
1182
|
-
return
|
|
1186
|
+
protected get simpleSchema(): UnannotateImplicitAllowedTypes<T> {
|
|
1187
|
+
return unannotatedTypes;
|
|
1183
1188
|
}
|
|
1184
1189
|
protected get allowedTypes(): ReadonlySet<TreeNodeSchema> {
|
|
1185
1190
|
return lazyChildTypes.value;
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import type { TreeArrayNode } from "./arrayNode.js";
|
|
7
7
|
import type {
|
|
8
|
-
|
|
8
|
+
ImplicitAnnotatedAllowedTypes,
|
|
9
9
|
InsertableTreeNodeFromImplicitAllowedTypes,
|
|
10
|
+
UnannotateImplicitAllowedTypes,
|
|
10
11
|
} from "./schemaTypes.js";
|
|
11
12
|
import {
|
|
12
13
|
NodeKind,
|
|
@@ -24,14 +25,14 @@ import type { SimpleArrayNodeSchema } from "./simpleSchema.js";
|
|
|
24
25
|
*/
|
|
25
26
|
export interface ArrayNodeCustomizableSchema<
|
|
26
27
|
out TName extends string = string,
|
|
27
|
-
in out T extends
|
|
28
|
+
in out T extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes,
|
|
28
29
|
out ImplicitlyConstructable extends boolean = true,
|
|
29
30
|
out TCustomMetadata = unknown,
|
|
30
31
|
> extends TreeNodeSchemaClass<
|
|
31
32
|
TName,
|
|
32
33
|
NodeKind.Array,
|
|
33
|
-
TreeArrayNode<T
|
|
34
|
-
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T
|
|
34
|
+
TreeArrayNode<UnannotateImplicitAllowedTypes<T>> & WithType<TName, NodeKind.Array, T>,
|
|
35
|
+
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<UnannotateImplicitAllowedTypes<T>>>,
|
|
35
36
|
ImplicitlyConstructable,
|
|
36
37
|
T,
|
|
37
38
|
undefined,
|
|
@@ -45,14 +46,14 @@ export interface ArrayNodeCustomizableSchema<
|
|
|
45
46
|
*/
|
|
46
47
|
export interface ArrayNodePojoEmulationSchema<
|
|
47
48
|
out TName extends string = string,
|
|
48
|
-
in out T extends
|
|
49
|
+
in out T extends ImplicitAnnotatedAllowedTypes = ImplicitAnnotatedAllowedTypes,
|
|
49
50
|
out ImplicitlyConstructable extends boolean = true,
|
|
50
51
|
out TCustomMetadata = unknown,
|
|
51
52
|
> extends TreeNodeSchemaNonClass<
|
|
52
53
|
TName,
|
|
53
54
|
NodeKind.Array,
|
|
54
|
-
TreeArrayNode<T
|
|
55
|
-
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T
|
|
55
|
+
TreeArrayNode<UnannotateImplicitAllowedTypes<T>> & WithType<TName, NodeKind.Array, T>,
|
|
56
|
+
Iterable<InsertableTreeNodeFromImplicitAllowedTypes<UnannotateImplicitAllowedTypes<T>>>,
|
|
56
57
|
ImplicitlyConstructable,
|
|
57
58
|
T,
|
|
58
59
|
undefined,
|
package/src/simple-tree/index.ts
CHANGED
|
@@ -81,7 +81,7 @@ export {
|
|
|
81
81
|
comparePersistedSchema,
|
|
82
82
|
type ConciseTree,
|
|
83
83
|
comparePersistedSchemaInternal,
|
|
84
|
-
|
|
84
|
+
SchemaCompatibilityTester,
|
|
85
85
|
type Unenforced,
|
|
86
86
|
type System_Unsafe,
|
|
87
87
|
type ArrayNodeCustomizableSchemaUnsafe,
|
|
@@ -120,6 +120,8 @@ export {
|
|
|
120
120
|
allowUnused,
|
|
121
121
|
type FieldSchemaAlphaUnsafe,
|
|
122
122
|
type TreeSchema,
|
|
123
|
+
type ValidateRecursiveSchemaTemplate,
|
|
124
|
+
type FixRecursiveRecursionLimit,
|
|
123
125
|
} from "./api/index.js";
|
|
124
126
|
export type {
|
|
125
127
|
SimpleTreeSchema,
|
|
@@ -135,13 +137,26 @@ export type {
|
|
|
135
137
|
export {
|
|
136
138
|
type NodeFromSchema,
|
|
137
139
|
isTreeNodeSchemaClass,
|
|
140
|
+
type AnnotatedAllowedType,
|
|
141
|
+
type AnnotatedAllowedTypes,
|
|
138
142
|
type ImplicitFieldSchema,
|
|
143
|
+
type ImplicitAnnotatedFieldSchema,
|
|
139
144
|
type TreeFieldFromImplicitField,
|
|
140
145
|
type ImplicitAllowedTypes,
|
|
146
|
+
type ImplicitAnnotatedAllowedTypes,
|
|
147
|
+
type UnannotateImplicitAllowedTypes,
|
|
148
|
+
type UnannotateAllowedTypes,
|
|
149
|
+
type UnannotateAllowedType,
|
|
150
|
+
type UnannotateAllowedTypesList,
|
|
151
|
+
type UnannotateAllowedTypeOrLazyItem,
|
|
152
|
+
type UnannotateImplicitFieldSchema,
|
|
153
|
+
type UnannotateSchemaRecord,
|
|
141
154
|
type TreeNodeFromImplicitAllowedTypes,
|
|
142
155
|
type InsertableTreeNodeFromImplicitAllowedTypes,
|
|
143
156
|
type TreeLeafValue,
|
|
144
157
|
type AllowedTypes,
|
|
158
|
+
type AllowedTypeMetadata,
|
|
159
|
+
type AllowedTypesMetadata,
|
|
145
160
|
FieldKind,
|
|
146
161
|
FieldSchema,
|
|
147
162
|
type FieldSchemaAlpha,
|
|
@@ -191,6 +206,7 @@ export {
|
|
|
191
206
|
type FieldHasDefault,
|
|
192
207
|
type InsertableObjectFromSchemaRecord,
|
|
193
208
|
type ObjectFromSchemaRecord,
|
|
209
|
+
type InsertableObjectFromAnnotatedSchemaRecord,
|
|
194
210
|
type TreeObjectNode,
|
|
195
211
|
setField,
|
|
196
212
|
createUnknownOptionalFieldPolicy,
|