@fluidframework/tree 2.21.0 → 2.22.1
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/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/api-report/tree.alpha.api.md +29 -4
- package/api-report/tree.beta.api.md +29 -4
- package/api-report/tree.legacy.alpha.api.md +29 -4
- package/api-report/tree.legacy.public.api.md +29 -4
- package/api-report/tree.public.api.md +29 -4
- package/dist/alpha.d.ts +1 -0
- package/dist/beta.d.ts +1 -0
- package/dist/core/forest/editableForest.js +1 -1
- package/dist/core/forest/editableForest.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts +2 -5
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +1 -151
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -2
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/pathTree.d.ts +0 -11
- package/dist/core/tree/pathTree.d.ts.map +1 -1
- package/dist/core/tree/pathTree.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/dist/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
- package/dist/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/treeEvents.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +0 -9
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -19
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +11 -12
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
- package/dist/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +7 -3
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -11
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -0
- package/dist/shared-tree/index.d.ts +1 -3
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +1 -7
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +4 -5
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +9 -10
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +39 -39
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +81 -52
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/treeApi.d.ts +2 -2
- package/dist/shared-tree/treeApi.d.ts.map +1 -1
- package/dist/shared-tree/treeApi.js +9 -3
- package/dist/shared-tree/treeApi.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +3 -3
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +3 -2
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManager.js +1 -1
- package/dist/shared-tree-core/editManager.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +1 -2
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +0 -9
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts +12 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.js +25 -7
- package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +25 -30
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +20 -49
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +156 -63
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +179 -86
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -0
- package/dist/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +23 -2
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/index.d.ts +1 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +3 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/schemaTypes.d.ts +2 -2
- package/dist/simple-tree/schemaTypes.js +1 -1
- package/dist/simple-tree/schemaTypes.js.map +1 -1
- package/dist/simple-tree/treeNodeValid.js +1 -2
- package/dist/simple-tree/treeNodeValid.js.map +1 -1
- package/dist/treeFactory.d.ts +16 -5
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +21 -12
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/breakable.d.ts +1 -1
- package/dist/util/breakable.d.ts.map +1 -1
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/rangeMap.d.ts +1 -1
- package/dist/util/rangeMap.js +1 -1
- package/dist/util/rangeMap.js.map +1 -1
- package/lib/alpha.d.ts +1 -0
- package/lib/beta.d.ts +1 -0
- package/lib/core/forest/editableForest.js +1 -1
- package/lib/core/forest/editableForest.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts +2 -5
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +1 -151
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -2
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/pathTree.d.ts +0 -11
- package/lib/core/tree/pathTree.d.ts.map +1 -1
- package/lib/core/tree/pathTree.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +1 -2
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js +0 -9
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/lib/feature-libraries/flex-tree/treeEvents.d.ts +2 -4
- package/lib/feature-libraries/flex-tree/treeEvents.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/treeEvents.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +1 -2
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +0 -9
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +6 -2
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts +2 -4
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -19
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +11 -12
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.js +1 -1
- package/lib/feature-libraries/node-key/mockNodeKeyManager.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +7 -3
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +3 -5
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +1 -11
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js +13 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldEditor.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -0
- package/lib/shared-tree/index.d.ts +1 -3
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +1 -3
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +4 -5
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +4 -5
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +39 -39
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +79 -50
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/treeApi.d.ts +2 -2
- package/lib/shared-tree/treeApi.d.ts.map +1 -1
- package/lib/shared-tree/treeApi.js +8 -2
- package/lib/shared-tree/treeApi.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +3 -3
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +4 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManager.js +2 -2
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +1 -2
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +0 -9
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts +12 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.js +23 -5
- package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +25 -30
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +19 -48
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +156 -63
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +178 -85
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/{shared-tree → simple-tree/api}/transactionTypes.d.ts +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -0
- package/lib/{shared-tree → simple-tree/api}/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +23 -2
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/index.d.ts +1 -1
- 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/schemaTypes.d.ts +2 -2
- package/lib/simple-tree/schemaTypes.js +1 -1
- package/lib/simple-tree/schemaTypes.js.map +1 -1
- package/lib/simple-tree/treeNodeValid.js +1 -2
- package/lib/simple-tree/treeNodeValid.js.map +1 -1
- package/lib/treeFactory.d.ts +16 -5
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +20 -11
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/breakable.d.ts +1 -1
- package/lib/util/breakable.d.ts.map +1 -1
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/rangeMap.d.ts +1 -1
- package/lib/util/rangeMap.js +1 -1
- package/lib/util/rangeMap.js.map +1 -1
- package/package.json +21 -21
- package/src/core/forest/editableForest.ts +1 -1
- package/src/core/index.ts +0 -3
- package/src/core/tree/anchorSet.ts +4 -197
- package/src/core/tree/index.ts +0 -3
- package/src/core/tree/pathTree.ts +0 -13
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -1
- package/src/feature-libraries/detachedFieldIndexSummarizer.ts +0 -11
- package/src/feature-libraries/flex-tree/treeEvents.ts +2 -4
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +0 -11
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +6 -2
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +3 -35
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +9 -42
- package/src/feature-libraries/optional-field/optionalField.ts +10 -3
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +1 -16
- package/src/feature-libraries/sequence-field/sequenceFieldEditor.ts +13 -2
- package/src/index.ts +15 -12
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/index.ts +3 -19
- package/src/shared-tree/schematizingTreeView.ts +18 -16
- package/src/shared-tree/sharedTree.ts +203 -100
- package/src/shared-tree/treeApi.ts +10 -1
- package/src/shared-tree/treeCheckout.ts +11 -8
- package/src/shared-tree-core/editManager.ts +2 -2
- package/src/shared-tree-core/editManagerSummarizer.ts +0 -11
- package/src/shared-tree-core/sequenceIdUtils.ts +26 -5
- package/src/shared-tree-core/sharedTreeCore.ts +30 -87
- package/src/simple-tree/api/index.ts +15 -0
- package/src/simple-tree/api/schemaFactory.ts +203 -89
- package/src/{shared-tree → simple-tree/api}/transactionTypes.ts +1 -1
- package/src/simple-tree/api/tree.ts +31 -6
- package/src/simple-tree/index.ts +12 -0
- package/src/simple-tree/schemaTypes.ts +2 -2
- package/src/treeFactory.ts +29 -11
- package/src/util/breakable.ts +1 -1
- package/src/util/rangeMap.ts +1 -1
- package/dist/core/tree/visitPath.d.ts +0 -101
- package/dist/core/tree/visitPath.d.ts.map +0 -1
- package/dist/core/tree/visitPath.js +0 -7
- package/dist/core/tree/visitPath.js.map +0 -1
- package/dist/shared-tree/publicContracts.d.ts +0 -18
- package/dist/shared-tree/publicContracts.d.ts.map +0 -1
- package/dist/shared-tree/publicContracts.js +0 -24
- package/dist/shared-tree/publicContracts.js.map +0 -1
- package/dist/shared-tree/transactionTypes.d.ts.map +0 -1
- package/lib/core/tree/visitPath.d.ts +0 -101
- package/lib/core/tree/visitPath.d.ts.map +0 -1
- package/lib/core/tree/visitPath.js +0 -6
- package/lib/core/tree/visitPath.js.map +0 -1
- package/lib/shared-tree/publicContracts.d.ts +0 -18
- package/lib/shared-tree/publicContracts.d.ts.map +0 -1
- package/lib/shared-tree/publicContracts.js +0 -21
- package/lib/shared-tree/publicContracts.js.map +0 -1
- package/lib/shared-tree/transactionTypes.d.ts.map +0 -1
- package/src/core/tree/visitPath.ts +0 -124
- package/src/shared-tree/publicContracts.ts +0 -24
- /package/dist/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
- /package/lib/{shared-tree → simple-tree/api}/transactionTypes.js +0 -0
|
@@ -4,24 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import type {
|
|
8
|
-
IChannelAttributes,
|
|
9
|
-
IFluidDataStoreRuntime,
|
|
10
|
-
IChannelStorageService,
|
|
11
|
-
} from "@fluidframework/datastore-definitions/internal";
|
|
7
|
+
import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
12
8
|
import type { IIdCompressor } from "@fluidframework/id-compressor";
|
|
13
9
|
import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
14
10
|
import type {
|
|
15
11
|
IExperimentalIncrementalSummaryContext,
|
|
16
|
-
IGarbageCollectionData,
|
|
17
12
|
ISummaryTreeWithStats,
|
|
18
13
|
ITelemetryContext,
|
|
19
14
|
} from "@fluidframework/runtime-definitions/internal";
|
|
20
15
|
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
|
|
21
|
-
import {
|
|
22
|
-
type IFluidSerializer,
|
|
23
|
-
SharedObject,
|
|
24
|
-
} from "@fluidframework/shared-object-base/internal";
|
|
16
|
+
import type { IFluidSerializer } from "@fluidframework/shared-object-base/internal";
|
|
25
17
|
|
|
26
18
|
import type { ICodecOptions, IJsonCodec } from "../codec/index.js";
|
|
27
19
|
import {
|
|
@@ -39,7 +31,7 @@ import {
|
|
|
39
31
|
import {
|
|
40
32
|
type JsonCompatibleReadOnly,
|
|
41
33
|
brand,
|
|
42
|
-
Breakable,
|
|
34
|
+
type Breakable,
|
|
43
35
|
type WithBreakable,
|
|
44
36
|
throwIfBroken,
|
|
45
37
|
breakingClass,
|
|
@@ -57,6 +49,8 @@ import type { ResubmitMachine } from "./resubmitMachine.js";
|
|
|
57
49
|
import { DefaultResubmitMachine } from "./defaultResubmitMachine.js";
|
|
58
50
|
import { BranchCommitEnricher } from "./branchCommitEnricher.js";
|
|
59
51
|
import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
|
|
52
|
+
import type { IFluidLoadable, ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
53
|
+
import type { IChannelView } from "../shared-tree/index.js";
|
|
60
54
|
|
|
61
55
|
// TODO: Organize this to be adjacent to persisted types.
|
|
62
56
|
const summarizablesTreeKey = "indexes";
|
|
@@ -75,11 +69,8 @@ export interface ClonableSchemaAndPolicy extends SchemaAndPolicy {
|
|
|
75
69
|
*/
|
|
76
70
|
@breakingClass
|
|
77
71
|
export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
78
|
-
extends SharedObject
|
|
79
72
|
implements WithBreakable
|
|
80
73
|
{
|
|
81
|
-
public readonly breaker: Breakable = new Breakable("Shared Tree");
|
|
82
|
-
|
|
83
74
|
private readonly editManager: EditManager<TEditor, TChange, ChangeFamily<TEditor, TChange>>;
|
|
84
75
|
private readonly summarizables: readonly [EditManagerSummarizer<TChange>, ...Summarizable[]];
|
|
85
76
|
/**
|
|
@@ -89,14 +80,6 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
89
80
|
*/
|
|
90
81
|
private detachedRevision: SeqNumber | undefined = minimumPossibleSequenceNumber;
|
|
91
82
|
|
|
92
|
-
/**
|
|
93
|
-
* Used to edit the state of the tree. Edits will be immediately applied locally to the tree.
|
|
94
|
-
* If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.
|
|
95
|
-
*/
|
|
96
|
-
public get editor(): TEditor {
|
|
97
|
-
return this.getLocalBranch().editor;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
83
|
/**
|
|
101
84
|
* Used to encode/decode messages sent to/received from the Fluid runtime.
|
|
102
85
|
*
|
|
@@ -113,12 +96,10 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
113
96
|
MessageEncodingContext
|
|
114
97
|
>;
|
|
115
98
|
|
|
116
|
-
private readonly idCompressor: IIdCompressor;
|
|
117
|
-
|
|
118
99
|
private readonly resubmitMachine: ResubmitMachine<TChange>;
|
|
119
|
-
|
|
100
|
+
public readonly commitEnricher: BranchCommitEnricher<TChange>;
|
|
120
101
|
|
|
121
|
-
|
|
102
|
+
public readonly mintRevisionTag: () => RevisionTag;
|
|
122
103
|
|
|
123
104
|
private readonly schemaAndPolicy: ClonableSchemaAndPolicy;
|
|
124
105
|
|
|
@@ -126,50 +107,44 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
126
107
|
* @param summarizables - Summarizers for all indexes used by this tree
|
|
127
108
|
* @param changeFamily - The change family
|
|
128
109
|
* @param editManager - The edit manager
|
|
129
|
-
* @param id - The id of the shared object
|
|
130
110
|
* @param runtime - The IFluidDataStoreRuntime which contains the shared object
|
|
131
|
-
* @param
|
|
132
|
-
*
|
|
111
|
+
* @param editor - Used to edit the state of the tree. Edits will be immediately applied locally to the tree.
|
|
112
|
+
* If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.
|
|
133
113
|
*/
|
|
134
114
|
public constructor(
|
|
115
|
+
public readonly breaker: Breakable,
|
|
116
|
+
public readonly sharedObject: IChannelView & IFluidLoadable,
|
|
117
|
+
public readonly serializer: IFluidSerializer,
|
|
118
|
+
public readonly submitLocalMessage: (content: unknown, localOpMetadata?: unknown) => void,
|
|
119
|
+
logger: ITelemetryBaseLogger | undefined,
|
|
135
120
|
summarizables: readonly Summarizable[],
|
|
136
121
|
changeFamily: ChangeFamily<TEditor, TChange>,
|
|
137
122
|
options: ICodecOptions,
|
|
138
123
|
formatOptions: ExplicitCoreCodecVersions,
|
|
139
|
-
|
|
140
|
-
id: string,
|
|
141
|
-
runtime: IFluidDataStoreRuntime,
|
|
142
|
-
attributes: IChannelAttributes,
|
|
143
|
-
telemetryContextPrefix: string,
|
|
124
|
+
private readonly idCompressor: IIdCompressor,
|
|
144
125
|
schema: TreeStoredSchemaRepository,
|
|
145
126
|
schemaPolicy: SchemaPolicy,
|
|
146
127
|
resubmitMachine?: ResubmitMachine<TChange>,
|
|
147
128
|
enricher?: ChangeEnricherReadonlyCheckout<TChange>,
|
|
129
|
+
public readonly getEditor: () => TEditor = () => this.getLocalBranch().editor,
|
|
148
130
|
) {
|
|
149
|
-
super(id, runtime, attributes, telemetryContextPrefix);
|
|
150
|
-
|
|
151
131
|
this.schemaAndPolicy = {
|
|
152
132
|
schema,
|
|
153
133
|
policy: schemaPolicy,
|
|
154
134
|
};
|
|
155
135
|
|
|
156
136
|
const rebaseLogger = createChildLogger({
|
|
157
|
-
logger
|
|
137
|
+
logger,
|
|
158
138
|
namespace: "Rebase",
|
|
159
139
|
});
|
|
160
140
|
|
|
161
|
-
assert(
|
|
162
|
-
runtime.idCompressor !== undefined,
|
|
163
|
-
0x886 /* IdCompressor must be enabled to use SharedTree */,
|
|
164
|
-
);
|
|
165
|
-
this.idCompressor = runtime.idCompressor;
|
|
166
141
|
this.mintRevisionTag = () => this.idCompressor.generateCompressedId();
|
|
167
142
|
/**
|
|
168
143
|
* A random ID that uniquely identifies this client in the collab session.
|
|
169
144
|
* This is sent alongside every op to identify which client the op originated from.
|
|
170
145
|
* This is used rather than the Fluid client ID because the Fluid client ID is not stable across reconnections.
|
|
171
146
|
*/
|
|
172
|
-
const localSessionId =
|
|
147
|
+
const localSessionId = idCompressor.localSessionId;
|
|
173
148
|
this.editManager = new EditManager(
|
|
174
149
|
changeFamily,
|
|
175
150
|
localSessionId,
|
|
@@ -189,7 +164,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
189
164
|
}
|
|
190
165
|
});
|
|
191
166
|
|
|
192
|
-
const revisionTagCodec = new RevisionTagCodec(
|
|
167
|
+
const revisionTagCodec = new RevisionTagCodec(idCompressor);
|
|
193
168
|
const editManagerCodec = makeEditManagerCodec(
|
|
194
169
|
this.editManager.changeFamily.codecs,
|
|
195
170
|
revisionTagCodec,
|
|
@@ -212,7 +187,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
212
187
|
|
|
213
188
|
this.messageCodec = makeMessageCodec(
|
|
214
189
|
changeFamily.codecs,
|
|
215
|
-
new RevisionTagCodec(
|
|
190
|
+
new RevisionTagCodec(idCompressor),
|
|
216
191
|
options,
|
|
217
192
|
formatOptions.message,
|
|
218
193
|
);
|
|
@@ -231,7 +206,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
231
206
|
// TODO: SharedObject's merging of the two summary methods into summarizeCore is not what we want here:
|
|
232
207
|
// We might want to not subclass it, or override/reimplement most of its functionality.
|
|
233
208
|
@throwIfBroken
|
|
234
|
-
|
|
209
|
+
public summarizeCore(
|
|
235
210
|
serializer: IFluidSerializer,
|
|
236
211
|
telemetryContext?: ITelemetryContext,
|
|
237
212
|
incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
|
|
@@ -243,7 +218,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
243
218
|
summarizableBuilder.addWithStats(
|
|
244
219
|
s.key,
|
|
245
220
|
s.getAttachSummary(
|
|
246
|
-
(contents) => serializer.stringify(contents, this.handle),
|
|
221
|
+
(contents) => serializer.stringify(contents, this.sharedObject.handle),
|
|
247
222
|
undefined,
|
|
248
223
|
undefined,
|
|
249
224
|
telemetryContext,
|
|
@@ -256,7 +231,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
256
231
|
return builder.getSummaryTree();
|
|
257
232
|
}
|
|
258
233
|
|
|
259
|
-
|
|
234
|
+
public async loadCore(services: IChannelStorageService): Promise<void> {
|
|
260
235
|
assert(
|
|
261
236
|
this.editManager.localBranch.getHead() === this.editManager.getTrunkHead(),
|
|
262
237
|
0xaaa /* All local changes should be applied to the trunk before loading from summary */,
|
|
@@ -311,7 +286,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
311
286
|
isResubmit: boolean,
|
|
312
287
|
): void {
|
|
313
288
|
assert(
|
|
314
|
-
this.isAttached() === (this.detachedRevision === undefined),
|
|
289
|
+
this.sharedObject.isAttached() === (this.detachedRevision === undefined),
|
|
315
290
|
0x95a /* Detached revision should only be set when not attached */,
|
|
316
291
|
);
|
|
317
292
|
|
|
@@ -352,7 +327,7 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
352
327
|
this.resubmitMachine.onCommitSubmitted(enrichedCommit);
|
|
353
328
|
}
|
|
354
329
|
|
|
355
|
-
|
|
330
|
+
public processCore(
|
|
356
331
|
message: ISequencedDocumentMessage,
|
|
357
332
|
local: boolean,
|
|
358
333
|
localOpMetadata: unknown,
|
|
@@ -372,22 +347,15 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
372
347
|
this.editManager.advanceMinimumSequenceNumber(brand(message.minimumSequenceNumber));
|
|
373
348
|
}
|
|
374
349
|
|
|
375
|
-
|
|
350
|
+
public getLocalBranch(): SharedTreeBranch<TEditor, TChange> {
|
|
376
351
|
return this.editManager.localBranch;
|
|
377
352
|
}
|
|
378
353
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
protected override didAttach(): void {
|
|
382
|
-
if (this.detachedRevision !== undefined) {
|
|
383
|
-
this.detachedRevision = undefined;
|
|
384
|
-
}
|
|
354
|
+
public didAttach(): void {
|
|
355
|
+
this.detachedRevision = undefined;
|
|
385
356
|
}
|
|
386
357
|
|
|
387
|
-
|
|
388
|
-
content: JsonCompatibleReadOnly,
|
|
389
|
-
localOpMetadata: unknown,
|
|
390
|
-
): void {
|
|
358
|
+
public reSubmitCore(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void {
|
|
391
359
|
// Empty context object is passed in, as our decode function is schema-agnostic.
|
|
392
360
|
const {
|
|
393
361
|
commit: { revision },
|
|
@@ -416,31 +384,13 @@ export class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange>
|
|
|
416
384
|
this.submitCommit(enrichedCommit, localOpMetadata, true);
|
|
417
385
|
}
|
|
418
386
|
|
|
419
|
-
|
|
387
|
+
public applyStashedOp(content: JsonCompatibleReadOnly): void {
|
|
420
388
|
// Empty context object is passed in, as our decode function is schema-agnostic.
|
|
421
389
|
const {
|
|
422
390
|
commit: { revision, change },
|
|
423
391
|
} = this.messageCodec.decode(content, { idCompressor: this.idCompressor });
|
|
424
392
|
this.editManager.localBranch.apply({ change, revision });
|
|
425
393
|
}
|
|
426
|
-
|
|
427
|
-
public override getGCData(fullGC?: boolean): IGarbageCollectionData {
|
|
428
|
-
const gcNodes: IGarbageCollectionData["gcNodes"] = super.getGCData(fullGC).gcNodes;
|
|
429
|
-
for (const s of this.summarizables) {
|
|
430
|
-
for (const [id, routes] of Object.entries(s.getGCData(fullGC).gcNodes)) {
|
|
431
|
-
gcNodes[id] ??= [];
|
|
432
|
-
for (const route of routes) {
|
|
433
|
-
// Non null asserting here because we are creating an array at gcNodes[id] if it is undefined
|
|
434
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
435
|
-
gcNodes[id]!.push(route);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return {
|
|
441
|
-
gcNodes,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
394
|
}
|
|
445
395
|
|
|
446
396
|
function isClonableSchemaPolicy(
|
|
@@ -482,13 +432,6 @@ export interface Summarizable {
|
|
|
482
432
|
telemetryContext?: ITelemetryContext,
|
|
483
433
|
): Promise<ISummaryTreeWithStats>;
|
|
484
434
|
|
|
485
|
-
/**
|
|
486
|
-
* {@inheritDoc (ISharedObject:interface).getGCData}
|
|
487
|
-
*/
|
|
488
|
-
// TODO: Change this interface (and the one in ISharedObject, if necessary) to support "handles within handles".
|
|
489
|
-
// Consider the case of a document with history; the return value here currently grows unboundedly.
|
|
490
|
-
getGCData(fullGC?: boolean): IGarbageCollectionData;
|
|
491
|
-
|
|
492
435
|
/**
|
|
493
436
|
* Allows the component to perform custom loading. The storage service is scoped to this component and therefore
|
|
494
437
|
* paths in this component will not collide with those in other components, even if they are the same string.
|
|
@@ -15,12 +15,14 @@ export {
|
|
|
15
15
|
type TreeViewAlpha,
|
|
16
16
|
type TreeBranch,
|
|
17
17
|
type TreeBranchEvents,
|
|
18
|
+
type ITreeAlpha,
|
|
18
19
|
asTreeViewAlpha,
|
|
19
20
|
} from "./tree.js";
|
|
20
21
|
export {
|
|
21
22
|
SchemaFactory,
|
|
22
23
|
type ScopedSchemaName,
|
|
23
24
|
type SchemaFactoryObjectOptions,
|
|
25
|
+
type schemaStatics,
|
|
24
26
|
} from "./schemaFactory.js";
|
|
25
27
|
export { SchemaFactoryAlpha } from "./schemaFactoryAlpha.js";
|
|
26
28
|
export type {
|
|
@@ -118,6 +120,19 @@ export {
|
|
|
118
120
|
comparePersistedSchema,
|
|
119
121
|
} from "./storedSchema.js";
|
|
120
122
|
|
|
123
|
+
export {
|
|
124
|
+
type TransactionConstraint,
|
|
125
|
+
type NodeInDocumentConstraint,
|
|
126
|
+
type RunTransactionParams,
|
|
127
|
+
type VoidTransactionCallbackStatus,
|
|
128
|
+
type TransactionCallbackStatus,
|
|
129
|
+
type TransactionResult,
|
|
130
|
+
type TransactionResultExt,
|
|
131
|
+
type TransactionResultSuccess,
|
|
132
|
+
type TransactionResultFailed,
|
|
133
|
+
rollback,
|
|
134
|
+
} from "./transactionTypes.js";
|
|
135
|
+
|
|
121
136
|
// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.
|
|
122
137
|
// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639
|
|
123
138
|
export {
|
|
@@ -171,6 +171,141 @@ export type ScopedSchemaName<
|
|
|
171
171
|
> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;
|
|
172
172
|
// > = `${TScope extends undefined ? "" : `${TScope}.`}${TName}`;
|
|
173
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Stateless APIs exposed via {@link SchemaFactory} as both instance properties and as statics.
|
|
176
|
+
* @privateRemarks
|
|
177
|
+
* We have no way to make linkable members which exist both as statics and instance properties since API-Extractor does not support this.
|
|
178
|
+
* As a workaround, we have this type as a third place which can be linked.
|
|
179
|
+
* @system @sealed @public
|
|
180
|
+
*/
|
|
181
|
+
export const schemaStatics = {
|
|
182
|
+
/**
|
|
183
|
+
* {@link TreeNodeSchema} for holding a JavaScript `string`.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
|
|
187
|
+
*
|
|
188
|
+
* These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
|
|
189
|
+
* JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
|
|
190
|
+
* @privateRemarks
|
|
191
|
+
* TODO:
|
|
192
|
+
* We should be much more clear about what happens if you use problematic values.
|
|
193
|
+
* We should validate and/or normalize them when inserting content.
|
|
194
|
+
*/
|
|
195
|
+
string: stringSchema,
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* {@link TreeNodeSchema} for holding a JavaScript `number`.
|
|
199
|
+
*
|
|
200
|
+
* @remarks
|
|
201
|
+
* The number is a {@link https://en.wikipedia.org/wiki/Double-precision_floating-point_format | double-precision 64-bit binary format IEEE 754} value, however there are some exceptions:
|
|
202
|
+
* - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
|
|
203
|
+
* - `-0` may be converted to `0` in some cases.
|
|
204
|
+
*
|
|
205
|
+
* These limitations match the limitations of JSON.
|
|
206
|
+
* @privateRemarks
|
|
207
|
+
* TODO:
|
|
208
|
+
* We should be much more clear about what happens if you use problematic values.
|
|
209
|
+
* We should validate and/or normalize them when inserting content.
|
|
210
|
+
*/
|
|
211
|
+
number: numberSchema,
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* {@link TreeNodeSchema} for holding a boolean.
|
|
215
|
+
*/
|
|
216
|
+
boolean: booleanSchema,
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* {@link TreeNodeSchema} for JavaScript `null`.
|
|
220
|
+
*
|
|
221
|
+
* @remarks
|
|
222
|
+
* There are good {@link https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null | reasons to avoid using null} in JavaScript, however sometimes it is desired.
|
|
223
|
+
* This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
|
|
224
|
+
* Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.
|
|
225
|
+
*/
|
|
226
|
+
null: nullSchema,
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* {@link TreeNodeSchema} for holding an {@link @fluidframework/core-interfaces#(IFluidHandle:interface)}.
|
|
230
|
+
*/
|
|
231
|
+
handle: handleSchema,
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* {@link AllowedTypes} for holding any of the leaf types.
|
|
235
|
+
*/
|
|
236
|
+
leaves: [stringSchema, numberSchema, booleanSchema, nullSchema, handleSchema],
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Make a field optional instead of the default, which is required.
|
|
240
|
+
*
|
|
241
|
+
* @param t - The types allowed under the field.
|
|
242
|
+
* @param props - Optional properties to associate with the field.
|
|
243
|
+
*
|
|
244
|
+
* @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
|
|
245
|
+
* See {@link FieldSchemaMetadata.custom}.
|
|
246
|
+
*/
|
|
247
|
+
optional: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
|
|
248
|
+
t: T,
|
|
249
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
250
|
+
): FieldSchema<FieldKind.Optional, T, TCustomMetadata> => {
|
|
251
|
+
const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {
|
|
252
|
+
return undefined;
|
|
253
|
+
});
|
|
254
|
+
return createFieldSchema(FieldKind.Optional, t, {
|
|
255
|
+
defaultProvider: defaultOptionalProvider,
|
|
256
|
+
...props,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Make a field explicitly required.
|
|
262
|
+
*
|
|
263
|
+
* @param t - The types allowed under the field.
|
|
264
|
+
* @param props - Optional properties to associate with the field.
|
|
265
|
+
*
|
|
266
|
+
* @remarks
|
|
267
|
+
* Fields are required by default, but this API can be used to make the required nature explicit in the schema,
|
|
268
|
+
* and allows associating custom {@link FieldProps | properties} with the field.
|
|
269
|
+
*
|
|
270
|
+
* @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
|
|
271
|
+
* See {@link FieldSchemaMetadata.custom}.
|
|
272
|
+
*/
|
|
273
|
+
required: <const T extends ImplicitAllowedTypes, const TCustomMetadata = unknown>(
|
|
274
|
+
t: T,
|
|
275
|
+
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
276
|
+
): FieldSchema<FieldKind.Required, T, TCustomMetadata> => {
|
|
277
|
+
return createFieldSchema(FieldKind.Required, t, props);
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* {@link schemaStatics.optional} except tweaked to work better for recursive types.
|
|
282
|
+
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
283
|
+
* @remarks
|
|
284
|
+
* This version of {@link schemaStatics.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
285
|
+
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
286
|
+
*/
|
|
287
|
+
optionalRecursive: <const T extends Unenforced<ImplicitAllowedTypes>>(
|
|
288
|
+
t: T,
|
|
289
|
+
props?: Omit<FieldProps, "defaultProvider">,
|
|
290
|
+
): FieldSchemaUnsafe<FieldKind.Optional, T> => {
|
|
291
|
+
return createFieldSchemaUnsafe(FieldKind.Optional, t, props);
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* {@link schemaStatics.required} except tweaked to work better for recursive types.
|
|
296
|
+
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
297
|
+
* @remarks
|
|
298
|
+
* This version of {@link schemaStatics.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
299
|
+
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
300
|
+
*/
|
|
301
|
+
requiredRecursive: <const T extends Unenforced<ImplicitAllowedTypes>>(
|
|
302
|
+
t: T,
|
|
303
|
+
props?: Omit<FieldProps, "defaultProvider">,
|
|
304
|
+
): FieldSchemaUnsafe<FieldKind.Required, T> => {
|
|
305
|
+
return createFieldSchemaUnsafe(FieldKind.Required, t, props);
|
|
306
|
+
},
|
|
307
|
+
} as const;
|
|
308
|
+
|
|
174
309
|
// TODO:
|
|
175
310
|
// SchemaFactory.array references should link to the correct overloads, however the syntax for this does not seems to work currently for methods unless the they are not qualified with the class.
|
|
176
311
|
// API-Extractor requires such links to be qualified with the class, so it can't work.
|
|
@@ -328,56 +463,65 @@ export class SchemaFactory<
|
|
|
328
463
|
}
|
|
329
464
|
|
|
330
465
|
/**
|
|
331
|
-
* {@
|
|
332
|
-
*
|
|
333
|
-
* @remarks
|
|
334
|
-
* Strings containing unpaired UTF-16 surrogate pair code units may not be handled correctly.
|
|
335
|
-
*
|
|
336
|
-
* These limitations come from the use of UTF-8 encoding of the strings, which requires them to be valid unicode.
|
|
337
|
-
* JavaScript does not make this requirement for its strings so not all possible JavaScript strings are supported.
|
|
338
|
-
* @privateRemarks
|
|
339
|
-
* TODO:
|
|
340
|
-
* We should be much more clear about what happens if you use problematic values.
|
|
341
|
-
* We should validate and/or normalize them when inserting content.
|
|
466
|
+
* {@inheritDoc schemaStatics.string}
|
|
342
467
|
*/
|
|
343
468
|
public readonly string = stringSchema;
|
|
344
469
|
|
|
345
470
|
/**
|
|
346
|
-
* {@
|
|
347
|
-
*
|
|
348
|
-
* @remarks
|
|
349
|
-
* The number is a [double-precision 64-bit binary format IEEE 754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) value, however there are some exceptions:
|
|
350
|
-
* - `NaN`, and the infinities are converted to `null` (and may therefore only be used where `null` is allowed by the schema).
|
|
351
|
-
* - `-0` may be converted to `0` in some cases.
|
|
352
|
-
*
|
|
353
|
-
* These limitations match the limitations of JSON.
|
|
354
|
-
* @privateRemarks
|
|
355
|
-
* TODO:
|
|
356
|
-
* We should be much more clear about what happens if you use problematic values.
|
|
357
|
-
* We should validate and/or normalize them when inserting content.
|
|
471
|
+
* {@inheritDoc schemaStatics.number}
|
|
358
472
|
*/
|
|
359
473
|
public readonly number = numberSchema;
|
|
360
474
|
|
|
361
475
|
/**
|
|
362
|
-
* {@
|
|
476
|
+
* {@inheritDoc schemaStatics.boolean}
|
|
363
477
|
*/
|
|
364
478
|
public readonly boolean = booleanSchema;
|
|
365
479
|
|
|
366
480
|
/**
|
|
367
|
-
* {@
|
|
368
|
-
*
|
|
369
|
-
* @remarks
|
|
370
|
-
* There are good [reasons to avoid using null](https://www.npmjs.com/package/%40rushstack/eslint-plugin#rushstackno-new-null) in JavaScript, however sometimes it is desired.
|
|
371
|
-
* This {@link TreeNodeSchema} node provides the option to include nulls in trees when desired.
|
|
372
|
-
* Unless directly inter-operating with existing data using null, consider other approaches, like wrapping the value in an optional field, or using a more specifically named empty object node.
|
|
481
|
+
* {@inheritDoc schemaStatics.null}
|
|
373
482
|
*/
|
|
374
483
|
public readonly null = nullSchema;
|
|
375
484
|
|
|
376
485
|
/**
|
|
377
|
-
* {@
|
|
486
|
+
* {@inheritDoc schemaStatics.handle}
|
|
378
487
|
*/
|
|
379
488
|
public readonly handle = handleSchema;
|
|
380
489
|
|
|
490
|
+
/**
|
|
491
|
+
* {@inheritDoc schemaStatics.leaves}
|
|
492
|
+
*/
|
|
493
|
+
public readonly leaves = schemaStatics.leaves;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* {@inheritDoc schemaStatics.string}
|
|
497
|
+
*/
|
|
498
|
+
public static readonly string = stringSchema;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* {@inheritDoc schemaStatics.number}
|
|
502
|
+
*/
|
|
503
|
+
public static readonly number = numberSchema;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* {@inheritDoc schemaStatics.boolean}
|
|
507
|
+
*/
|
|
508
|
+
public static readonly boolean = booleanSchema;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* {@inheritDoc schemaStatics.null}
|
|
512
|
+
*/
|
|
513
|
+
public static readonly null = nullSchema;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* {@inheritDoc schemaStatics.handle}
|
|
517
|
+
*/
|
|
518
|
+
public static readonly handle = handleSchema;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* {@inheritDoc schemaStatics.leaves}
|
|
522
|
+
*/
|
|
523
|
+
public static readonly leaves = schemaStatics.leaves;
|
|
524
|
+
|
|
381
525
|
/**
|
|
382
526
|
* Define a {@link TreeNodeSchemaClass} for a {@link TreeObjectNode}.
|
|
383
527
|
*
|
|
@@ -696,74 +840,44 @@ export class SchemaFactory<
|
|
|
696
840
|
}
|
|
697
841
|
|
|
698
842
|
/**
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
* @param t - The types allowed under the field.
|
|
702
|
-
* @param props - Optional properties to associate with the field.
|
|
703
|
-
*
|
|
704
|
-
* @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
|
|
705
|
-
* See {@link FieldSchemaMetadata.custom}.
|
|
843
|
+
* {@inheritDoc schemaStatics.optional}
|
|
706
844
|
*/
|
|
707
|
-
public optional
|
|
708
|
-
t: T,
|
|
709
|
-
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
710
|
-
): FieldSchema<FieldKind.Optional, T, TCustomMetadata> {
|
|
711
|
-
const defaultOptionalProvider: DefaultProvider = getDefaultProvider(() => {
|
|
712
|
-
return undefined;
|
|
713
|
-
});
|
|
714
|
-
return createFieldSchema(FieldKind.Optional, t, {
|
|
715
|
-
defaultProvider: defaultOptionalProvider,
|
|
716
|
-
...props,
|
|
717
|
-
});
|
|
718
|
-
}
|
|
845
|
+
public readonly optional = schemaStatics.optional;
|
|
719
846
|
|
|
720
847
|
/**
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
* @param t - The types allowed under the field.
|
|
724
|
-
* @param props - Optional properties to associate with the field.
|
|
725
|
-
*
|
|
726
|
-
* @remarks
|
|
727
|
-
* Fields are required by default, but this API can be used to make the required nature explicit in the schema,
|
|
728
|
-
* and allows associating custom {@link FieldProps | properties} with the field.
|
|
729
|
-
*
|
|
730
|
-
* @typeParam TCustomMetadata - Custom metadata properties to associate with the field.
|
|
731
|
-
* See {@link FieldSchemaMetadata.custom}.
|
|
848
|
+
* {@inheritDoc schemaStatics.required}
|
|
732
849
|
*/
|
|
733
|
-
public required
|
|
734
|
-
t: T,
|
|
735
|
-
props?: Omit<FieldProps<TCustomMetadata>, "defaultProvider">,
|
|
736
|
-
): FieldSchema<FieldKind.Required, T, TCustomMetadata> {
|
|
737
|
-
return createFieldSchema(FieldKind.Required, t, props);
|
|
738
|
-
}
|
|
850
|
+
public readonly required = schemaStatics.required;
|
|
739
851
|
|
|
740
852
|
/**
|
|
741
|
-
* {@
|
|
742
|
-
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
743
|
-
* @remarks
|
|
744
|
-
* This version of {@link SchemaFactory.optional} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
745
|
-
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
853
|
+
* {@inheritDoc schemaStatics.optionalRecursive}
|
|
746
854
|
*/
|
|
747
|
-
public optionalRecursive
|
|
748
|
-
t: T,
|
|
749
|
-
props?: Omit<FieldProps, "defaultProvider">,
|
|
750
|
-
): FieldSchemaUnsafe<FieldKind.Optional, T> {
|
|
751
|
-
return createFieldSchemaUnsafe(FieldKind.Optional, t, props);
|
|
752
|
-
}
|
|
855
|
+
public readonly optionalRecursive = schemaStatics.optionalRecursive;
|
|
753
856
|
|
|
754
857
|
/**
|
|
755
|
-
* {@
|
|
756
|
-
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
757
|
-
* @remarks
|
|
758
|
-
* This version of {@link SchemaFactory.required} has fewer type constraints to work around TypeScript limitations, see {@link Unenforced}.
|
|
759
|
-
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
858
|
+
* {@inheritDoc schemaStatics.requiredRecursive}
|
|
760
859
|
*/
|
|
761
|
-
public requiredRecursive
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
860
|
+
public readonly requiredRecursive = schemaStatics.requiredRecursive;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* {@inheritDoc schemaStatics.optional}
|
|
864
|
+
*/
|
|
865
|
+
public static readonly optional = schemaStatics.optional;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* {@inheritDoc schemaStatics.required}
|
|
869
|
+
*/
|
|
870
|
+
public static readonly required = schemaStatics.required;
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* {@inheritDoc schemaStatics.optionalRecursive}
|
|
874
|
+
*/
|
|
875
|
+
public static readonly optionalRecursive = schemaStatics.optionalRecursive;
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* {@inheritDoc schemaStatics.requiredRecursive}
|
|
879
|
+
*/
|
|
880
|
+
public static readonly requiredRecursive = schemaStatics.requiredRecursive;
|
|
767
881
|
|
|
768
882
|
/**
|
|
769
883
|
* A special field which holds a unique identifier for an object node.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { TreeNode } from "../
|
|
6
|
+
import type { TreeNode } from "../core/index.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A special object that signifies when a SharedTree {@link RunTransaction | transaction} should "roll back".
|