@fluidframework/tree 2.74.0 → 2.80.0
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/.eslintrc.cjs +1 -16
- package/CHANGELOG.md +18 -0
- package/api-report/tree.alpha.api.md +20 -2
- package/dist/alpha.d.ts +4 -0
- package/dist/codec/codec.d.ts +31 -3
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +10 -0
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +2 -2
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +2 -2
- package/dist/codec/index.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +80 -22
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js +137 -15
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/index.d.ts +1 -1
- package/dist/codec/versioned/index.d.ts.map +1 -1
- package/dist/codec/versioned/index.js +2 -2
- package/dist/codec/versioned/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/rebase/changeRebaser.d.ts +36 -2
- package/dist/core/rebase/changeRebaser.d.ts.map +1 -1
- package/dist/core/rebase/changeRebaser.js.map +1 -1
- package/dist/core/rebase/index.d.ts +2 -2
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js +1 -2
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +6 -2
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js +1 -12
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/rebase/utils.js +3 -3
- package/dist/core/rebase/utils.js.map +1 -1
- package/dist/core/schema-stored/schema.js +3 -3
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/anchorSet.d.ts.map +1 -1
- package/dist/core/tree/anchorSet.js +3 -4
- package/dist/core/tree/anchorSet.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +1 -2
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +12 -56
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.js +6 -6
- package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +11 -41
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +2 -2
- package/dist/core/tree/index.js.map +1 -1
- package/dist/core/tree/mapTree.js +1 -1
- package/dist/core/tree/mapTree.js.map +1 -1
- package/dist/core/tree/sparseTree.d.ts.map +1 -1
- package/dist/core/tree/sparseTree.js +1 -0
- package/dist/core/tree/sparseTree.js.map +1 -1
- package/dist/core/tree/treeTextFormat.d.ts.map +1 -1
- package/dist/core/tree/treeTextFormat.js +5 -9
- package/dist/core/tree/treeTextFormat.js.map +1 -1
- package/dist/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/dist/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/dist/feature-libraries/changeAtomIdBTree.js +16 -0
- package/dist/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/dist/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/dist/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/dist/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +19 -11
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/dist/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
- package/dist/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/dist/feature-libraries/flex-tree/lazyField.js +11 -13
- package/dist/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +3 -2
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +9 -7
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/dist/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js +10 -1
- package/dist/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +12 -9
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js +59 -0
- package/dist/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
- 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.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -4
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js +2 -2
- package/dist/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +4 -2
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +11 -7
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js +315 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js +31 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +25 -288
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +225 -195
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +7 -7
- package/dist/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js +21 -0
- package/dist/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
- package/dist/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/dist/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/dist/feature-libraries/object-forest/objectForest.js +4 -4
- package/dist/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +34 -39
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +14 -2
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +7 -21
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +28 -70
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/index.d.ts +2 -2
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +2 -5
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +1 -12
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/dist/feature-libraries/schemaChecker.js +11 -6
- package/dist/feature-libraries/schemaChecker.js.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/compose.js +17 -13
- package/dist/feature-libraries/sequence-field/compose.js.map +1 -1
- package/dist/feature-libraries/sequence-field/invert.js +5 -4
- package/dist/feature-libraries/sequence-field/invert.js.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/moveEffectTable.js +15 -9
- package/dist/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/dist/feature-libraries/sequence-field/rebase.js +26 -18
- package/dist/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
- package/dist/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/replaceRevisions.js +40 -35
- package/dist/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
- package/dist/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/utils.js +46 -27
- package/dist/feature-libraries/sequence-field/utils.js.map +1 -1
- package/dist/feature-libraries/treeCursorUtils.js +7 -7
- package/dist/feature-libraries/treeCursorUtils.js.map +1 -1
- package/dist/feature-libraries/treeTextCursor.js +2 -2
- package/dist/feature-libraries/treeTextCursor.js.map +1 -1
- package/dist/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/dist/feature-libraries/valueUtilities.js +16 -8
- package/dist/feature-libraries/valueUtilities.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +2 -3
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +20 -9
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +61 -44
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +9 -8
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +4 -2
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js +19 -14
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js +1 -1
- package/dist/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +35 -29
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +21 -23
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +2 -0
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +31 -18
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/branch.d.ts +3 -1
- package/dist/shared-tree-core/branch.d.ts.map +1 -1
- package/dist/shared-tree-core/branch.js +5 -3
- package/dist/shared-tree-core/branch.js.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.js +1 -1
- package/dist/shared-tree-core/branchCommitEnricher.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/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +9 -4
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +6 -0
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +1 -0
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +3 -3
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +8 -4
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +1 -0
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +6 -0
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
- package/dist/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js +8 -1
- package/dist/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/dist/shared-tree-core/sequenceIdUtils.js +4 -4
- package/dist/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +12 -8
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/transaction.d.ts +25 -8
- package/dist/shared-tree-core/transaction.d.ts.map +1 -1
- package/dist/shared-tree-core/transaction.js +65 -30
- package/dist/shared-tree-core/transaction.js.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/dist/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/dist/shared-tree-core/transactionEnricher.js +3 -3
- package/dist/shared-tree-core/transactionEnricher.js.map +1 -1
- package/dist/simple-tree/api/configuration.js +1 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/customTree.d.ts.map +1 -1
- package/dist/simple-tree/api/customTree.js +13 -9
- package/dist/simple-tree/api/customTree.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +21 -17
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +1 -1
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +12 -8
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +18 -9
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/simpleTreeIndex.js +10 -10
- package/dist/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +2 -3
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/transactionTypes.d.ts +17 -4
- package/dist/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/transactionTypes.js.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/dist/simple-tree/api/treeNodeApi.js +21 -13
- package/dist/simple-tree/api/treeNodeApi.js.map +1 -1
- package/dist/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/dist/simple-tree/api/verboseTree.js +14 -9
- package/dist/simple-tree/api/verboseTree.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js +6 -3
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/dist/simple-tree/core/unhydratedFlexTree.js +20 -15
- package/dist/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/dist/simple-tree/getTreeNodeForField.js +2 -1
- package/dist/simple-tree/getTreeNodeForField.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.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +9 -6
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +15 -15
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +4 -5
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +9 -5
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/treeFactory.js +7 -3
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/bTreeUtils.js +1 -1
- package/dist/util/bTreeUtils.js.map +1 -1
- package/dist/util/breakable.js +7 -9
- package/dist/util/breakable.js.map +1 -1
- package/dist/util/idAllocator.d.ts.map +1 -1
- package/dist/util/idAllocator.js +1 -2
- package/dist/util/idAllocator.js.map +1 -1
- package/dist/util/nestedMap.d.ts.map +1 -1
- package/dist/util/nestedMap.js +1 -1
- package/dist/util/nestedMap.js.map +1 -1
- package/dist/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +16 -15
- package/dist/util/utils.js.map +1 -1
- package/eslint.config.mts +1 -16
- package/lib/alpha.d.ts +4 -0
- package/lib/codec/codec.d.ts +31 -3
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +10 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +2 -2
- package/lib/codec/index.d.ts.map +1 -1
- package/lib/codec/index.js +1 -1
- package/lib/codec/index.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +80 -22
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js +138 -15
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/index.d.ts +1 -1
- package/lib/codec/versioned/index.d.ts.map +1 -1
- package/lib/codec/versioned/index.js +1 -1
- package/lib/codec/versioned/index.js.map +1 -1
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -2
- package/lib/core/index.js.map +1 -1
- package/lib/core/rebase/changeRebaser.d.ts +36 -2
- package/lib/core/rebase/changeRebaser.d.ts.map +1 -1
- package/lib/core/rebase/changeRebaser.js.map +1 -1
- package/lib/core/rebase/index.d.ts +2 -2
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +6 -2
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js +0 -10
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/rebase/utils.js +3 -3
- package/lib/core/rebase/utils.js.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -3
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/anchorSet.d.ts.map +1 -1
- package/lib/core/tree/anchorSet.js +3 -4
- package/lib/core/tree/anchorSet.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +1 -2
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +13 -57
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +18 -10
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.js +4 -4
- package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +4 -5
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -6
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +5 -6
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +12 -39
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/core/tree/mapTree.js +1 -1
- package/lib/core/tree/mapTree.js.map +1 -1
- package/lib/core/tree/sparseTree.d.ts.map +1 -1
- package/lib/core/tree/sparseTree.js +1 -0
- package/lib/core/tree/sparseTree.js.map +1 -1
- package/lib/core/tree/treeTextFormat.d.ts.map +1 -1
- package/lib/core/tree/treeTextFormat.js +5 -9
- package/lib/core/tree/treeTextFormat.js.map +1 -1
- package/lib/feature-libraries/changeAtomIdBTree.d.ts +10 -0
- package/lib/feature-libraries/changeAtomIdBTree.d.ts.map +1 -0
- package/lib/feature-libraries/changeAtomIdBTree.js +11 -0
- package/lib/feature-libraries/changeAtomIdBTree.js.map +1 -0
- package/lib/feature-libraries/chunked-forest/basicChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/basicChunk.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/chunkedForest.js +6 -6
- package/lib/feature-libraries/chunked-forest/chunkedForest.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js +7 -4
- package/lib/feature-libraries/chunked-forest/codec/chunkDecoding.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +19 -11
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +9 -5
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js +1 -1
- package/lib/feature-libraries/chunked-forest/uniformChunk.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +15 -5
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +19 -14
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +11 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts +2 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js +6 -0
- package/lib/feature-libraries/default-schema/mappedEditBuilder.js.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.d.ts.map +1 -1
- package/lib/feature-libraries/flex-tree/lazyField.js +11 -13
- package/lib/feature-libraries/flex-tree/lazyField.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +3 -2
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +3 -2
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/indexing/anchorTreeIndex.js +6 -6
- package/lib/feature-libraries/indexing/anchorTreeIndex.js.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js +10 -1
- package/lib/feature-libraries/mitigatedChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +12 -9
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts +25 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js +55 -0
- package/lib/feature-libraries/modular-schema/defaultRevisionReplacer.js.map +1 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +3 -3
- 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.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +5 -5
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKindCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +4 -2
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +3 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts +49 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js +298 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV1.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts +15 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js +27 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecV2.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts +2 -2
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +27 -290
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +14 -8
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +118 -88
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/modular-schema/{modularChangeFormat.d.ts → modularChangeFormatV1.d.ts} +5 -6
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/{modularChangeFormat.js → modularChangeFormatV1.js} +4 -4
- package/lib/feature-libraries/modular-schema/modularChangeFormatV1.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts +112 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.d.ts.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js +18 -0
- package/lib/feature-libraries/modular-schema/modularChangeFormatV2.js.map +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts +13 -3
- package/lib/feature-libraries/modular-schema/modularChangeTypes.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeTypes.js.map +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js +1 -1
- package/lib/feature-libraries/node-identifier/mockNodeIdentifierManager.js.map +1 -1
- package/lib/feature-libraries/object-forest/objectForest.js +4 -4
- package/lib/feature-libraries/object-forest/objectForest.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +35 -40
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +15 -3
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +7 -21
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +30 -68
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/index.d.ts +2 -2
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +2 -2
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +1 -9
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +0 -10
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/feature-libraries/schemaChecker.d.ts.map +1 -1
- package/lib/feature-libraries/schemaChecker.js +11 -6
- package/lib/feature-libraries/schemaChecker.js.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/compose.js +17 -13
- package/lib/feature-libraries/sequence-field/compose.js.map +1 -1
- package/lib/feature-libraries/sequence-field/invert.js +5 -4
- package/lib/feature-libraries/sequence-field/invert.js.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/moveEffectTable.js +15 -9
- package/lib/feature-libraries/sequence-field/moveEffectTable.js.map +1 -1
- package/lib/feature-libraries/sequence-field/rebase.js +26 -18
- package/lib/feature-libraries/sequence-field/rebase.js.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts +2 -2
- package/lib/feature-libraries/sequence-field/replaceRevisions.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/replaceRevisions.js +41 -36
- package/lib/feature-libraries/sequence-field/replaceRevisions.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +16 -8
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +4 -2
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js +6 -3
- package/lib/feature-libraries/sequence-field/sequenceFieldToDelta.js.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/utils.js +46 -27
- package/lib/feature-libraries/sequence-field/utils.js.map +1 -1
- package/lib/feature-libraries/treeCursorUtils.js +7 -7
- package/lib/feature-libraries/treeCursorUtils.js.map +1 -1
- package/lib/feature-libraries/treeTextCursor.js +2 -2
- package/lib/feature-libraries/treeTextCursor.js.map +1 -1
- package/lib/feature-libraries/valueUtilities.d.ts.map +1 -1
- package/lib/feature-libraries/valueUtilities.js +16 -8
- package/lib/feature-libraries/valueUtilities.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +2 -3
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +20 -9
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +30 -13
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +9 -8
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +4 -2
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +3 -2
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js +19 -14
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js +1 -1
- package/lib/shared-tree/sharedTreeEditBuilder.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +35 -29
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +21 -23
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +2 -0
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +32 -19
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/branch.d.ts +3 -1
- package/lib/shared-tree-core/branch.d.ts.map +1 -1
- package/lib/shared-tree-core/branch.js +5 -3
- package/lib/shared-tree-core/branch.js.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/branchCommitEnricher.js +2 -2
- package/lib/shared-tree-core/branchCommitEnricher.js.map +1 -1
- package/lib/shared-tree-core/editManager.js +1 -1
- package/lib/shared-tree-core/editManager.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +9 -4
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +1 -0
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +6 -0
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +1 -0
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +3 -3
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js +2 -1
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +8 -4
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +1 -0
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +6 -0
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts +3 -2
- package/lib/shared-tree-core/messageFormatV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js +8 -1
- package/lib/shared-tree-core/messageFormatV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.d.ts.map +1 -1
- package/lib/shared-tree-core/sequenceIdUtils.js +4 -4
- package/lib/shared-tree-core/sequenceIdUtils.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +12 -8
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/transaction.d.ts +25 -8
- package/lib/shared-tree-core/transaction.d.ts.map +1 -1
- package/lib/shared-tree-core/transaction.js +67 -32
- package/lib/shared-tree-core/transaction.js.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.d.ts +2 -2
- package/lib/shared-tree-core/transactionEnricher.d.ts.map +1 -1
- package/lib/shared-tree-core/transactionEnricher.js +3 -3
- package/lib/shared-tree-core/transactionEnricher.js.map +1 -1
- package/lib/simple-tree/api/configuration.js +1 -1
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/customTree.d.ts.map +1 -1
- package/lib/simple-tree/api/customTree.js +13 -9
- package/lib/simple-tree/api/customTree.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +21 -17
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +1 -1
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +12 -8
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +18 -9
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaCodec.js +10 -5
- package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js +15 -11
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/simpleTreeIndex.js +10 -10
- package/lib/simple-tree/api/simpleTreeIndex.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +4 -7
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/transactionTypes.d.ts +17 -4
- package/lib/simple-tree/api/transactionTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/transactionTypes.js.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.d.ts.map +1 -1
- package/lib/simple-tree/api/treeNodeApi.js +21 -13
- package/lib/simple-tree/api/treeNodeApi.js.map +1 -1
- package/lib/simple-tree/api/verboseTree.d.ts.map +1 -1
- package/lib/simple-tree/api/verboseTree.js +14 -9
- package/lib/simple-tree/api/verboseTree.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js +6 -3
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.d.ts.map +1 -1
- package/lib/simple-tree/core/unhydratedFlexTree.js +20 -15
- package/lib/simple-tree/core/unhydratedFlexTree.js.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.d.ts.map +1 -1
- package/lib/simple-tree/getTreeNodeForField.js +2 -1
- package/lib/simple-tree/getTreeNodeForField.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.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +9 -6
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +15 -15
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +4 -5
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +2 -3
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +9 -5
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/treeFactory.js +7 -3
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/bTreeUtils.js +1 -1
- package/lib/util/bTreeUtils.js.map +1 -1
- package/lib/util/breakable.js +7 -9
- package/lib/util/breakable.js.map +1 -1
- package/lib/util/idAllocator.d.ts.map +1 -1
- package/lib/util/idAllocator.js +1 -2
- package/lib/util/idAllocator.js.map +1 -1
- package/lib/util/nestedMap.d.ts.map +1 -1
- package/lib/util/nestedMap.js +1 -1
- package/lib/util/nestedMap.js.map +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +16 -15
- package/lib/util/utils.js.map +1 -1
- package/package.json +32 -32
- package/src/codec/codec.ts +48 -8
- package/src/codec/index.ts +4 -1
- package/src/codec/versioned/codec.ts +340 -22
- package/src/codec/versioned/index.ts +3 -1
- package/src/core/index.ts +2 -2
- package/src/core/rebase/changeRebaser.ts +40 -6
- package/src/core/rebase/index.ts +1 -1
- package/src/core/rebase/types.ts +6 -18
- package/src/core/rebase/utils.ts +3 -3
- package/src/core/schema-stored/schema.ts +3 -3
- package/src/core/tree/anchorSet.ts +3 -4
- package/src/core/tree/detachedFieldIndex.ts +13 -74
- package/src/core/tree/detachedFieldIndexCodecCommon.ts +4 -8
- package/src/core/tree/detachedFieldIndexCodecV1.ts +3 -7
- package/src/core/tree/detachedFieldIndexCodecV2.ts +5 -9
- package/src/core/tree/detachedFieldIndexCodecs.ts +21 -64
- package/src/core/tree/index.ts +1 -1
- package/src/core/tree/mapTree.ts +1 -1
- package/src/core/tree/sparseTree.ts +1 -0
- package/src/core/tree/treeTextFormat.ts +5 -9
- package/src/feature-libraries/changeAtomIdBTree.ts +24 -0
- package/src/feature-libraries/chunked-forest/basicChunk.ts +1 -1
- package/src/feature-libraries/chunked-forest/chunkedForest.ts +5 -5
- package/src/feature-libraries/chunked-forest/codec/chunkDecoding.ts +7 -4
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +19 -11
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +3 -3
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -5
- package/src/feature-libraries/chunked-forest/uniformChunk.ts +1 -1
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +48 -17
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +12 -2
- package/src/feature-libraries/default-schema/mappedEditBuilder.ts +6 -0
- package/src/feature-libraries/flex-tree/lazyField.ts +13 -14
- package/src/feature-libraries/index.ts +10 -5
- package/src/feature-libraries/indexing/anchorTreeIndex.ts +5 -5
- package/src/feature-libraries/mitigatedChangeFamily.ts +11 -6
- package/src/feature-libraries/modular-schema/comparison.ts +12 -9
- package/src/feature-libraries/modular-schema/defaultRevisionReplacer.ts +70 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +3 -6
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +5 -7
- package/src/feature-libraries/modular-schema/genericFieldKindCodecs.ts +1 -1
- package/src/feature-libraries/modular-schema/index.ts +5 -2
- package/src/feature-libraries/modular-schema/modularChangeCodecV1.ts +703 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecV2.ts +89 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +39 -523
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +159 -125
- package/src/feature-libraries/modular-schema/{modularChangeFormat.ts → modularChangeFormatV1.ts} +4 -4
- package/src/feature-libraries/modular-schema/modularChangeFormatV2.ts +34 -0
- package/src/feature-libraries/modular-schema/modularChangeTypes.ts +13 -4
- package/src/feature-libraries/node-identifier/mockNodeIdentifierManager.ts +1 -1
- package/src/feature-libraries/object-forest/objectForest.ts +4 -4
- package/src/feature-libraries/optional-field/optionalField.ts +34 -46
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +18 -3
- package/src/feature-libraries/schema-index/codec.ts +30 -90
- package/src/feature-libraries/schema-index/index.ts +2 -4
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +0 -17
- package/src/feature-libraries/schemaChecker.ts +11 -6
- package/src/feature-libraries/sequence-field/compose.ts +17 -13
- package/src/feature-libraries/sequence-field/invert.ts +5 -4
- package/src/feature-libraries/sequence-field/moveEffectTable.ts +15 -9
- package/src/feature-libraries/sequence-field/rebase.ts +26 -18
- package/src/feature-libraries/sequence-field/replaceRevisions.ts +52 -56
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +16 -8
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldToDelta.ts +6 -3
- package/src/feature-libraries/sequence-field/utils.ts +46 -27
- package/src/feature-libraries/treeCursorUtils.ts +7 -7
- package/src/feature-libraries/treeTextCursor.ts +2 -2
- package/src/feature-libraries/valueUtilities.ts +16 -8
- package/src/index.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +23 -13
- package/src/shared-tree/sharedTree.ts +30 -14
- package/src/shared-tree/sharedTreeChangeCodecs.ts +10 -9
- package/src/shared-tree/sharedTreeChangeEnricher.ts +4 -2
- package/src/shared-tree/sharedTreeChangeFamily.ts +29 -19
- package/src/shared-tree/sharedTreeEditBuilder.ts +9 -5
- package/src/shared-tree/treeAlpha.ts +60 -51
- package/src/shared-tree/treeCheckout.ts +66 -50
- package/src/shared-tree-core/branch.ts +8 -3
- package/src/shared-tree-core/branchCommitEnricher.ts +3 -8
- package/src/shared-tree-core/editManager.ts +1 -1
- package/src/shared-tree-core/editManagerCodecs.ts +9 -4
- package/src/shared-tree-core/editManagerFormatCommons.ts +6 -0
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +3 -1
- package/src/shared-tree-core/editManagerSummarizer.ts +3 -3
- package/src/shared-tree-core/messageCodecV1ToV4.ts +2 -1
- package/src/shared-tree-core/messageCodecVSharedBranches.ts +2 -1
- package/src/shared-tree-core/messageCodecs.ts +8 -4
- package/src/shared-tree-core/messageFormat.ts +6 -1
- package/src/shared-tree-core/messageFormatV1ToV4.ts +16 -2
- package/src/shared-tree-core/sequenceIdUtils.ts +4 -4
- package/src/shared-tree-core/sharedTreeCore.ts +11 -7
- package/src/shared-tree-core/transaction.ts +115 -56
- package/src/shared-tree-core/transactionEnricher.ts +5 -6
- package/src/simple-tree/api/configuration.ts +1 -1
- package/src/simple-tree/api/customTree.ts +14 -10
- package/src/simple-tree/api/discrepancies.ts +23 -17
- package/src/simple-tree/api/index.ts +2 -0
- package/src/simple-tree/api/schemaFactory.ts +11 -7
- package/src/simple-tree/api/schemaFromSimple.ts +18 -9
- package/src/simple-tree/api/simpleSchemaCodec.ts +10 -5
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +17 -13
- package/src/simple-tree/api/simpleTreeIndex.ts +8 -8
- package/src/simple-tree/api/storedSchema.ts +10 -7
- package/src/simple-tree/api/transactionTypes.ts +19 -4
- package/src/simple-tree/api/treeNodeApi.ts +21 -13
- package/src/simple-tree/api/verboseTree.ts +14 -9
- package/src/simple-tree/core/treeNodeKernel.ts +6 -3
- package/src/simple-tree/core/unhydratedFlexTree.ts +22 -17
- package/src/simple-tree/getTreeNodeForField.ts +2 -1
- package/src/simple-tree/index.ts +2 -0
- package/src/simple-tree/leafNodeSchema.ts +8 -5
- package/src/simple-tree/node-kinds/array/arrayNode.ts +23 -23
- package/src/simple-tree/node-kinds/object/objectNode.ts +4 -5
- package/src/simple-tree/node-kinds/record/recordNode.ts +2 -3
- package/src/simple-tree/toStoredSchema.ts +9 -5
- package/src/treeFactory.ts +10 -5
- package/src/util/bTreeUtils.ts +1 -1
- package/src/util/breakable.ts +9 -9
- package/src/util/idAllocator.ts +1 -2
- package/src/util/nestedMap.ts +1 -3
- package/src/util/utils.ts +14 -13
- package/dist/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
- package/dist/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.d.ts.map +0 -1
- package/lib/feature-libraries/modular-schema/modularChangeFormat.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;AAc5E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAO9C,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EACN,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,sBA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AC,QAAQ,CAAC;KAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n\tJsonRecordNodeSchema,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../fieldSchema.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleRecordNodeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport type { TreeSchema } from \"../treeSchema.js\";\nimport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nimport {\n\tArrayNodeSchema,\n\tisMapNodeSchema,\n\tisRecordNodeSchema,\n\tObjectNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport { KeyEncodingOptions } from \"./customTree.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @remarks\n * This expects the data to be in the {@link ConciseTree} format.\n *\n * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.\n * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.\n */\nexport function toJsonSchema(\n\tschema: TreeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions, options);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.root.allowedTypesIdentifiers) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\t// TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.\n\t// TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes\n\t// TODO: handle case where allowedTypes is empty.\n\t// TODO: handle staged types in a controllable way.\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, TreeNodeSchema>,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value, options);\n\t}\n\treturn result;\n}\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(\n\tschema: TreeNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonNodeSchema {\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn convertArrayNodeSchema(schema);\n\t} else if (isMapNodeSchema(schema) || isRecordNodeSchema(schema)) {\n\t\treturn convertRecordLikeNodeSchema(schema);\n\t} else if (schema instanceof ObjectNodeSchema) {\n\t\treturn convertObjectNodeSchema(schema, options);\n\t} else if (schema instanceof LeafNodeSchema) {\n\t\treturn convertLeafNodeSchema(schema);\n\t}\n\tthrow new TypeError(`Unknown node schema kind: ${schema.kind}`);\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tconst allowedTypesIdentifiers: ReadonlySet<string> = new Set(\n\t\tschema.simpleAllowedTypes.keys(),\n\t);\n\tallowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String:\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Number:\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Boolean:\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\tcase ValueSchema.Null:\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\tcase ValueSchema.FluidHandle:\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\tdefault:\n\t\t\tunreachableCase(schema.leafKind);\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nexport function convertObjectNodeSchema(\n\tschema: ObjectNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\tconst key =\n\t\t\toptions.keys === KeyEncodingOptions.usePropertyKeys\n\t\t\t\t? propertyKey\n\t\t\t\t: fieldSchema.storedKey;\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypesIdentifiers) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (fieldSchema.kind !== FieldKind.Optional) {\n\t\t\tif (\n\t\t\t\toptions.requireFieldsWithDefaults ||\n\t\t\t\tfieldSchema.props?.defaultProvider === undefined\n\t\t\t) {\n\t\t\t\trequired.push(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\t// TODO: support unknown optional fields (only when using \"allStoredKeys\", and constrain the content to be in schema somehow)\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertRecordLikeNodeSchema(\n\tschema: SimpleRecordNodeSchema | SimpleMapNodeSchema,\n): JsonMapNodeSchema | JsonRecordNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tconst allowedTypesIdentifiers: ReadonlySet<string> = new Set(\n\t\tschema.simpleAllowedTypes.keys(),\n\t);\n\tallowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: schema.kind,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t} as const;\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"simpleSchemaToJsonSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleSchemaToJsonSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;AAc5E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAO9C,OAAO,EAAE,QAAQ,EAAuB,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EACN,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC3B,MAAkB,EAClB,OAA4C;IAE5C,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAEpE,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC/D,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,gHAAgH;IAChH,qFAAqF;IACrF,iDAAiD;IACjD,mDAAmD;IACnD,OAAO,SAAS,CAAC,YAAY,CAAC;QAC7B,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E,KAAK;KAC3B,CAAC;IAEF,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;IAE9D,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,SAAS,2BAA2B,CACnC,MAAoD;IAEpD,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAC3D,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAChC,CAAC;IACF,uBAAuB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACxC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG;QACd,IAAI,EAAE,QAAQ;QACd,mBAAmB,EAAE,MAAM,CAAC,IAAI;QAChC,iBAAiB,EAAE;YAClB,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC;gBAC9B,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;gBACjB,CAAC,CAAC;oBACA,KAAK,EAAE,YAAY;iBACnB;SACH;KACQ,CAAC;IAEX,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,QAAgB;IACxC,OAAO;QACN,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACtC,OAAO,WAAW,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { ValueSchema } from \"../../core/index.js\";\nimport { copyProperty, hasSingle, type Mutable } from \"../../util/index.js\";\nimport type {\n\tJsonArrayNodeSchema,\n\tJsonFieldSchema,\n\tJsonSchemaRef,\n\tJsonRefPath,\n\tJsonLeafNodeSchema,\n\tJsonMapNodeSchema,\n\tJsonNodeSchema,\n\tJsonObjectNodeSchema,\n\tJsonTreeSchema,\n\tJsonLeafSchemaType,\n\tJsonRecordNodeSchema,\n} from \"./jsonSchema.js\";\nimport { FieldKind } from \"../fieldSchema.js\";\nimport type {\n\tSimpleArrayNodeSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleRecordNodeSchema,\n} from \"../simpleSchema.js\";\nimport { NodeKind, type TreeNodeSchema } from \"../core/index.js\";\nimport type { TreeSchema } from \"../treeSchema.js\";\nimport type { TreeSchemaEncodingOptions } from \"./getJsonSchema.js\";\nimport {\n\tArrayNodeSchema,\n\tisMapNodeSchema,\n\tisRecordNodeSchema,\n\tObjectNodeSchema,\n} from \"../node-kinds/index.js\";\nimport { LeafNodeSchema } from \"../leafNodeSchema.js\";\nimport { KeyEncodingOptions } from \"./customTree.js\";\n\n/**\n * Generates a JSON Schema representation from a simple tree schema.\n * @remarks\n * This expects the data to be in the {@link ConciseTree} format.\n *\n * This cannot handle the case where the root is undefined since undefined is not a concept in JSON.\n * This also cannot handle {@link SchemaStatics.handle} since they also are not supported in JSON.\n */\nexport function toJsonSchema(\n\tschema: TreeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonTreeSchema {\n\tconst definitions = convertDefinitions(schema.definitions, options);\n\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tfor (const allowedType of schema.root.allowedTypesIdentifiers) {\n\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t}\n\n\t// TODO: deduplicate field handling logic from convertObjectNodeSchema: at least include metadata's description.\n\t// TODO: maybe account for consider schema.kind, or just take in ImplicitAllowedTypes\n\t// TODO: handle case where allowedTypes is empty.\n\t// TODO: handle staged types in a controllable way.\n\treturn hasSingle(allowedTypes)\n\t\t? {\n\t\t\t\t...allowedTypes[0],\n\t\t\t\t$defs: definitions,\n\t\t\t}\n\t\t: {\n\t\t\t\t$defs: definitions,\n\t\t\t\tanyOf: allowedTypes,\n\t\t\t};\n}\n\nfunction convertDefinitions(\n\tdefinitions: ReadonlyMap<string, TreeNodeSchema>,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): Record<string, JsonNodeSchema> {\n\tconst result: Record<string, JsonNodeSchema> = {};\n\tfor (const [key, value] of definitions) {\n\t\tresult[key] = convertNodeSchema(value, options);\n\t}\n\treturn result;\n}\n\n/**\n * Converts an input {@link SimpleNodeSchema} to a {@link JsonNodeSchema}.\n *\n * @remarks Caches the result on the input schema for future calls.\n */\nfunction convertNodeSchema(\n\tschema: TreeNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonNodeSchema {\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn convertArrayNodeSchema(schema);\n\t} else if (isMapNodeSchema(schema) || isRecordNodeSchema(schema)) {\n\t\treturn convertRecordLikeNodeSchema(schema);\n\t} else if (schema instanceof ObjectNodeSchema) {\n\t\treturn convertObjectNodeSchema(schema, options);\n\t} else if (schema instanceof LeafNodeSchema) {\n\t\treturn convertLeafNodeSchema(schema);\n\t}\n\tthrow new TypeError(`Unknown node schema kind: ${schema.kind}`);\n}\n\nfunction convertArrayNodeSchema(schema: SimpleArrayNodeSchema): JsonArrayNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tconst allowedTypesIdentifiers: ReadonlySet<string> = new Set(\n\t\tschema.simpleAllowedTypes.keys(),\n\t);\n\tallowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst items: JsonFieldSchema = hasSingle(allowedTypes)\n\t\t? allowedTypes[0]\n\t\t: { anyOf: allowedTypes };\n\n\tconst output: Mutable<JsonArrayNodeSchema> = {\n\t\ttype: \"array\",\n\t\t_treeNodeSchemaKind: NodeKind.Array,\n\t\titems,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction convertLeafNodeSchema(schema: SimpleLeafNodeSchema): JsonLeafNodeSchema {\n\tlet type: JsonLeafSchemaType;\n\tswitch (schema.leafKind) {\n\t\tcase ValueSchema.String: {\n\t\t\ttype = \"string\";\n\t\t\tbreak;\n\t\t}\n\t\tcase ValueSchema.Number: {\n\t\t\ttype = \"number\";\n\t\t\tbreak;\n\t\t}\n\t\tcase ValueSchema.Boolean: {\n\t\t\ttype = \"boolean\";\n\t\t\tbreak;\n\t\t}\n\t\tcase ValueSchema.Null: {\n\t\t\ttype = \"null\";\n\t\t\tbreak;\n\t\t}\n\t\tcase ValueSchema.FluidHandle: {\n\t\t\tthrow new UsageError(\"Fluid handles are not supported via JSON Schema.\");\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(schema.leafKind);\n\t\t}\n\t}\n\n\treturn {\n\t\ttype,\n\t\t_treeNodeSchemaKind: NodeKind.Leaf,\n\t};\n}\n\nexport function convertObjectNodeSchema(\n\tschema: ObjectNodeSchema,\n\toptions: Required<TreeSchemaEncodingOptions>,\n): JsonObjectNodeSchema {\n\tconst properties: Record<string, JsonFieldSchema> = {};\n\tconst required: string[] = [];\n\tfor (const [propertyKey, fieldSchema] of schema.fields) {\n\t\tconst key =\n\t\t\toptions.keys === KeyEncodingOptions.usePropertyKeys\n\t\t\t\t? propertyKey\n\t\t\t\t: fieldSchema.storedKey;\n\t\tconst allowedTypes: JsonSchemaRef[] = [];\n\t\tfor (const allowedType of fieldSchema.allowedTypesIdentifiers) {\n\t\t\tallowedTypes.push(createSchemaRef(allowedType));\n\t\t}\n\n\t\tconst output: Mutable<JsonFieldSchema> = hasSingle(allowedTypes)\n\t\t\t? allowedTypes[0]\n\t\t\t: {\n\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t};\n\n\t\tcopyProperty(fieldSchema.metadata, \"description\", output);\n\t\tproperties[key] = output;\n\n\t\tif (\n\t\t\tfieldSchema.kind !== FieldKind.Optional &&\n\t\t\t(options.requireFieldsWithDefaults || fieldSchema.props?.defaultProvider === undefined)\n\t\t) {\n\t\t\trequired.push(key);\n\t\t}\n\t}\n\n\tconst transformedNode: Mutable<JsonObjectNodeSchema> = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: NodeKind.Object,\n\t\tproperties,\n\t\trequired,\n\t\t// TODO: support unknown optional fields (only when using \"allStoredKeys\", and constrain the content to be in schema somehow)\n\t\tadditionalProperties: false,\n\t};\n\n\tcopyProperty(schema.metadata, \"description\", transformedNode);\n\n\treturn transformedNode;\n}\n\nfunction convertRecordLikeNodeSchema(\n\tschema: SimpleRecordNodeSchema | SimpleMapNodeSchema,\n): JsonMapNodeSchema | JsonRecordNodeSchema {\n\tconst allowedTypes: JsonSchemaRef[] = [];\n\tconst allowedTypesIdentifiers: ReadonlySet<string> = new Set(\n\t\tschema.simpleAllowedTypes.keys(),\n\t);\n\tallowedTypesIdentifiers.forEach((type) => {\n\t\tallowedTypes.push(createSchemaRef(type));\n\t});\n\n\tconst output = {\n\t\ttype: \"object\",\n\t\t_treeNodeSchemaKind: schema.kind,\n\t\tpatternProperties: {\n\t\t\t\"^.*$\": hasSingle(allowedTypes)\n\t\t\t\t? allowedTypes[0]\n\t\t\t\t: {\n\t\t\t\t\t\tanyOf: allowedTypes,\n\t\t\t\t\t},\n\t\t},\n\t} as const;\n\n\tcopyProperty(schema.metadata, \"description\", output);\n\n\treturn output;\n}\n\nfunction createSchemaRef(schemaId: string): JsonSchemaRef {\n\treturn {\n\t\t\"$ref\": createRefPath(schemaId),\n\t};\n}\n\nfunction createRefPath(schemaId: string): JsonRefPath {\n\treturn `#/$defs/${schemaId}`;\n}\n"]}
|
|
@@ -15,29 +15,29 @@ import { walkFieldSchema } from "../walkFieldSchema.js";
|
|
|
15
15
|
*/
|
|
16
16
|
export function createSimpleTreeIndex(view, indexer, getValue, isKeyValid, indexableSchema) {
|
|
17
17
|
const indexableSchemaMap = new Map();
|
|
18
|
-
if (indexableSchema
|
|
19
|
-
for (const schemus of indexableSchema) {
|
|
20
|
-
indexableSchemaMap.set(schemus.identifier, schemus);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
18
|
+
if (indexableSchema === undefined) {
|
|
24
19
|
walkFieldSchema(view.schema, {
|
|
25
20
|
node: (schemus) => indexableSchemaMap.set(schemus.identifier, schemus),
|
|
26
21
|
});
|
|
27
22
|
}
|
|
23
|
+
else {
|
|
24
|
+
for (const schemus of indexableSchema) {
|
|
25
|
+
indexableSchemaMap.set(schemus.identifier, schemus);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
28
|
const schemaIndexer = indexableSchema === undefined
|
|
29
29
|
? (schemaIdentifier) => {
|
|
30
30
|
// if indexable schema isn't provided, we check if the node is in schema
|
|
31
31
|
const schemus = indexableSchemaMap.get(schemaIdentifier);
|
|
32
|
-
if (schemus
|
|
32
|
+
if (schemus === undefined) {
|
|
33
|
+
fail(0xb32 /* node is out of schema */);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
33
36
|
const keyLocation = typeof indexer === "function" ? indexer(schemus) : indexer.get(schemus);
|
|
34
37
|
if (keyLocation !== undefined) {
|
|
35
38
|
return makeGenericKeyFinder(brand(keyLocation), isKeyValid);
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
else {
|
|
39
|
-
fail(0xb32 /* node is out of schema */);
|
|
40
|
-
}
|
|
41
41
|
}
|
|
42
42
|
: (schemaIdentifier) => {
|
|
43
43
|
const schemus = indexableSchemaMap.get(schemaIdentifier);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleTreeIndex.js","sourceRoot":"","sources":["../../../src/simple-tree/api/simpleTreeIndex.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAO3D,OAAO,EACN,eAAe,EACf,WAAW,EAEX,UAAU,GAIV,MAAM,kCAAkC,CAAC;AAC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AC9B,OAAO,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;IACF,CAAC;IACD,+FAA+F;IAC/F,IAAI,CACJ,CAAC;IAEF,sFAAsF;IACtF,2CAA2C;IAC3C,OAAO,KAAsC,CAAC;AAC/C,CAAC;AAED,SAAS,oBAAoB,CAC5B,QAAkB,EAClB,UAA8C;IAE9C,OAAO,CAAC,MAA+B,EAAE,EAAE;QAC1C,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5B,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,SAAS,EAAE,CAAC;QAEnB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tAnchorNode,\n\tFieldKey,\n\tITreeSubscriptionCursor,\n\tTreeNodeSchemaIdentifier,\n} from \"../../core/index.js\";\nimport {\n\tAnchorTreeIndex,\n\tisTreeValue,\n\ttype TreeIndexNodes,\n\thasElement,\n\ttype TreeIndex,\n\ttype TreeIndexKey,\n\ttype KeyFinder,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport {\n\ttreeNodeFromAnchor,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype NodeFromSchema,\n} from \"../core/index.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\nimport type { TreeView } from \"./tree.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport type { SchematizingSimpleTreeView } from \"../../shared-tree/index.js\";\n\n/**\n * A {@link TreeIndex} that returns tree nodes given their associated keys.\n *\n * @alpha\n */\nexport type SimpleTreeIndex<TKey extends TreeIndexKey, TValue> = TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TreeNodeSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: ((schema: TreeNodeSchema) => string | undefined) | Map<TreeNodeSchema, string>,\n\tgetValue:\n\t\t| ((nodes: TreeIndexNodes<TreeNode>) => TValue)\n\t\t| ((nodes: TreeIndexNodes<NodeFromSchema<TreeNodeSchema>>) => TValue),\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema?: readonly TreeNodeSchema[],\n): SimpleTreeIndex<TKey, TValue> {\n\tconst indexableSchemaMap = new Map();\n\tif (indexableSchema !== undefined) {\n\t\tfor (const schemus of indexableSchema) {\n\t\t\tindexableSchemaMap.set(schemus.identifier, schemus);\n\t\t}\n\t} else {\n\t\twalkFieldSchema(view.schema, {\n\t\t\tnode: (schemus) => indexableSchemaMap.set(schemus.identifier, schemus),\n\t\t});\n\t}\n\n\tconst schemaIndexer =\n\t\tindexableSchema === undefined\n\t\t\t? (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\t// if indexable schema isn't provided, we check if the node is in schema\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus !== undefined) {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfail(0xb32 /* node is out of schema */);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t: (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus !== undefined) {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\n\tconst index = new AnchorTreeIndex<TKey, TValue>(\n\t\t(view as SchematizingSimpleTreeView<TFieldSchema>).checkout.forest,\n\t\tschemaIndexer,\n\t\t(anchorNodes) => {\n\t\t\tconst simpleTreeNodes: TreeNode[] = [];\n\t\t\tfor (const anchorNode of anchorNodes) {\n\t\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\t\tsimpleTreeNodes.push(simpleTree);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasElement(simpleTreeNodes)) {\n\t\t\t\treturn getValue(simpleTreeNodes);\n\t\t\t}\n\t\t},\n\t\t(anchorNode: AnchorNode) => {\n\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\treturn treeNodeApi.status(simpleTree);\n\t\t\t}\n\t\t},\n\t\t// simple tree indexes are shallow indexes, indicating so allows for a performance optimization\n\t\ttrue,\n\t);\n\n\t// all the type checking guarantees that we put nodes of the correct type in the index\n\t// but it's not captured in the type system\n\treturn index as SimpleTreeIndex<TKey, TValue>;\n}\n\nfunction makeGenericKeyFinder<TKey extends TreeIndexKey>(\n\tkeyField: FieldKey,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): KeyFinder<TKey> {\n\treturn (cursor: ITreeSubscriptionCursor) => {\n\t\tcursor.enterField(keyField);\n\t\tcursor.firstNode();\n\t\tconst value = cursor.value;\n\t\tcursor.exitNode();\n\t\tcursor.exitField();\n\n\t\tif (value === undefined) {\n\t\t\tfail(0xb33 /* a value for the key does not exist */);\n\t\t}\n\n\t\tif (!isKeyValid(value)) {\n\t\t\tfail(0xb34 /* the key is an unexpected type */);\n\t\t}\n\n\t\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F,CAAC;QAED,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC,eAAe,CAAC,CAAC;QAClC,CAAC;IACF,CAAC,EACD,CAAC,UAAsB,EAAE,EAAE;QAC1B,MAAM,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,OAAO,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;IACF,CAAC;IACD,+FAA+F;IAC/F,IAAI,CACJ,CAAC;IAEF,sFAAsF;IACtF,2CAA2C;IAC3C,OAAO,KAAsC,CAAC;AAC/C,CAAC;AAED,SAAS,oBAAoB,CAC5B,QAAkB,EAClB,UAA8C;IAE9C,OAAO,CAAC,MAA+B,EAAE,EAAE;QAC1C,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5B,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,SAAS,EAAE,CAAC;QAEnB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tAnchorNode,\n\tFieldKey,\n\tITreeSubscriptionCursor,\n\tTreeNodeSchemaIdentifier,\n} from \"../../core/index.js\";\nimport {\n\tAnchorTreeIndex,\n\tisTreeValue,\n\ttype TreeIndexNodes,\n\thasElement,\n\ttype TreeIndex,\n\ttype TreeIndexKey,\n\ttype KeyFinder,\n} from \"../../feature-libraries/index.js\";\nimport { brand } from \"../../util/index.js\";\nimport type { ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport {\n\ttreeNodeFromAnchor,\n\ttype TreeNode,\n\ttype TreeNodeSchema,\n\ttype NodeFromSchema,\n} from \"../core/index.js\";\nimport { treeNodeApi } from \"./treeNodeApi.js\";\nimport type { TreeView } from \"./tree.js\";\nimport { walkFieldSchema } from \"../walkFieldSchema.js\";\nimport type { SchematizingSimpleTreeView } from \"../../shared-tree/index.js\";\n\n/**\n * A {@link TreeIndex} that returns tree nodes given their associated keys.\n *\n * @alpha\n */\nexport type SimpleTreeIndex<TKey extends TreeIndexKey, TValue> = TreeIndex<TKey, TValue>;\n\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TreeNodeSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a function that takes in a {@link TreeNodeSchema} and returns the field name that all nodes of the given schema\n * should be keyed on, must be pure and functional\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: (schema: TSchema) => string | undefined,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<TreeNode>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @param view - the view for the tree being indexed\n * @param indexer - a map from {@link TreeNodeSchema} to the field name that all nodes of the given schema\n * should be keyed on\n * @param getValue - given at least one {@link TreeNode}, returns an associated value\n * @param isKeyValid - function for verifying the validity of the key retrieved based on the information given by the indexer\n * @param indexableSchema - a list of all the schema types that can be indexed\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n\tTSchema extends TreeNodeSchema,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: Map<TreeNodeSchema, string>,\n\tgetValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema: readonly TSchema[],\n): SimpleTreeIndex<TKey, TValue>;\n/**\n * Creates a {@link SimpleTreeIndex} with a specified indexer.\n *\n * @alpha\n */\nexport function createSimpleTreeIndex<\n\tTFieldSchema extends ImplicitFieldSchema,\n\tTKey extends TreeIndexKey,\n\tTValue,\n>(\n\tview: TreeView<TFieldSchema>,\n\tindexer: ((schema: TreeNodeSchema) => string | undefined) | Map<TreeNodeSchema, string>,\n\tgetValue:\n\t\t| ((nodes: TreeIndexNodes<TreeNode>) => TValue)\n\t\t| ((nodes: TreeIndexNodes<NodeFromSchema<TreeNodeSchema>>) => TValue),\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n\tindexableSchema?: readonly TreeNodeSchema[],\n): SimpleTreeIndex<TKey, TValue> {\n\tconst indexableSchemaMap = new Map();\n\tif (indexableSchema === undefined) {\n\t\twalkFieldSchema(view.schema, {\n\t\t\tnode: (schemus) => indexableSchemaMap.set(schemus.identifier, schemus),\n\t\t});\n\t} else {\n\t\tfor (const schemus of indexableSchema) {\n\t\t\tindexableSchemaMap.set(schemus.identifier, schemus);\n\t\t}\n\t}\n\n\tconst schemaIndexer =\n\t\tindexableSchema === undefined\n\t\t\t? (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\t// if indexable schema isn't provided, we check if the node is in schema\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus === undefined) {\n\t\t\t\t\t\tfail(0xb32 /* node is out of schema */);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t: (schemaIdentifier: TreeNodeSchemaIdentifier) => {\n\t\t\t\t\tconst schemus = indexableSchemaMap.get(schemaIdentifier);\n\t\t\t\t\tif (schemus !== undefined) {\n\t\t\t\t\t\tconst keyLocation =\n\t\t\t\t\t\t\ttypeof indexer === \"function\" ? indexer(schemus) : indexer.get(schemus);\n\t\t\t\t\t\tif (keyLocation !== undefined) {\n\t\t\t\t\t\t\treturn makeGenericKeyFinder<TKey>(brand(keyLocation), isKeyValid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\n\tconst index = new AnchorTreeIndex<TKey, TValue>(\n\t\t(view as SchematizingSimpleTreeView<TFieldSchema>).checkout.forest,\n\t\tschemaIndexer,\n\t\t(anchorNodes) => {\n\t\t\tconst simpleTreeNodes: TreeNode[] = [];\n\t\t\tfor (const anchorNode of anchorNodes) {\n\t\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\t\tsimpleTreeNodes.push(simpleTree);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasElement(simpleTreeNodes)) {\n\t\t\t\treturn getValue(simpleTreeNodes);\n\t\t\t}\n\t\t},\n\t\t(anchorNode: AnchorNode) => {\n\t\t\tconst simpleTree = treeNodeFromAnchor(anchorNode);\n\t\t\tif (!isTreeValue(simpleTree)) {\n\t\t\t\treturn treeNodeApi.status(simpleTree);\n\t\t\t}\n\t\t},\n\t\t// simple tree indexes are shallow indexes, indicating so allows for a performance optimization\n\t\ttrue,\n\t);\n\n\t// all the type checking guarantees that we put nodes of the correct type in the index\n\t// but it's not captured in the type system\n\treturn index as SimpleTreeIndex<TKey, TValue>;\n}\n\nfunction makeGenericKeyFinder<TKey extends TreeIndexKey>(\n\tkeyField: FieldKey,\n\tisKeyValid: (key: TreeIndexKey) => key is TKey,\n): KeyFinder<TKey> {\n\treturn (cursor: ITreeSubscriptionCursor) => {\n\t\tcursor.enterField(keyField);\n\t\tcursor.firstNode();\n\t\tconst value = cursor.value;\n\t\tcursor.exitNode();\n\t\tcursor.exitField();\n\n\t\tif (value === undefined) {\n\t\t\tfail(0xb33 /* a value for the key does not exist */);\n\t\t}\n\n\t\tif (!isKeyValid(value)) {\n\t\t\tfail(0xb34 /* the key is an unexpected type */);\n\t\t}\n\n\t\treturn value;\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,
|
|
1
|
+
{"version":3,"file":"storedSchema.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAGN,KAAK,aAAa,EAClB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,mBAAmB,EAAE,uBAAuB,EAC5C,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,GAChD,cAAc,CAIhB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,aAAa,GACpB,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAalD"}
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { FluidClientVersion } from "../../codec/index.js";
|
|
5
|
+
import { FluidClientVersion, FormatValidatorNoOp, } from "../../codec/index.js";
|
|
6
6
|
import { SchemaFormatVersion } from "../../core/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import { clientVersionToSchemaVersion,
|
|
9
|
-
// eslint-disable-next-line import-x/no-internal-modules
|
|
10
|
-
} from "../../feature-libraries/schema-index/index.js";
|
|
7
|
+
import { makeSchemaCodec } from "../../feature-libraries/index.js";
|
|
11
8
|
import { normalizeFieldSchema } from "../fieldSchema.js";
|
|
12
9
|
import { toStoredSchema } from "../toStoredSchema.js";
|
|
13
10
|
import { TreeViewConfigurationAlpha } from "./configuration.js";
|
|
@@ -46,8 +43,8 @@ import { SchemaCompatibilityTester } from "./schemaCompatibilityTester.js";
|
|
|
46
43
|
*/
|
|
47
44
|
export function extractPersistedSchema(schema, minVersionForCollab, includeStaged) {
|
|
48
45
|
const stored = toStoredSchema(schema, { includeStaged });
|
|
49
|
-
const
|
|
50
|
-
return
|
|
46
|
+
const codec = makeSchemaCodec({ minVersionForCollab, jsonValidator: FormatValidatorNoOp });
|
|
47
|
+
return codec.encode(stored);
|
|
51
48
|
}
|
|
52
49
|
/**
|
|
53
50
|
* Compares two schema extracted using {@link extractPersistedSchema}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-tree/api/storedSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"storedSchema.js","sourceRoot":"","sources":["../../../src/simple-t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;KAClC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { MinimumVersionForCollab } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tFluidClientVersion,\n\tFormatValidatorNoOp,\n\ttype ICodecOptions,\n} from \"../../codec/index.js\";\nimport { SchemaFormatVersion } from \"../../core/index.js\";\nimport { makeSchemaCodec } from \"../../feature-libraries/index.js\";\nimport type {\n\tFormatV1,\n\t// eslint-disable-next-line import-x/no-internal-modules\n} from \"../../feature-libraries/schema-index/index.js\";\nimport type { JsonCompatible } from \"../../util/index.js\";\nimport type { SchemaUpgrade } from \"../core/index.js\";\nimport { normalizeFieldSchema, type ImplicitFieldSchema } from \"../fieldSchema.js\";\nimport { toStoredSchema } from \"../toStoredSchema.js\";\nimport { TreeViewConfigurationAlpha } from \"./configuration.js\";\n\nimport { SchemaCompatibilityTester } from \"./schemaCompatibilityTester.js\";\nimport type { SchemaCompatibilityStatus } from \"./tree.js\";\n\n/**\n * Dumps the \"persisted\" schema subset of the provided `schema` into a deterministic JSON-compatible, semi-human-readable format.\n *\n * @param schema - The schema to dump.\n * @param minVersionForCollab - The oldest client version which can read the schema: impacts the format used.\n * @param includeStaged - filter for selecting which staged allowed types to include in the output.\n *\n * @remarks\n * This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema.\n * This format is also compatible with {@link ViewContent.schema}, {@link comparePersistedSchema} and {@link persistedToSimpleSchema}.\n *\n * This only includes the \"persisted\" subset of schema information, which means the portion which gets included in documents.\n * It thus uses \"persisted\" keys, see {@link FieldProps.key}.\n *\n * If two schema have identical \"persisted\" schema, then they are considered {@link SchemaCompatibilityStatus.isEquivalent|equivalent}.\n *\n * See also {@link comparePersistedSchema}.\n *\n * @example\n * An application could use this API to generate a `schema.json` file when it first releases,\n * then test that the schema is sill compatible with documents from that version with a test like :\n * ```typescript\n * assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require(\"./schema.json\"));\n * ```\n *\n * @privateRemarks\n * This currently uses the schema summary format, but that could be changed to something more human readable (particularly if the encoded format becomes less human readable).\n * This intentionally does not leak the format types in the API.\n *\n * Public API surface uses \"persisted\" terminology while internally we use \"stored\".\n * @alpha\n */\nexport function extractPersistedSchema(\n\tschema: ImplicitFieldSchema,\n\tminVersionForCollab: MinimumVersionForCollab,\n\tincludeStaged: (upgrade: SchemaUpgrade) => boolean,\n): JsonCompatible {\n\tconst stored = toStoredSchema(schema, { includeStaged });\n\tconst codec = makeSchemaCodec({ minVersionForCollab, jsonValidator: FormatValidatorNoOp });\n\treturn codec.encode(stored) as JsonCompatible;\n}\n\n/**\n * Compares two schema extracted using {@link extractPersistedSchema}.\n * Reports the same compatibility that {@link TreeView.compatibility} would report if\n * opening a document that used the `persisted` schema and provided `view` to {@link ViewableTree.viewWith}.\n *\n * @param persisted - Schema persisted for a document. Typically persisted alongside the data and assumed to describe that data.\n * @param view - Schema which would be used to view persisted content.\n * @param options - {@link ICodecOptions} used when parsing the provided schema.\n * @param canInitialize - Passed through to the return value unchanged and otherwise unused.\n * @returns The {@link SchemaCompatibilityStatus} a {@link TreeView} would report for this combination of schema.\n *\n * @remarks\n * This uses the persisted formats for schema, meaning it only includes data which impacts compatibility.\n * It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.\n *\n * @example\n * An application could use {@link extractPersistedSchema} to generate a `schema.json` file for various versions of the app,\n * then test that documents using those schema can be upgraded to work with the current schema using a test like:\n * ```typescript\n * assert(\n * \tcomparePersistedSchema(\n * \t\trequire(\"./schema.json\"),\n * \t\tMySchema,\n * \t\t{ jsonValidator: typeboxValidator },\n * \t\tfalse,\n * \t).canUpgrade,\n * );\n * ```\n * @alpha\n */\nexport function comparePersistedSchema(\n\tpersisted: JsonCompatible,\n\tview: ImplicitFieldSchema,\n\toptions: ICodecOptions,\n): Omit<SchemaCompatibilityStatus, \"canInitialize\"> {\n\t// Any version can be passed down to makeSchemaCodec here.\n\t// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.\n\tconst schemaCodec = makeSchemaCodec(\n\t\t{ ...options, minVersionForCollab: FluidClientVersion.v2_0 },\n\t\tSchemaFormatVersion.v1,\n\t);\n\tconst stored = schemaCodec.decode(persisted as FormatV1);\n\tconst config = new TreeViewConfigurationAlpha({\n\t\tschema: normalizeFieldSchema(view),\n\t});\n\tconst viewSchema = new SchemaCompatibilityTester(config);\n\treturn viewSchema.checkCompatibility(stored);\n}\n"]}
|
|
@@ -19,6 +19,11 @@ export declare const rollback: unique symbol;
|
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
21
21
|
export type TransactionConstraint = NodeInDocumentConstraint;
|
|
22
|
+
/**
|
|
23
|
+
* Type for alpha version {@link TransactionConstraint | constraint}s
|
|
24
|
+
* @sealed @alpha
|
|
25
|
+
*/
|
|
26
|
+
export type TransactionConstraintAlpha = TransactionConstraint | NoChangeConstraint;
|
|
22
27
|
/**
|
|
23
28
|
* A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.
|
|
24
29
|
* @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as "existing".
|
|
@@ -28,6 +33,14 @@ export interface NodeInDocumentConstraint {
|
|
|
28
33
|
readonly type: "nodeInDocument";
|
|
29
34
|
readonly node: TreeNode;
|
|
30
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A {@link TransactionConstraintAlpha | constraint} which requires that, for this transaction to apply, the document must be in the same state immediately before the transaction is applied as it was before the transaction was authored.
|
|
38
|
+
* When used as a revert precondition it requires that, for the revert to apply, the document must be in the same state immediately before the revert is applied as it was after the transaction was applied.
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
export interface NoChangeConstraint {
|
|
42
|
+
readonly type: "noChange";
|
|
43
|
+
}
|
|
31
44
|
/**
|
|
32
45
|
* The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.
|
|
33
46
|
* @alpha
|
|
@@ -44,13 +57,13 @@ export type TransactionCallbackStatus<TSuccessValue, TFailureValue> = ({
|
|
|
44
57
|
value: TFailureValue;
|
|
45
58
|
}) & {
|
|
46
59
|
/**
|
|
47
|
-
* An optional list of {@link
|
|
60
|
+
* An optional list of {@link TransactionConstraintAlpha | constraints} that will be checked when the commit corresponding
|
|
48
61
|
* to this transaction is reverted. If any of these constraints are not met when the revert is being applied either
|
|
49
62
|
* locally or on remote clients, the revert will be ignored.
|
|
50
63
|
* These constraints must also be met at the time they are first introduced. If they are not met after the transaction
|
|
51
64
|
* callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.
|
|
52
65
|
*/
|
|
53
|
-
preconditionsOnRevert?: readonly
|
|
66
|
+
preconditionsOnRevert?: readonly TransactionConstraintAlpha[];
|
|
54
67
|
};
|
|
55
68
|
/**
|
|
56
69
|
* The status of a the transaction callback in the {@link RunTransaction | RunTransaction} API where the transaction doesn't
|
|
@@ -96,11 +109,11 @@ export type TransactionResult = Omit<TransactionResultSuccess<unknown>, "value">
|
|
|
96
109
|
*/
|
|
97
110
|
export interface RunTransactionParams {
|
|
98
111
|
/**
|
|
99
|
-
* An optional list of {@link
|
|
112
|
+
* An optional list of {@link TransactionConstraintAlpha | constraints} that are checked just before the transaction begins.
|
|
100
113
|
* If any of the constraints are not met when `runTransaction` is called, an error will be thrown.
|
|
101
114
|
* If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on
|
|
102
115
|
* this client and ignored by all other clients.
|
|
103
116
|
*/
|
|
104
|
-
readonly preconditions?: readonly
|
|
117
|
+
readonly preconditions?: readonly TransactionConstraintAlpha[];
|
|
105
118
|
}
|
|
106
119
|
//# sourceMappingURL=transactionTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionTypes.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/transactionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,QAAQ,eAA4C,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,aAAa,EAAE,aAAa,IAAI,CACnE;IACA,gEAAgE;IAChE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,oEAAoE;IACpE,KAAK,EAAE,aAAa,CAAC;CACpB,GACD;IACA,gGAAgG;IAChG,QAAQ,EAAE,IAAI,CAAC;IACf,0DAA0D;IAC1D,KAAK,EAAE,aAAa,CAAC;CACpB,CACH,GAAG;IACH;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"transactionTypes.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/transactionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,QAAQ,eAA4C,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;AAEpF;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAA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AC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;CAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionTypes.js","sourceRoot":"","sources":["../../../src/simple-tree/api/transactionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,iCAAiC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNode } from \"../core/index.js\";\n\n/**\n * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should \"roll back\".\n * @public\n */\nexport const rollback = Symbol(\"SharedTree Transaction Rollback\");\n\n/**\n * A requirement for a SharedTree transaction to succeed.\n * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.\n * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.\n * However, they cannot know what the tree state will be when the transaction is _sequenced_.\n * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.\n * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.\n * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.\n * @public\n */\nexport type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here\n\n/**\n * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.\n * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as \"existing\".\n * @public\n */\nexport interface NodeInDocumentConstraint {\n\treadonly type: \"nodeInDocument\";\n\treadonly node: TreeNode;\n}\n\n/**\n * The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (\n\t| {\n\t\t\t/** Indicates that the transaction callback ran successfully. */\n\t\t\trollback?: false;\n\t\t\t/** The user defined value when the transaction ran successfully. */\n\t\t\tvalue: TSuccessValue;\n\t }\n\t| {\n\t\t\t/** Indicates that the transaction callback failed and the transaction should be rolled back. */\n\t\t\trollback: true;\n\t\t\t/** The user defined value when the transaction failed. */\n\t\t\tvalue: TFailureValue;\n\t }\n) & {\n\t/**\n\t * An optional list of {@link
|
|
1
|
+
{"version":3,"file":"transactionTypes.js","sourceRoot":"","sources":["../../../src/simple-tree/api/transactionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,iCAAiC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TreeNode } from \"../core/index.js\";\n\n/**\n * A special object that signifies when a SharedTree {@link RunTransaction | transaction} should \"roll back\".\n * @public\n */\nexport const rollback = Symbol(\"SharedTree Transaction Rollback\");\n\n/**\n * A requirement for a SharedTree transaction to succeed.\n * @remarks Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs.\n * In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not.\n * However, they cannot know what the tree state will be when the transaction is _sequenced_.\n * There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced.\n * Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met.\n * All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.\n * @public\n */\nexport type TransactionConstraint = NodeInDocumentConstraint; // TODO: Add more constraint types here\n\n/**\n * Type for alpha version {@link TransactionConstraint | constraint}s\n * @sealed @alpha\n */\nexport type TransactionConstraintAlpha = TransactionConstraint | NoChangeConstraint; // TODO: Add more constraint types here\n\n/**\n * A transaction {@link TransactionConstraint | constraint} which requires that the given node exists in the tree.\n * @remarks The node must be in the document (its {@link TreeStatus | status} must be {@link TreeStatus.InDocument | InDocument}) to qualify as \"existing\".\n * @public\n */\nexport interface NodeInDocumentConstraint {\n\treadonly type: \"nodeInDocument\";\n\treadonly node: TreeNode;\n}\n\n/**\n * A {@link TransactionConstraintAlpha | constraint} which requires that, for this transaction to apply, the document must be in the same state immediately before the transaction is applied as it was before the transaction was authored.\n * When used as a revert precondition it requires that, for the revert to apply, the document must be in the same state immediately before the revert is applied as it was after the transaction was applied.\n * @alpha\n */\nexport interface NoChangeConstraint {\n\treadonly type: \"noChange\";\n}\n\n/**\n * The status of the transaction callback in the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport type TransactionCallbackStatus<TSuccessValue, TFailureValue> = (\n\t| {\n\t\t\t/** Indicates that the transaction callback ran successfully. */\n\t\t\trollback?: false;\n\t\t\t/** The user defined value when the transaction ran successfully. */\n\t\t\tvalue: TSuccessValue;\n\t }\n\t| {\n\t\t\t/** Indicates that the transaction callback failed and the transaction should be rolled back. */\n\t\t\trollback: true;\n\t\t\t/** The user defined value when the transaction failed. */\n\t\t\tvalue: TFailureValue;\n\t }\n) & {\n\t/**\n\t * An optional list of {@link TransactionConstraintAlpha | constraints} that will be checked when the commit corresponding\n\t * to this transaction is reverted. If any of these constraints are not met when the revert is being applied either\n\t * locally or on remote clients, the revert will be ignored.\n\t * These constraints must also be met at the time they are first introduced. If they are not met after the transaction\n\t * callback returns, then `runTransaction` (which invokes the transaction callback) will throw a `UsageError`.\n\t */\n\tpreconditionsOnRevert?: readonly TransactionConstraintAlpha[];\n};\n\n/**\n * The status of a the transaction callback in the {@link RunTransaction | RunTransaction} API where the transaction doesn't\n * need to return a value. This is the same as {@link TransactionCallbackStatus} but with the `value` field omitted. This\n * @alpha\n */\nexport type VoidTransactionCallbackStatus = Omit<\n\tTransactionCallbackStatus<unknown, unknown>,\n\t\"value\"\n>;\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API when it was successful.\n * @alpha\n */\nexport interface TransactionResultSuccess<TSuccessValue> {\n\t/** Indicates that the transaction was successful. */\n\tsuccess: true;\n\t/** The user defined value when the transaction was successful. */\n\tvalue: TSuccessValue;\n}\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API when it failed.\n * @alpha\n */\nexport interface TransactionResultFailed<TFailureValue> {\n\t/** Indicates that the transaction failed. */\n\tsuccess: false;\n\t/** The user defined value when the transaction failed. */\n\tvalue: TFailureValue;\n}\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API.\n * @alpha\n */\nexport type TransactionResultExt<TSuccessValue, TFailureValue> =\n\t| TransactionResultSuccess<TSuccessValue>\n\t| TransactionResultFailed<TFailureValue>;\n\n/**\n * The result of the {@link RunTransaction | RunTransaction} API. This is the same as {@link TransactionResultExt}\n * but with the `value` field omitted. This is useful when the transaction callback doesn't need to return a value.\n * @alpha\n */\nexport type TransactionResult =\n\t| Omit<TransactionResultSuccess<unknown>, \"value\">\n\t| Omit<TransactionResultFailed<unknown>, \"value\">;\n\n/**\n * The parameters for the {@link RunTransaction | RunTransaction} API.\n * @alpha\n * @input\n */\nexport interface RunTransactionParams {\n\t/**\n\t * An optional list of {@link TransactionConstraintAlpha | constraints} that are checked just before the transaction begins.\n\t * If any of the constraints are not met when `runTransaction` is called, an error will be thrown.\n\t * If any of the constraints are not met after the transaction has been ordered by the service, it will be rolled back on\n\t * this client and ignored by all other clients.\n\t */\n\treadonly preconditions?: readonly TransactionConstraintAlpha[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeNodeApi.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,KAAK,UAAU,EAA2B,MAAM,kCAAkC,CAAC;AAa5F,OAAO,EAGN,KAAK,cAAc,EAEnB,KAAK,QAAQ,EAKb,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EAErC,MAAM,kBA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qBAAqB,CACpC,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,YAAY,GACvB,MAAM,GAAG,SAAS,CAAC;AACtB,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,cAAc,GACzB,MAAM,GAAG,SAAS,CAAC;AA8DtB;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAgB5D;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,GAAG,MAAM,GACxB,MAAM,GAAG,MAAM,CAyBjB"}
|
|
@@ -67,8 +67,9 @@ export const treeNodeApi = {
|
|
|
67
67
|
case "treeChanged": {
|
|
68
68
|
return kernel.events.on("subtreeChangedAfterBatch", () => listener({}));
|
|
69
69
|
}
|
|
70
|
-
default:
|
|
70
|
+
default: {
|
|
71
71
|
throw new UsageError(`No event named ${JSON.stringify(eventName)}.`);
|
|
72
|
+
}
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
75
|
status(node) {
|
|
@@ -97,12 +98,15 @@ export const treeNodeApi = {
|
|
|
97
98
|
*/
|
|
98
99
|
export function tryGetSchema(value) {
|
|
99
100
|
switch (typeof value) {
|
|
100
|
-
case "string":
|
|
101
|
+
case "string": {
|
|
101
102
|
return stringSchema;
|
|
102
|
-
|
|
103
|
+
}
|
|
104
|
+
case "number": {
|
|
103
105
|
return numberSchema;
|
|
104
|
-
|
|
106
|
+
}
|
|
107
|
+
case "boolean": {
|
|
105
108
|
return booleanSchema;
|
|
109
|
+
}
|
|
106
110
|
case "object": {
|
|
107
111
|
if (isTreeNode(value)) {
|
|
108
112
|
// TODO: This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.
|
|
@@ -115,8 +119,9 @@ export function tryGetSchema(value) {
|
|
|
115
119
|
return handleSchema;
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
|
-
default:
|
|
122
|
+
default: {
|
|
119
123
|
return undefined;
|
|
124
|
+
}
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
127
|
export function getIdentifierFromNode(node, compression) {
|
|
@@ -127,8 +132,9 @@ export function getIdentifierFromNode(node, compression) {
|
|
|
127
132
|
const flexNode = getInnerNode(node);
|
|
128
133
|
const identifierFieldKeys = schema.identifierFieldKeys;
|
|
129
134
|
switch (identifierFieldKeys.length) {
|
|
130
|
-
case 0:
|
|
135
|
+
case 0: {
|
|
131
136
|
return undefined;
|
|
137
|
+
}
|
|
132
138
|
case 1: {
|
|
133
139
|
const key = identifierFieldKeys[0] ?? oob();
|
|
134
140
|
const identifierField = flexNode.tryGetField(key);
|
|
@@ -140,9 +146,9 @@ export function getIdentifierFromNode(node, compression) {
|
|
|
140
146
|
case "preferCompressed": {
|
|
141
147
|
if (context.isHydrated()) {
|
|
142
148
|
const localNodeKey = context.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);
|
|
143
|
-
return localNodeKey
|
|
144
|
-
?
|
|
145
|
-
:
|
|
149
|
+
return localNodeKey === undefined
|
|
150
|
+
? identifierValue
|
|
151
|
+
: extractFromOpaque(localNodeKey);
|
|
146
152
|
}
|
|
147
153
|
else {
|
|
148
154
|
return identifierValue;
|
|
@@ -151,7 +157,7 @@ export function getIdentifierFromNode(node, compression) {
|
|
|
151
157
|
case "compressed": {
|
|
152
158
|
if (context.isHydrated()) {
|
|
153
159
|
const localNodeKey = context.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);
|
|
154
|
-
return localNodeKey
|
|
160
|
+
return localNodeKey === undefined ? undefined : extractFromOpaque(localNodeKey);
|
|
155
161
|
}
|
|
156
162
|
else {
|
|
157
163
|
return undefined;
|
|
@@ -160,12 +166,14 @@ export function getIdentifierFromNode(node, compression) {
|
|
|
160
166
|
case "uncompressed": {
|
|
161
167
|
return identifierValue;
|
|
162
168
|
}
|
|
163
|
-
default:
|
|
169
|
+
default: {
|
|
164
170
|
unreachableCase(compression);
|
|
171
|
+
}
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
|
-
default:
|
|
168
|
-
throw new UsageError("
|
|
174
|
+
default: {
|
|
175
|
+
throw new UsageError("The node has more than one identifier. Retrieve identifiers individually via their fields instead.");
|
|
176
|
+
}
|
|
169
177
|
}
|
|
170
178
|
}
|
|
171
179
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeNodeApi.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAmB,WAAW,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAA4B,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACN,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,SAAS,EACT,UAAU,EAEV,QAAQ,EAER,oBAAoB,EACpB,4BAA4B,EAC5B,gBAAgB,EAChB,YAAY,EAIZ,qBAAqB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAoGnE;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAgB;IACvC,MAAM,CAAC,IAAc;QACpB,MAAM,QAAQ,GAAG,Y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E,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,IAAI,WAAW,YAAY,WAAW,IAAI,WAAW,CAAC,KAAK,EAAE,GAAG,KAAK,SAAS,EAAE,CAAC;YAChF,OAAO,WAAW,CAAC;QACpB,CAAC;IACF,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport { EmptyKey, rootFieldKey } from \"../../core/index.js\";\nimport { type TreeStatus, isTreeValue, FieldKinds } from \"../../feature-libraries/index.js\";\nimport { extractFromOpaque } from \"../../util/index.js\";\nimport { type ImplicitFieldSchema, FieldSchema } from \"../fieldSchema.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Off } from \"@fluidframework/core-interfaces\";\nimport {\n\tgetKernel,\n\tisTreeNode,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNode,\n\ttryGetTreeNodeSchema,\n\tgetOrCreateNodeFromInnerNode,\n\ttypeSchemaSymbol,\n\tgetInnerNode,\n\ttype TreeLeafValue,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n} from \"../core/index.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { isArrayNodeSchema, isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport { tryGetTreeNodeForField } from \"../getTreeNodeForField.js\";\n\n/**\n * Provides various functions for analyzing {@link TreeNode}s.\n *\n * @remarks\n * With the exception of {@link TreeNodeApi.status}, these functions should not be called with nodes that have\n * been {@link TreeStatus.Deleted | deleted}.\n * To verify whether or not a node already has been deleted, use the {@link TreeNodeApi.status} function.\n *\n * This type should only be used via the public {@link (Tree:variable)} export.\n *\n * @privateRemarks\n * Due to limitations of API-Extractor link resolution, this type can't be moved into internalTypes but should be considered just an implementation detail of the `Tree` export.\n *\n * Inlining the typing of this interface onto the `Tree` object provides slightly different .d.ts generation,\n * which avoids typescript expanding the type of TreeNodeSchema and thus encountering\n * https://github.com/microsoft/rushstack/issues/1958.\n * @sealed @public\n */\nexport interface TreeNodeApi {\n\t/**\n\t * The schema information for this node.\n\t */\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema;\n\n\t/**\n\t * Narrow the type of the given value if it satisfies the given schema.\n\t * @example\n\t * ```ts\n\t * if (node.is(myNode, Point)) {\n\t * const y = myNode.y; // `myNode` is now known to satisfy the `Point` schema and therefore has a `y` coordinate.\n\t * }\n\t * ```\n\t */\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema>;\n\n\t/**\n\t * Return the node under which this node resides in the tree (or undefined if this is a root node of the tree).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t *\n\t * @see {@link (TreeAlpha:interface).child}\n\t * @see {@link (TreeAlpha:interface).children}\n\t */\n\tparent(node: TreeNode): TreeNode | undefined;\n\n\t/**\n\t * The key of the given node under its parent.\n\t *\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t */\n\tkey(node: TreeNode): string | number;\n\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): () => void;\n\n\t/**\n\t * Returns the {@link TreeStatus} of the given node.\n\t */\n\tstatus(node: TreeNode): TreeStatus;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.\n\t * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return that string.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.\n\t * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.\n\t */\n\tshortId(node: TreeNode): number | string | undefined;\n}\n\n/**\n * {@inheritDoc TreeNodeApi}\n */\nexport const treeNodeApi: TreeNodeApi = {\n\tparent(node: TreeNode): TreeNode | undefined {\n\t\tconst editNode = getInnerNode(node).parentField.parent.parent;\n\t\tif (editNode === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = getOrCreateNodeFromInnerNode(editNode);\n\t\tassert(\n\t\t\t!isTreeValue(output),\n\t\t\t0x87f /* Parent can't be a leaf, so it should be a node not a value */,\n\t\t);\n\t\treturn output;\n\t},\n\tkey(node: TreeNode): string | number {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\t// so we know its key is the special root one.\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn rootFieldKey;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\tconst propertyKey = getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t\treturn propertyKey;\n\t},\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): Off {\n\t\tconst kernel = getKernel(node);\n\t\tswitch (eventName) {\n\t\t\tcase \"nodeChanged\": {\n\t\t\t\tconst nodeSchema = kernel.schema;\n\t\t\t\tif (isObjectNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tconst changedProperties = new Set(\n\t\t\t\t\t\t\tArray.from(\n\t\t\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t\t\t\t(field) =>\n\t\t\t\t\t\t\t\t\tnodeSchema.storedKeyToPropertyKey.get(field) ??\n\t\t\t\t\t\t\t\t\tfail(0xb36 /* Could not find stored key in schema. */),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlistener({ changedProperties });\n\t\t\t\t\t});\n\t\t\t\t} else if (isArrayNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", () => {\n\t\t\t\t\t\tlistener({ changedProperties: undefined });\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tlistener({ changedProperties: changedFields });\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase \"treeChanged\": {\n\t\t\t\treturn kernel.events.on(\"subtreeChangedAfterBatch\", () => listener({}));\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new UsageError(`No event named ${JSON.stringify(eventName)}.`);\n\t\t}\n\t},\n\tstatus(node: TreeNode): TreeStatus {\n\t\treturn getKernel(node).getStatus();\n\t},\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema> {\n\t\t// This \"is\" utility would return false if the provided schema is a base type of the actual schema.\n\t\t// This could be confusing, and that case can only be hit when violating the rule that there is a single most derived schema that gets used (See documentation on TreeNodeSchemaClass).\n\t\t// Therefore this uses markSchemaMostDerived to ensure an informative usage error is thrown in the case where a base type is used.\n\n\t\tconst actualSchema = tryGetSchema(value);\n\t\tif (actualSchema === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn normalizeAllowedTypes(schema).evaluateSet().has(actualSchema);\n\t},\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema {\n\t\treturn tryGetSchema(node) ?? fail(0xb37 /* Not a tree node */);\n\t},\n\tshortId(node: TreeNode): number | string | undefined {\n\t\treturn getIdentifierFromNode(node, \"preferCompressed\");\n\t},\n};\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.\n * Returns undefined for other values.\n */\nexport function tryGetSchema(value: unknown): undefined | TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"string\":\n\t\t\treturn stringSchema;\n\t\tcase \"number\":\n\t\t\treturn numberSchema;\n\t\tcase \"boolean\":\n\t\t\treturn booleanSchema;\n\t\tcase \"object\": {\n\t\t\tif (isTreeNode(value)) {\n\t\t\t\t// TODO: This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.\n\t\t\t\treturn tryGetTreeNodeSchema(value);\n\t\t\t}\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tif (isFluidHandle(value)) {\n\t\t\t\treturn handleSchema;\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\n/**\n * Gets the identifier from a node.\n *\n * @param node - {@link TreeNode} where you want to extract the identifier from.\n * @param compression - string value to determine what type of identifier you want to retrieve.\n *\n * @remarks\n * If the node does not contain an identifier field, it returns undefined.\n *\n * If `compression` is set to `compressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, `undefined` is returned.\n *\n * If `compression` is set to `preferCompressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, the uncompressed identifier is returned.\n *\n * If `compression` is set to `uncompressed`:\n * - If the node contains an identifier field, the uncompressed identifier is returned.\n */\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\",\n): number | string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"compressed\",\n): number | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"uncompressed\",\n): string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\" | \"compressed\" | \"uncompressed\",\n): number | string | undefined {\n\tconst schema = node[typeSchemaSymbol];\n\tif (!isObjectNodeSchema(schema)) {\n\t\treturn undefined;\n\t}\n\n\tconst flexNode = getInnerNode(node);\n\tconst identifierFieldKeys = schema.identifierFieldKeys;\n\n\tswitch (identifierFieldKeys.length) {\n\t\tcase 0:\n\t\t\treturn undefined;\n\t\tcase 1: {\n\t\t\tconst key = identifierFieldKeys[0] ?? oob();\n\t\t\tconst identifierField = flexNode.tryGetField(key);\n\t\t\tassert(identifierField !== undefined, 0xbb5 /* missing identifier field */);\n\t\t\tconst identifierValue = tryGetTreeNodeForField(identifierField);\n\t\t\tassert(typeof identifierValue === \"string\", 0xbb6 /* identifier not a string */);\n\n\t\t\tconst context = flexNode.context;\n\t\t\tswitch (compression) {\n\t\t\t\tcase \"preferCompressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey !== undefined\n\t\t\t\t\t\t\t? extractFromOpaque(localNodeKey)\n\t\t\t\t\t\t\t: identifierValue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn identifierValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"compressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey !== undefined ? extractFromOpaque(localNodeKey) : undefined;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"uncompressed\": {\n\t\t\t\t\treturn identifierValue;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(compression);\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\tthrow new UsageError(\n\t\t\t\t\"shortId() may not be called on a node with more than one identifier. Consider converting extraneous identifier fields to string fields.\",\n\t\t\t);\n\t}\n}\n\n/**\n * Gets the stored key with which the provided node is associated in the parent.\n */\nexport function getStoredKey(node: TreeNode): string | number {\n\t// Note: the flex domain strictly works with \"stored keys\", and knows nothing about the developer-facing\n\t// \"property keys\".\n\tconst parentField = getInnerNode(node).parentField;\n\tif (parentField.parent.schema === FieldKinds.sequence.identifier) {\n\t\t// The parent of `node` is an array node\n\t\tassert(\n\t\t\tparentField.parent.key === EmptyKey,\n\t\t\t0xa28 /* When using index as key, field should use EmptyKey */,\n\t\t);\n\t\treturn parentField.index;\n\t}\n\n\t// The parent of `node` is an object, a map, or undefined. If undefined, then `node` is a root/detached node.\n\tassert(parentField.index === 0, 0xa29 /* When using field key as key, index should be 0 */);\n\treturn parentField.parent.key;\n}\n\n/**\n * Given a node schema, gets the property key corresponding with the provided {@link FieldProps.key | stored key}.\n */\nexport function getPropertyKeyFromStoredKey(\n\tschema: TreeNodeSchema,\n\tstoredKey: string | number,\n): string | number {\n\t// Only object nodes have the concept of a \"stored key\", differentiated from the developer-facing \"property key\".\n\t// For any other kind of node, the stored key and the property key are the same.\n\tif (schema.kind !== NodeKind.Object) {\n\t\treturn storedKey;\n\t}\n\n\tconst fields = schema.info as Record<string, ImplicitFieldSchema>;\n\n\t// Invariants:\n\t// - The set of all property keys under an object must be unique.\n\t// - The set of all stored keys (including those implicitly created from property keys) must be unique.\n\t// To find the property key associated with the provided stored key, first check for any stored key matches (which are optionally populated).\n\t// If we don't find any, then search for a matching property key.\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tif (fieldSchema instanceof FieldSchema && fieldSchema.props?.key === storedKey) {\n\t\t\treturn propertyKey;\n\t\t}\n\t}\n\n\tif (fields[storedKey] === undefined) {\n\t\tfail(0xb38 /* Existing stored key should always map to a property key */);\n\t}\n\n\treturn storedKey;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"treeNodeApi.js","sourceRoot":"","sources":["../../../src/simple-tree/api/treeNodeApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEzF,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,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AAM,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, oob, fail, unreachableCase } from \"@fluidframework/core-utils/internal\";\n\nimport { EmptyKey, rootFieldKey } from \"../../core/index.js\";\nimport { type TreeStatus, isTreeValue, FieldKinds } from \"../../feature-libraries/index.js\";\nimport { extractFromOpaque } from \"../../util/index.js\";\nimport { type ImplicitFieldSchema, FieldSchema } from \"../fieldSchema.js\";\nimport {\n\tbooleanSchema,\n\thandleSchema,\n\tnullSchema,\n\tnumberSchema,\n\tstringSchema,\n} from \"../leafNodeSchema.js\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Off } from \"@fluidframework/core-interfaces\";\nimport {\n\tgetKernel,\n\tisTreeNode,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype TreeNode,\n\ttryGetTreeNodeSchema,\n\tgetOrCreateNodeFromInnerNode,\n\ttypeSchemaSymbol,\n\tgetInnerNode,\n\ttype TreeLeafValue,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n} from \"../core/index.js\";\nimport type { TreeChangeEvents } from \"./treeChangeEvents.js\";\nimport { isArrayNodeSchema, isObjectNodeSchema } from \"../node-kinds/index.js\";\nimport { tryGetTreeNodeForField } from \"../getTreeNodeForField.js\";\n\n/**\n * Provides various functions for analyzing {@link TreeNode}s.\n *\n * @remarks\n * With the exception of {@link TreeNodeApi.status}, these functions should not be called with nodes that have\n * been {@link TreeStatus.Deleted | deleted}.\n * To verify whether or not a node already has been deleted, use the {@link TreeNodeApi.status} function.\n *\n * This type should only be used via the public {@link (Tree:variable)} export.\n *\n * @privateRemarks\n * Due to limitations of API-Extractor link resolution, this type can't be moved into internalTypes but should be considered just an implementation detail of the `Tree` export.\n *\n * Inlining the typing of this interface onto the `Tree` object provides slightly different .d.ts generation,\n * which avoids typescript expanding the type of TreeNodeSchema and thus encountering\n * https://github.com/microsoft/rushstack/issues/1958.\n * @sealed @public\n */\nexport interface TreeNodeApi {\n\t/**\n\t * The schema information for this node.\n\t */\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema;\n\n\t/**\n\t * Narrow the type of the given value if it satisfies the given schema.\n\t * @example\n\t * ```ts\n\t * if (node.is(myNode, Point)) {\n\t * const y = myNode.y; // `myNode` is now known to satisfy the `Point` schema and therefore has a `y` coordinate.\n\t * }\n\t * ```\n\t */\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema>;\n\n\t/**\n\t * Return the node under which this node resides in the tree (or undefined if this is a root node of the tree).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t *\n\t * @see {@link (TreeAlpha:interface).child}\n\t * @see {@link (TreeAlpha:interface).children}\n\t */\n\tparent(node: TreeNode): TreeNode | undefined;\n\n\t/**\n\t * The key of the given node under its parent.\n\t *\n\t * @remarks\n\t * If `node` is an element in a {@link (TreeArrayNode:interface)}, this returns the index of `node` in the array node (a `number`).\n\t * Otherwise, this returns the key of the field that it is under (a `string`).\n\t *\n\t * @throws A {@link @fluidframework/telemetry-utils#UsageError} if the node has been {@link TreeStatus.Deleted | deleted}.\n\t */\n\tkey(node: TreeNode): string | number;\n\n\t/**\n\t * Register an event listener on the given node.\n\t * @param node - The node whose events should be subscribed to.\n\t * @param eventName - Which event to subscribe to.\n\t * @param listener - The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback.\n\t * @returns A callback function which will deregister the event.\n\t * This callback should be called only once.\n\t */\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): () => void;\n\n\t/**\n\t * Returns the {@link TreeStatus} of the given node.\n\t */\n\tstatus(node: TreeNode): TreeStatus;\n\n\t/**\n\t * Returns the {@link SchemaFactory.identifier | identifier} of the given node in the most compressed form possible.\n\t * @remarks\n\t * If the node is {@link Unhydrated | hydrated} and its identifier is a valid UUID that was automatically generated by the SharedTree it is part of (or something else using the same {@link @fluidframework/id-compressor#IIdCompressor}), then this will return a process-unique integer corresponding to that identifier.\n\t * This is useful for performance-sensitive scenarios involving many nodes with identifiers that need to be compactly retained in memory or used for efficient lookup.\n\t * Note that automatically generated identifiers that were accessed before the node was hydrated will return the generated UUID, not the process-unique integer.\n\t *\n\t * If the node's identifier is any other user-provided string, then this will return that string.\n\t *\n\t * If the node has no identifier (that is, it has no {@link SchemaFactory.identifier | identifier} field), then this returns `undefined`.\n\t *\n\t * If the node has more than one identifier, then this will throw an error.\n\t *\n\t * The returned integer should not be serialized or preserved outside of the current process.\n\t * Its lifetime is that of the current in-memory instance of the FF container for this client, and it is not guaranteed to be unique or stable outside of that context.\n\t * The same node's identifier may, for example, be different across multiple sessions for the same client and document, or different across two clients in the same session.\n\t */\n\tshortId(node: TreeNode): number | string | undefined;\n}\n\n/**\n * {@inheritDoc TreeNodeApi}\n */\nexport const treeNodeApi: TreeNodeApi = {\n\tparent(node: TreeNode): TreeNode | undefined {\n\t\tconst editNode = getInnerNode(node).parentField.parent.parent;\n\t\tif (editNode === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = getOrCreateNodeFromInnerNode(editNode);\n\t\tassert(\n\t\t\t!isTreeValue(output),\n\t\t\t0x87f /* Parent can't be a leaf, so it should be a node not a value */,\n\t\t);\n\t\treturn output;\n\t},\n\tkey(node: TreeNode): string | number {\n\t\t// If the parent is undefined, then this node is under the root field,\n\t\t// so we know its key is the special root one.\n\t\tconst parent = treeNodeApi.parent(node);\n\t\tif (parent === undefined) {\n\t\t\treturn rootFieldKey;\n\t\t}\n\n\t\t// The flex-domain strictly operates in terms of \"stored keys\".\n\t\t// To find the associated developer-facing \"property key\", we need to look up the field associated with\n\t\t// the stored key from the flex-domain, and get property key its simple-domain counterpart was created with.\n\t\tconst storedKey = getStoredKey(node);\n\t\tconst parentSchema = treeNodeApi.schema(parent);\n\t\tconst propertyKey = getPropertyKeyFromStoredKey(parentSchema, storedKey);\n\t\treturn propertyKey;\n\t},\n\ton<K extends keyof TreeChangeEvents>(\n\t\tnode: TreeNode,\n\t\teventName: K,\n\t\tlistener: TreeChangeEvents[K],\n\t): Off {\n\t\tconst kernel = getKernel(node);\n\t\tswitch (eventName) {\n\t\t\tcase \"nodeChanged\": {\n\t\t\t\tconst nodeSchema = kernel.schema;\n\t\t\t\tif (isObjectNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tconst changedProperties = new Set(\n\t\t\t\t\t\t\tArray.from(\n\t\t\t\t\t\t\t\tchangedFields,\n\t\t\t\t\t\t\t\t(field) =>\n\t\t\t\t\t\t\t\t\tnodeSchema.storedKeyToPropertyKey.get(field) ??\n\t\t\t\t\t\t\t\t\tfail(0xb36 /* Could not find stored key in schema. */),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlistener({ changedProperties });\n\t\t\t\t\t});\n\t\t\t\t} else if (isArrayNodeSchema(nodeSchema)) {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", () => {\n\t\t\t\t\t\tlistener({ changedProperties: undefined });\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn kernel.events.on(\"childrenChangedAfterBatch\", ({ changedFields }) => {\n\t\t\t\t\t\tlistener({ changedProperties: changedFields });\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase \"treeChanged\": {\n\t\t\t\treturn kernel.events.on(\"subtreeChangedAfterBatch\", () => listener({}));\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new UsageError(`No event named ${JSON.stringify(eventName)}.`);\n\t\t\t}\n\t\t}\n\t},\n\tstatus(node: TreeNode): TreeStatus {\n\t\treturn getKernel(node).getStatus();\n\t},\n\tis<TSchema extends ImplicitAllowedTypes>(\n\t\tvalue: unknown,\n\t\tschema: TSchema,\n\t): value is TreeNodeFromImplicitAllowedTypes<TSchema> {\n\t\t// This \"is\" utility would return false if the provided schema is a base type of the actual schema.\n\t\t// This could be confusing, and that case can only be hit when violating the rule that there is a single most derived schema that gets used (See documentation on TreeNodeSchemaClass).\n\t\t// Therefore this uses markSchemaMostDerived to ensure an informative usage error is thrown in the case where a base type is used.\n\n\t\tconst actualSchema = tryGetSchema(value);\n\t\tif (actualSchema === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\treturn normalizeAllowedTypes(schema).evaluateSet().has(actualSchema);\n\t},\n\tschema(node: TreeNode | TreeLeafValue): TreeNodeSchema {\n\t\treturn tryGetSchema(node) ?? fail(0xb37 /* Not a tree node */);\n\t},\n\tshortId(node: TreeNode): number | string | undefined {\n\t\treturn getIdentifierFromNode(node, \"preferCompressed\");\n\t},\n};\n\n/**\n * Returns a schema for a value if the value is a {@link TreeNode} or a {@link TreeLeafValue}.\n * Returns undefined for other values.\n */\nexport function tryGetSchema(value: unknown): undefined | TreeNodeSchema {\n\tswitch (typeof value) {\n\t\tcase \"string\": {\n\t\t\treturn stringSchema;\n\t\t}\n\t\tcase \"number\": {\n\t\t\treturn numberSchema;\n\t\t}\n\t\tcase \"boolean\": {\n\t\t\treturn booleanSchema;\n\t\t}\n\t\tcase \"object\": {\n\t\t\tif (isTreeNode(value)) {\n\t\t\t\t// TODO: This case could be optimized, for example by placing the simple schema in a symbol on tree nodes.\n\t\t\t\treturn tryGetTreeNodeSchema(value);\n\t\t\t}\n\t\t\tif (value === null) {\n\t\t\t\treturn nullSchema;\n\t\t\t}\n\t\t\tif (isFluidHandle(value)) {\n\t\t\t\treturn handleSchema;\n\t\t\t}\n\t\t}\n\t\tdefault: {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\n/**\n * Gets the identifier from a node.\n *\n * @param node - {@link TreeNode} where you want to extract the identifier from.\n * @param compression - string value to determine what type of identifier you want to retrieve.\n *\n * @remarks\n * If the node does not contain an identifier field, it returns undefined.\n *\n * If `compression` is set to `compressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, `undefined` is returned.\n *\n * If `compression` is set to `preferCompressed`:\n *\n * - If the node contains a compressible identifier known by the id compressor, the compressed identifier is returned.\n *\n * - If the node contains an identifier, but is not compressible or unknown by the id compressor, the uncompressed identifier is returned.\n *\n * If `compression` is set to `uncompressed`:\n * - If the node contains an identifier field, the uncompressed identifier is returned.\n */\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\",\n): number | string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"compressed\",\n): number | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"uncompressed\",\n): string | undefined;\nexport function getIdentifierFromNode(\n\tnode: TreeNode,\n\tcompression: \"preferCompressed\" | \"compressed\" | \"uncompressed\",\n): number | string | undefined {\n\tconst schema = node[typeSchemaSymbol];\n\tif (!isObjectNodeSchema(schema)) {\n\t\treturn undefined;\n\t}\n\n\tconst flexNode = getInnerNode(node);\n\tconst identifierFieldKeys = schema.identifierFieldKeys;\n\n\tswitch (identifierFieldKeys.length) {\n\t\tcase 0: {\n\t\t\treturn undefined;\n\t\t}\n\t\tcase 1: {\n\t\t\tconst key = identifierFieldKeys[0] ?? oob();\n\t\t\tconst identifierField = flexNode.tryGetField(key);\n\t\t\tassert(identifierField !== undefined, 0xbb5 /* missing identifier field */);\n\t\t\tconst identifierValue = tryGetTreeNodeForField(identifierField);\n\t\t\tassert(typeof identifierValue === \"string\", 0xbb6 /* identifier not a string */);\n\n\t\t\tconst context = flexNode.context;\n\t\t\tswitch (compression) {\n\t\t\t\tcase \"preferCompressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey === undefined\n\t\t\t\t\t\t\t? identifierValue\n\t\t\t\t\t\t\t: extractFromOpaque(localNodeKey);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn identifierValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"compressed\": {\n\t\t\t\t\tif (context.isHydrated()) {\n\t\t\t\t\t\tconst localNodeKey =\n\t\t\t\t\t\t\tcontext.nodeKeyManager.tryLocalizeNodeIdentifier(identifierValue);\n\t\t\t\t\t\treturn localNodeKey === undefined ? undefined : extractFromOpaque(localNodeKey);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase \"uncompressed\": {\n\t\t\t\t\treturn identifierValue;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(compression);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"The node has more than one identifier. Retrieve identifiers individually via their fields instead.\",\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * Gets the stored key with which the provided node is associated in the parent.\n */\nexport function getStoredKey(node: TreeNode): string | number {\n\t// Note: the flex domain strictly works with \"stored keys\", and knows nothing about the developer-facing\n\t// \"property keys\".\n\tconst parentField = getInnerNode(node).parentField;\n\tif (parentField.parent.schema === FieldKinds.sequence.identifier) {\n\t\t// The parent of `node` is an array node\n\t\tassert(\n\t\t\tparentField.parent.key === EmptyKey,\n\t\t\t0xa28 /* When using index as key, field should use EmptyKey */,\n\t\t);\n\t\treturn parentField.index;\n\t}\n\n\t// The parent of `node` is an object, a map, or undefined. If undefined, then `node` is a root/detached node.\n\tassert(parentField.index === 0, 0xa29 /* When using field key as key, index should be 0 */);\n\treturn parentField.parent.key;\n}\n\n/**\n * Given a node schema, gets the property key corresponding with the provided {@link FieldProps.key | stored key}.\n */\nexport function getPropertyKeyFromStoredKey(\n\tschema: TreeNodeSchema,\n\tstoredKey: string | number,\n): string | number {\n\t// Only object nodes have the concept of a \"stored key\", differentiated from the developer-facing \"property key\".\n\t// For any other kind of node, the stored key and the property key are the same.\n\tif (schema.kind !== NodeKind.Object) {\n\t\treturn storedKey;\n\t}\n\n\tconst fields = schema.info as Record<string, ImplicitFieldSchema>;\n\n\t// Invariants:\n\t// - The set of all property keys under an object must be unique.\n\t// - The set of all stored keys (including those implicitly created from property keys) must be unique.\n\t// To find the property key associated with the provided stored key, first check for any stored key matches (which are optionally populated).\n\t// If we don't find any, then search for a matching property key.\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tif (fieldSchema instanceof FieldSchema && fieldSchema.props?.key === storedKey) {\n\t\t\treturn propertyKey;\n\t\t}\n\t}\n\n\tif (fields[storedKey] === undefined) {\n\t\tfail(0xb38 /* Existing stored key should always map to a property key */);\n\t}\n\n\treturn storedKey;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verboseTree.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/verboseTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAKpE,OAAO,EAMN,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAE3B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAkB,MAAM,kBAAkB,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