@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":"objectNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EACN,sBAAsB,GAGtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,UAAU,EACV,WAAW,GAKX,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EACN,kBAAkB,EAElB,QAAQ;AAER,kDAAkD;AAClD,cAAc,EACd,gBAAgB,EAIhB,YAAY,EAGZ,aAAa,EAGb,i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AU,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,MAAM,CACL,YAAY,YAAY,sBAAsB,EAC9C,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO;IACR,CAAC;IAED,QAAQ,CACP,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,EACnC,SAAS,CAAC,MAAM,EAChB,KAAK,EACL,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,CAAC,CAChD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype TreeFieldStoredSchema,\n} from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n} from \"../../../feature-libraries/index.js\";\nimport type {\n\tRestrictiveStringRecord,\n\tFlattenKeys,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../../util/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport {\n\tCompatibilityLevel,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\ttype UnhydratedFlexTreeField,\n\tcreateField,\n\ttype TreeNodeSchemaCorePrivate,\n\ttype TreeNodeSchemaPrivateData,\n} from \"../../core/index.js\";\nimport {\n\tgetTreeNodeSchemaInitializedData,\n\tgetUnhydratedContext,\n} from \"../../createContext.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport type {\n\tObjectNodeSchema,\n\tObjectNodeSchemaInternalData,\n\tObjectNodeSchemaPrivate,\n} from \"./objectNodeTypes.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype FieldProps,\n\ttype ContextualFieldProvider,\n\textractFieldProvider,\n\tisConstant,\n} from \"../../fieldSchema.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\tunhydratedFlexTreeFromInsertableNode,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport { convertFieldKind } from \"../../toStoredSchema.js\";\nimport type { ObjectSchemaOptionsAlpha } from \"../../api/index.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @remarks\n * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.\n * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,\n * or using some other method like {@link (TreeAlpha:interface).create}.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n\t\t\t{}\n\t\t: {\n\t\t\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t\t\t\t: unknown;\n\t\t\t};\n\n/**\n * A {@link TreeNode} which models a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema} and {@link SchemaFactory.object}),\n * and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n *\n * Field Assignment and Deletion\n * Assigning to a field updates the tree value as long as it is still valid based on the schema.\n * - For required fields, assigning `undefined` is invalid, and will throw.\n * - For optional fields, assigning `undefined` removes the field's contents, and marks it as empty (non-enumerable and value set to undefined).\n *\n * Example:\n * ```ts\n * const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.optional(schemaFactory.number)});\n * const node = new Foo({bar: 1})\n *\n * // This clears the field, is non-enumerable, and value is undefined.\n * delete node.bar;\n *\n * // This is equivalent to the delete example.\n * node.bar = undefined\n * ```\n *\n * The API for fields is defined by {@link ObjectFromSchemaRecord}.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining if an implicit field schema is known to have a default value.\n *\n * @remarks Yields `false` when unknown.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = [T] extends [\n\tFieldSchema<FieldKind.Optional | FieldKind.Identifier>,\n]\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks\n * TODO: consider separating these cases into different types.\n *\n * Empty objects don't get \"no excess property\" checks in literals.\n * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.\n * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.\n *\n * Additionally when T is exactly `RestrictiveStringRecord<ImplicitFieldSchema>` produce just `never` so that it is assignable to the insertable for any given object type.\n *\n * Separating `{}` from `RestrictiveStringRecord<ImplicitFieldSchema>` is a bit messy since both extend each-other despite them being very different types.\n * A third dummy type `{ arbitraryKey: \"arbitraryValue\" }` is used to resolve this.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> = RestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t? // {} case\n\t\t\tRecord<string, never>\n\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\tnever\n\t: FlattenKeys<\n\t\t\t{\n\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\tT[Property & string]\n\t\t\t\t>;\n\t\t\t} & {\n\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t}\n\t\t>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst schema = normalizeFieldSchema(fieldSchema);\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * Creates a proxy handler for the given schema.\n *\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchemaPrivate,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getInnerNode(proxy);\n\t\t\t\tdebugAssert(() => !flexNode.context.isDisposed() || \"FlexTreeNode is disposed\");\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's built in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"proxy\", node: proxy }, fieldInfo, value);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.deleteProperty(target, propertyKey) : false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"target\", node: target }, fieldInfo, undefined);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(0xadd /* missing proxy */);\n\t\t\tconst field = getInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n\tdestinationSchema: TreeFieldStoredSchema,\n): void {\n\tconst mapTree = prepareForInsertion(\n\t\tvalue,\n\t\tsimpleFieldSchema,\n\t\tfield.context,\n\t\tdestinationSchema,\n\t);\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault:\n\t\t\tfail(0xade /* invalid FieldKind */);\n\t}\n}\n\n/**\n * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.\n */\nexport class ObjectFieldSchema<\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchemaAlpha<Kind, Types, TCustomMetadata>\n\timplements SimpleObjectFieldSchema\n{\n\tpublic readonly storedKey: string;\n\n\tpublic constructor(\n\t\tkind: Kind,\n\t\tallowedTypes: Types,\n\t\tprops: FieldProps<TCustomMetadata> & { readonly key: string },\n\t) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.storedKey = props.key;\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata - Optional persisted metadata for the object node schema.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tnodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData &\n\tTreeNodeSchemaCorePrivate {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(info);\n\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<\n\t\t\tstring,\n\t\t\tFieldSchemaAlpha & SimpleObjectFieldSchema\n\t\t> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [\n\t\t\t\tkey as string,\n\t\t\t\tnew ObjectFieldSchema(value.schema.kind, value.schema.allowedTypes, {\n\t\t\t\t\t...value.schema.props,\n\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\n\t\t\t\t}),\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\t\tpublic static readonly allowUnknownOptionalFields: boolean =\n\t\t\tnodeOptions.allowUnknownOptionalFields ?? false;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as Output);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchemaPrivate;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn getTreeNodeSchemaInitializedData(schema, {\n\t\t\t\tshallowCompatibilityTest: (data: FactoryContent): CompatibilityLevel =>\n\t\t\t\t\tshallowCompatibilityTest(data, schema),\n\t\t\t\ttoFlexContent: (\n\t\t\t\t\tdata: FactoryContent,\n\t\t\t\t\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\t\t\t\t): FlexContent => objectToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tnodeOptions.persistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\tArray.from(CustomObjectNode.fields.values(), (schema) => schema.allowedTypesFull),\n\t\t\t));\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for object nodes.\n *\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction objectToFlexContent(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema & ObjectNodeSchemaInternalData,\n): FlexContent {\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tconst value = getFieldProperty(data, key);\n\n\t\tlet children: UnhydratedFlexTreeNode[] | ContextualFieldProvider;\n\t\tif (value === undefined) {\n\t\t\tconst defaultProvider =\n\t\t\t\tfieldInfo.schema.props?.defaultProvider ??\n\t\t\t\tfail(0xbb1 /* missing field has no default provider */);\n\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\tchildren = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;\n\t\t} else {\n\t\t\tchildren = [\n\t\t\t\tunhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),\n\t\t\t];\n\t\t}\n\n\t\tconst kind =\n\t\t\tconvertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);\n\t\tfields.set(\n\t\t\tfieldInfo.storedKey,\n\t\t\tcreateField(context, kind.identifier, fieldInfo.storedKey, children),\n\t\t);\n\t}\n\n\treturn [{ type: brand(schema.identifier) }, fields];\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Object nodes.\n */\nfunction shallowCompatibilityTest(\n\tdata: FactoryContent,\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue) {\n\t\t\tif (getFieldProperty(data, fieldKey) === undefined) {\n\t\t\t\treturn CompatibilityLevel.None;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n *\n * @returns If the property exists, return its value. Otherwise, returns undefined.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.\n *\n * @privateRemarks\n * If we ever want to have an optional field which defaults to something other than undefined, this will need changes.\n * It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.\n */\nfunction getFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): InsertableContent | undefined {\n\t// This policy only allows own properties.\n\tif (Object.hasOwnProperty.call(data, key)) {\n\t\treturn (data as Record<string, InsertableContent>)[key as string];\n\t}\n\treturn undefined;\n}\n\nfunction applyFieldChange(\n\tschema: ObjectNodeSchemaPrivate,\n\tfrom: { kind: \"proxy\"; node: TreeNode } | { kind: \"target\"; node: object },\n\tfieldInfo: { storedKey: FieldKey; schema: FieldSchema },\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst proxy =\n\t\tfrom.kind === \"proxy\"\n\t\t\t? from.node\n\t\t\t: (targetToProxy.get(from.node) ?? fail(0xc95 /* missing proxy */));\n\tconst inner = getInnerNode(proxy);\n\tconst storedSchema = inner.context.schema.nodeSchema.get(brand(schema.identifier));\n\tassert(\n\t\tstoredSchema instanceof ObjectNodeStoredSchema,\n\t\t0xc96 /* Expected ObjectNodeStoredSchema */,\n\t);\n\n\tif (value === undefined && inner.tryGetField(fieldInfo.storedKey) === undefined) {\n\t\treturn;\n\t}\n\n\tsetField(\n\t\tinner.getBoxed(fieldInfo.storedKey),\n\t\tfieldInfo.schema,\n\t\tvalue,\n\t\tstoredSchema.getFieldSchema(fieldInfo.storedKey),\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"objectNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/object/objectNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EACN,sBAAsB,GAGtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,UAAU,EACV,WAAW,GAKX,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EACN,kBAAkB,EAElB,QAAQ;AAER,kDAAkD;AAClD,cAAc,EACd,gBAAgB,EAIhB,YAAY,EAGZ,aAAa,EAGb,iBAAiB,EACjB,+BAA+B,EAG/B,WAAW,GAGX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,gCAAgC,EAChC,oBAAoB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAMtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAEN,YAAY,EACZ,oBAAoB,EAIpB,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EAGT,oBAAoB,EACpB,UAAU,GACV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,gCAAgC,EAChC,oCAAoC,GAIpC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAuI3D;;GAEG;AACH,SAAS,oBAAoB,CAAC,MAA2C;IACxE,MAAM,MAAM,GAAuE,IAAI,GAAG,EAAE,CAAC;IAC7F,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO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I,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAQ,IAA0C,CAAC,GAAa,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,gBAAgB,CACxB,MAA+B,EAC/B,IAA0E,EAC1E,SAAuD,EACvD,KAAoC;IAEpC,MAAM,KAAK,GACV,IAAI,CAAC,IAAI,KAAK,OAAO;QACpB,CAAC,CAAC,IAAI,CAAC,IAAI;QACX,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACtE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,MAAM,CACL,YAAY,YAAY,sBAAsB,EAC9C,KAAK,CAAC,qCAAqC,CAC3C,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO;IACR,CAAC;IAED,QAAQ,CACP,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,EACnC,SAAS,CAAC,MAAM,EAChB,KAAK,EACL,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,SAAS,CAAC,CAChD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy, fail, debugAssert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport {\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype TreeFieldStoredSchema,\n} from \"../../../core/index.js\";\nimport {\n\tFieldKinds,\n\tisTreeValue,\n\ttype FlexTreeField,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeRequiredField,\n} from \"../../../feature-libraries/index.js\";\nimport type {\n\tRestrictiveStringRecord,\n\tFlattenKeys,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../../util/index.js\";\nimport { brand } from \"../../../util/index.js\";\n\nimport {\n\tCompatibilityLevel,\n\ttype TreeNodeSchema,\n\tNodeKind,\n\ttype WithType,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype InternalTreeNode,\n\ttype TreeNode,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\ttype UnhydratedFlexTreeField,\n\tcreateField,\n\ttype TreeNodeSchemaCorePrivate,\n\ttype TreeNodeSchemaPrivateData,\n} from \"../../core/index.js\";\nimport {\n\tgetTreeNodeSchemaInitializedData,\n\tgetUnhydratedContext,\n} from \"../../createContext.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport type {\n\tObjectNodeSchema,\n\tObjectNodeSchemaInternalData,\n\tObjectNodeSchemaPrivate,\n} from \"./objectNodeTypes.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\tgetStoredKey,\n\tgetExplicitStoredKey,\n\ttype TreeFieldFromImplicitField,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype FieldSchema,\n\tFieldSchemaAlpha,\n\tnormalizeFieldSchema,\n\tFieldKind,\n\ttype FieldProps,\n\ttype ContextualFieldProvider,\n\textractFieldProvider,\n\tisConstant,\n} from \"../../fieldSchema.js\";\nimport type { SimpleObjectFieldSchema } from \"../../simpleSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\tunhydratedFlexTreeFromInsertableNode,\n\ttype FactoryContent,\n\ttype FactoryContentObject,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport { convertFieldKind } from \"../../toStoredSchema.js\";\nimport type { ObjectSchemaOptionsAlpha } from \"../../api/index.js\";\n\n/**\n * Generates the properties for an ObjectNode from its field schema object.\n * @remarks\n * Due to {@link https://github.com/microsoft/TypeScript/issues/43826}, we can't enable implicit construction of {@link TreeNode|TreeNodes} for setters.\n * Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,\n * or using some other method like {@link (TreeAlpha:interface).create}.\n * @system @public\n */\nexport type ObjectFromSchemaRecord<T extends RestrictiveStringRecord<ImplicitFieldSchema>> =\n\tRestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t\t? // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n\t\t\t{}\n\t\t: {\n\t\t\t\t-readonly [Property in keyof T]: Property extends string\n\t\t\t\t\t? TreeFieldFromImplicitField<T[Property]>\n\t\t\t\t\t: unknown;\n\t\t\t};\n\n/**\n * A {@link TreeNode} which models a JavaScript object.\n * @remarks\n * Object nodes consist of a type which specifies which {@link TreeNodeSchema} they use (see {@link TreeNodeApi.schema} and {@link SchemaFactory.object}),\n * and a collections of fields, each with a distinct `key` and its own {@link FieldSchema} defining what can be placed under that key.\n *\n * All fields on an object node are exposed as own properties with string keys.\n * Non-empty fields are enumerable and empty optional fields are non-enumerable own properties with the value `undefined`.\n * No other own `own` or `enumerable` properties are included on object nodes unless the user of the node manually adds custom session only state.\n * This allows a majority of general purpose JavaScript object processing operations (like `for...in`, `Reflect.ownKeys()` and `Object.entries()`) to enumerate all the children.\n *\n * Field Assignment and Deletion\n * Assigning to a field updates the tree value as long as it is still valid based on the schema.\n * - For required fields, assigning `undefined` is invalid, and will throw.\n * - For optional fields, assigning `undefined` removes the field's contents, and marks it as empty (non-enumerable and value set to undefined).\n *\n * Example:\n * ```ts\n * const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.optional(schemaFactory.number)});\n * const node = new Foo({bar: 1})\n *\n * // This clears the field, is non-enumerable, and value is undefined.\n * delete node.bar;\n *\n * // This is equivalent to the delete example.\n * node.bar = undefined\n * ```\n *\n * The API for fields is defined by {@link ObjectFromSchemaRecord}.\n * @public\n */\nexport type TreeObjectNode<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tTypeName extends string = string,\n> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName, NodeKind.Object, T>;\n\n/**\n * Type utility for determining if an implicit field schema is known to have a default value.\n *\n * @remarks Yields `false` when unknown.\n *\n * @privateRemarks\n * TODO: Account for field schemas with default value providers.\n * For now, this only captures field kinds that we know always have defaults - optional fields and identifier fields.\n *\n * @system @public\n */\nexport type FieldHasDefault<T extends ImplicitFieldSchema> = [T] extends [\n\tFieldSchema<FieldKind.Optional | FieldKind.Identifier>,\n]\n\t? true\n\t: false;\n\n/**\n * Helper used to produce types for:\n *\n * 1. Insertable content which can be used to construct an object node.\n * In this case, only own properties are considered.\n * This reduces the risk of incorrectly interpreting data at the cost of occasionally requiring users to convert data into a compatible format.\n *\n * 2. Insertable content which is an unhydrated object node.\n *\n * 3. Union of 1 and 2.\n *\n * @see {@link Input}\n *\n * @privateRemarks\n * TODO: consider separating these cases into different types.\n *\n * Empty objects don't get \"no excess property\" checks in literals.\n * To prevent extraneous properties in literals for the fields of an empty object from compiling, the empty case is special cased to produce `Record<string, never>`.\n * More details at {@link https://mercury.com/blog/creating-an-emptyobject-type-in-typescript}.\n *\n * Additionally when T is exactly `RestrictiveStringRecord<ImplicitFieldSchema>` produce just `never` so that it is assignable to the insertable for any given object type.\n *\n * Separating `{}` from `RestrictiveStringRecord<ImplicitFieldSchema>` is a bit messy since both extend each-other despite them being very different types.\n * A third dummy type `{ arbitraryKey: \"arbitraryValue\" }` is used to resolve this.\n *\n * @system @public\n */\nexport type InsertableObjectFromSchemaRecord<\n\tT extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> = RestrictiveStringRecord<ImplicitFieldSchema> extends T\n\t? { arbitraryKey: \"arbitraryValue\" } extends T\n\t\t? // {} case\n\t\t\tRecord<string, never>\n\t\t: // RestrictiveStringRecord<ImplicitFieldSchema> case\n\t\t\tnever\n\t: FlattenKeys<\n\t\t\t{\n\t\t\t\treadonly [Property in keyof T]?: InsertableTreeFieldFromImplicitField<\n\t\t\t\t\tT[Property & string]\n\t\t\t\t>;\n\t\t\t} & {\n\t\t\t\t// Field does not have a known default, make it required:\n\t\t\t\treadonly [Property in keyof T as FieldHasDefault<T[Property & string]> extends false\n\t\t\t\t\t? Property\n\t\t\t\t\t: never]: InsertableTreeFieldFromImplicitField<T[Property & string]>;\n\t\t\t}\n\t\t>;\n\n/**\n * Maps from simple field keys (\"property\" keys) to information about the field.\n *\n * @remarks\n * A missing entry for a given property key indicates that no such field exists.\n * Keys with symbols are currently never used, but allowed to make lookups on non-field things\n * (returning undefined) easier.\n */\nexport type SimpleKeyMap = ReadonlyMap<\n\tstring | symbol,\n\t{ storedKey: FieldKey; schema: FieldSchema }\n>;\n\n/**\n * Caches the mappings from property keys to stored keys for the provided object field schemas in {@link simpleKeyToFlexKeyCache}.\n */\nfunction createFlexKeyMapping(fields: Record<string, ImplicitFieldSchema>): SimpleKeyMap {\n\tconst keyMap: Map<string | symbol, { storedKey: FieldKey; schema: FieldSchema }> = new Map();\n\tfor (const [propertyKey, fieldSchema] of Object.entries(fields)) {\n\t\tconst schema = normalizeFieldSchema(fieldSchema);\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tkeyMap.set(propertyKey, { storedKey, schema });\n\t}\n\n\treturn keyMap;\n}\n\n/**\n * Creates a proxy handler for the given schema.\n *\n * @param allowAdditionalProperties - If true, setting of unexpected properties will be forwarded to the target object.\n * Otherwise setting of unexpected properties will error.\n * TODO: consider implementing this using `Object.preventExtension` instead.\n * @param customTargetObject - Target object of the proxy.\n * If not provided `{}` is used for the target.\n */\nfunction createProxyHandler(\n\tschema: ObjectNodeSchemaPrivate,\n\tallowAdditionalProperties: boolean,\n): ProxyHandler<TreeNode> {\n\t// To satisfy 'deepEquals' level scrutiny, the target of the proxy must be an object with the same\n\t// prototype as an object literal '{}'. This is because 'deepEquals' uses 'Object.getPrototypeOf'\n\t// as a way to quickly reject objects with different prototype chains.\n\t//\n\t// (Note that the prototype of an object literal appears as '[Object: null prototype] {}', not because\n\t// the prototype is null, but because the prototype object itself has a null prototype.)\n\n\t// TODO: Although the target is an object literal, it's still worthwhile to try experimenting with\n\t// a dispatch object to see if it improves performance.\n\tconst handler: ProxyHandler<TreeNode> = {\n\t\tget(target, propertyKey, proxy): unknown {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo !== undefined) {\n\t\t\t\tconst flexNode = getInnerNode(proxy);\n\t\t\t\tdebugAssert(() => !flexNode.context.isDisposed() || \"FlexTreeNode is disposed\");\n\t\t\t\tconst field = flexNode.tryGetField(fieldInfo.storedKey);\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// POJO mode objects don't have TreeNode's built in members on their targets, so special case them:\n\t\t\tif (propertyKey === typeSchemaSymbol) {\n\t\t\t\treturn schema;\n\t\t\t}\n\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\tif (propertyKey === typeNameSymbol) {\n\t\t\t\treturn schema.identifier;\n\t\t\t}\n\n\t\t\t// Pass the proxy as the receiver here, so that any methods on the prototype receive `proxy` as `this`.\n\t\t\treturn Reflect.get(target, propertyKey, proxy);\n\t\t},\n\t\tset(target, propertyKey, value: InsertableContent | undefined, proxy) {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\t// Pass the proxy as the receiver here, so that setters on the prototype receive `proxy` as `this`.\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.set(target, propertyKey, value, proxy)\n\t\t\t\t\t: false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"proxy\", node: proxy }, fieldInfo, value);\n\t\t\treturn true;\n\t\t},\n\t\tdeleteProperty(target, propertyKey): boolean {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties ? Reflect.deleteProperty(target, propertyKey) : false;\n\t\t\t}\n\n\t\t\tapplyFieldChange(schema, { kind: \"target\", node: target }, fieldInfo, undefined);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, propertyKey) => {\n\t\t\treturn (\n\t\t\t\tschema.flexKeyMap.has(propertyKey) ||\n\t\t\t\t(allowAdditionalProperties ? Reflect.has(target, propertyKey) : false)\n\t\t\t);\n\t\t},\n\t\townKeys: (target) => {\n\t\t\treturn [\n\t\t\t\t...schema.flexKeyMap.keys(),\n\t\t\t\t...(allowAdditionalProperties ? Reflect.ownKeys(target) : []),\n\t\t\t];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, propertyKey) => {\n\t\t\tconst fieldInfo = schema.flexKeyMap.get(propertyKey);\n\n\t\t\tif (fieldInfo === undefined) {\n\t\t\t\treturn allowAdditionalProperties\n\t\t\t\t\t? Reflect.getOwnPropertyDescriptor(target, propertyKey)\n\t\t\t\t\t: undefined;\n\t\t\t}\n\n\t\t\t// For some reason, the getOwnPropertyDescriptor is not passed in the receiver, so use a weak map.\n\t\t\t// If a refactoring is done to associated flex tree data with the target not the proxy, this extra map could be removed,\n\t\t\t// and the design would be more compatible with proxyless nodes.\n\t\t\tconst proxy = targetToProxy.get(target) ?? fail(0xadd /* missing proxy */);\n\t\t\tconst field = getInnerNode(proxy).tryGetField(fieldInfo.storedKey);\n\n\t\t\tconst p: PropertyDescriptor = {\n\t\t\t\tvalue: field === undefined ? undefined : tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\t// Report empty fields as own properties so they shadow inherited properties (even when empty) to match TypeScript typing.\n\t\t\t\t// Make empty fields not enumerable so they get skipped when iterating over an object to better align with\n\t\t\t\t// JSON and deep equals with JSON compatible object (which can't have undefined fields).\n\t\t\t\tenumerable: field !== undefined,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\n\t\t\treturn p;\n\t\t},\n\t};\n\treturn handler;\n}\n\nexport function setField(\n\tfield: FlexTreeField,\n\tsimpleFieldSchema: FieldSchema,\n\tvalue: InsertableContent | undefined,\n\tdestinationSchema: TreeFieldStoredSchema,\n): void {\n\tconst mapTree = prepareForInsertion(\n\t\tvalue,\n\t\tsimpleFieldSchema,\n\t\tfield.context,\n\t\tdestinationSchema,\n\t);\n\n\tswitch (field.schema) {\n\t\tcase FieldKinds.required.identifier: {\n\t\t\tassert(mapTree !== undefined, 0xa04 /* Cannot set a required field to undefined */);\n\t\t\tconst typedField = field as FlexTreeRequiredField;\n\t\t\ttypedField.editor.set(mapTree);\n\t\t\tbreak;\n\t\t}\n\t\tcase FieldKinds.optional.identifier: {\n\t\t\tconst typedField = field as FlexTreeOptionalField;\n\t\t\ttypedField.editor.set(mapTree, typedField.length === 0);\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tfail(0xade /* invalid FieldKind */);\n\t\t}\n\t}\n}\n\n/**\n * {@link FieldSchemaAlpha} including {@link SimpleObjectFieldSchema}.\n */\nexport class ObjectFieldSchema<\n\t\tKind extends FieldKind,\n\t\tTypes extends ImplicitAllowedTypes,\n\t\tTCustomMetadata = unknown,\n\t>\n\textends FieldSchemaAlpha<Kind, Types, TCustomMetadata>\n\timplements SimpleObjectFieldSchema\n{\n\tpublic readonly storedKey: string;\n\n\tpublic constructor(\n\t\tkind: Kind,\n\t\tallowedTypes: Types,\n\t\tprops: FieldProps<TCustomMetadata> & { readonly key: string },\n\t) {\n\t\tsuper(kind, allowedTypes, props);\n\t\tthis.storedKey = props.key;\n\t}\n}\n\nabstract class CustomObjectNodeBase<\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n> extends TreeNodeValid<InsertableObjectFromSchemaRecord<T>> {\n\tpublic static readonly kind = NodeKind.Object;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeObjectNode}.\n *\n * @param name - Unique identifier for this schema within this factory's scope.\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata - Optional persisted metadata for the object node schema.\n */\nexport function objectSchema<\n\tTName extends string,\n\tconst T extends RestrictiveStringRecord<ImplicitFieldSchema>,\n\tconst ImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\tidentifier: TName,\n\tinfo: T,\n\timplicitlyConstructable: ImplicitlyConstructable,\n\tnodeOptions: ObjectSchemaOptionsAlpha<TCustomMetadata>,\n): ObjectNodeSchema<TName, T, ImplicitlyConstructable, TCustomMetadata> &\n\tObjectNodeSchemaInternalData &\n\tTreeNodeSchemaCorePrivate {\n\t// Field set can't be modified after this since derived data is stored in maps.\n\tObject.freeze(info);\n\n\t// Ensure no collisions between final set of property keys, and final set of stored keys (including those\n\t// implicitly derived from property keys)\n\tassertUniqueKeys(identifier, info);\n\n\t// Performance optimization: cache property key => stored key and schema.\n\tconst flexKeyMap: SimpleKeyMap = createFlexKeyMapping(info);\n\n\tconst identifierFieldKeys: FieldKey[] = [];\n\tfor (const item of flexKeyMap.values()) {\n\t\tif (item.schema.kind === FieldKind.Identifier) {\n\t\t\tidentifierFieldKeys.push(item.storedKey);\n\t\t}\n\t}\n\n\tconst lazyChildTypes = new Lazy(\n\t\t() => new Set(Array.from(flexKeyMap.values(), (f) => [...f.schema.allowedTypeSet]).flat()),\n\t);\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tlet handler: ProxyHandler<object>;\n\tlet customizable: boolean;\n\n\tclass CustomObjectNode extends CustomObjectNodeBase<T> {\n\t\tpublic static readonly fields: ReadonlyMap<\n\t\t\tstring,\n\t\t\tFieldSchemaAlpha & SimpleObjectFieldSchema\n\t\t> = new Map(\n\t\t\tArray.from(flexKeyMap, ([key, value]) => [\n\t\t\t\tkey as string,\n\t\t\t\tnew ObjectFieldSchema(value.schema.kind, value.schema.allowedTypes, {\n\t\t\t\t\t...value.schema.props,\n\t\t\t\t\tkey: getStoredKey(key as string, value.schema),\n\t\t\t\t}),\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly flexKeyMap: SimpleKeyMap = flexKeyMap;\n\t\tpublic static readonly storedKeyToPropertyKey: ReadonlyMap<FieldKey, string> = new Map<\n\t\t\tFieldKey,\n\t\t\tstring\n\t\t>(\n\t\t\tArray.from(flexKeyMap, ([key, value]): [FieldKey, string] => [\n\t\t\t\tvalue.storedKey,\n\t\t\t\tkey as string,\n\t\t\t]),\n\t\t);\n\t\tpublic static readonly identifierFieldKeys: readonly FieldKey[] = identifierFieldKeys;\n\t\tpublic static readonly allowUnknownOptionalFields: boolean =\n\t\t\tnodeOptions.allowUnknownOptionalFields ?? false;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.object(\"Foo\", {bar: schemaFactory.number});\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Object)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.object(\"Foo\", {bar: schemaFactory.number}) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\tconst proxy = new Proxy(proxyTarget, handler) as CustomObjectNode;\n\t\t\ttargetToProxy.set(proxyTarget, proxy);\n\t\t\treturn proxy;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as Output);\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// One time initialization that required knowing the most derived type (from this.constructor) and thus has to be lazy.\n\t\t\tcustomizable = (this as unknown) !== CustomObjectNode;\n\t\t\tconst schema = this as unknown as ObjectNodeSchemaPrivate;\n\t\t\thandler = createProxyHandler(schema, customizable);\n\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== CustomObjectNode.prototype) {\n\t\t\t\t\tfor (const [key] of flexKeyMap) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which shadows a field. Since fields are exposed as own properties, this shadowing will not work, and is an error.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomObjectNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomObjectNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn getTreeNodeSchemaInitializedData(schema, {\n\t\t\t\tshallowCompatibilityTest: (data: FactoryContent): CompatibilityLevel =>\n\t\t\t\t\tshallowCompatibilityTest(data, schema),\n\t\t\t\ttoFlexContent: (\n\t\t\t\t\tdata: FactoryContent,\n\t\t\t\t\tallowedTypes: ReadonlySet<TreeNodeSchema>,\n\t\t\t\t): FlexContent => objectToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: ImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn lazyChildTypes.value;\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tnodeOptions.persistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn CustomObjectNode.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(\n\t\t\t\tthis,\n\t\t\t\tArray.from(CustomObjectNode.fields.values(), (schema) => schema.allowedTypesFull),\n\t\t\t));\n\t\t}\n\t}\n\ttype Output = typeof CustomObjectNode &\n\t\t(new (\n\t\t\tinput: InsertableObjectFromSchemaRecord<T> | InternalTreeNode,\n\t\t) => TreeObjectNode<T, TName>);\n\treturn CustomObjectNode as Output;\n}\n\nconst targetToProxy: WeakMap<object, TreeNode> = new WeakMap();\n\n/**\n * Ensures that the set of property keys in the schema is unique.\n * Also ensure that the final set of stored keys (including those implicitly derived from property keys) is unique.\n * @throws Throws a `UsageError` if either of the key uniqueness invariants is violated.\n */\nfunction assertUniqueKeys<\n\tconst Name extends number | string,\n\tconst Fields extends RestrictiveStringRecord<ImplicitFieldSchema>,\n>(schemaName: Name, fields: Fields): void {\n\t// Verify that there are no duplicates among the explicitly specified stored keys.\n\tconst explicitStoredKeys = new Set<string>();\n\tfor (const schema of Object.values(fields)) {\n\t\tconst storedKey = getExplicitStoredKey(schema);\n\t\tif (storedKey === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (explicitStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Duplicate stored key \"${storedKey}\" in schema \"${schemaName}\". Stored keys must be unique within an object schema.`,\n\t\t\t);\n\t\t}\n\t\texplicitStoredKeys.add(storedKey);\n\t}\n\n\t// Verify that there are no duplicates among the derived\n\t// (including those implicitly derived from property keys) stored keys.\n\tconst derivedStoredKeys = new Set<string>();\n\tfor (const [propertyKey, schema] of Object.entries(fields)) {\n\t\tconst storedKey = getStoredKey(propertyKey, schema);\n\t\tif (derivedStoredKeys.has(storedKey)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t`Stored key \"${storedKey}\" in schema \"${schemaName}\" conflicts with a property key of the same name, which is not overridden by a stored key. The final set of stored keys in an object schema must be unique.`,\n\t\t\t);\n\t\t}\n\t\tderivedStoredKeys.add(storedKey);\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for object nodes.\n *\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction objectToFlexContent(\n\tdata: FactoryContent,\n\tschema: TreeNodeSchema & ObjectNodeSchemaInternalData,\n): FlexContent {\n\tif (\n\t\ttypeof data !== \"object\" ||\n\t\tdata === null ||\n\t\tSymbol.iterator in data ||\n\t\tisFluidHandle(data)\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-base-to-string\n\t\tthrow new UsageError(`Input data is incompatible with Object schema: ${data}`);\n\t}\n\n\tconst fields = new Map<FieldKey, UnhydratedFlexTreeField>();\n\tconst context = getUnhydratedContext(schema).flexContext;\n\n\tfor (const [key, fieldInfo] of schema.flexKeyMap) {\n\t\tconst value = getFieldProperty(data, key);\n\n\t\tlet children: UnhydratedFlexTreeNode[] | ContextualFieldProvider;\n\t\tif (value === undefined) {\n\t\t\tconst defaultProvider =\n\t\t\t\tfieldInfo.schema.props?.defaultProvider ??\n\t\t\t\tfail(0xbb1 /* missing field has no default provider */);\n\t\t\tconst fieldProvider = extractFieldProvider(defaultProvider);\n\t\t\tchildren = isConstant(fieldProvider) ? fieldProvider() : fieldProvider;\n\t\t} else {\n\t\t\tchildren = [\n\t\t\t\tunhydratedFlexTreeFromInsertableNode(value, fieldInfo.schema.allowedTypeSet),\n\t\t\t];\n\t\t}\n\n\t\tconst kind =\n\t\t\tconvertFieldKind.get(fieldInfo.schema.kind) ?? fail(0xbb2 /* Invalid field kind */);\n\t\tfields.set(\n\t\t\tfieldInfo.storedKey,\n\t\t\tcreateField(context, kind.identifier, fieldInfo.storedKey, children),\n\t\t);\n\t}\n\n\treturn [{ type: brand(schema.identifier) }, fields];\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Object nodes.\n */\nfunction shallowCompatibilityTest(\n\tdata: FactoryContent,\n\tschema: ObjectNodeSchema & ObjectNodeSchemaInternalData,\n): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\t// TODO: Improve type inference by making this logic more thorough. Handle at least:\n\t// * Types which are strict subsets of other types in the same polymorphic union\n\t// * Types which have the same keys but different types for those keys in the polymorphic union\n\t// * Types which have the same required fields but different optional fields and enough of those optional fields are populated to disambiguate\n\n\t// TODO#7441: Consider allowing data to be inserted which has keys that are extraneous/unknown to the schema (those keys are ignored)\n\n\t// If the schema has a required key which is not present in the input object, reject it.\n\tfor (const [fieldKey, fieldSchema] of schema.fields) {\n\t\tif (fieldSchema.requiresValue && getFieldProperty(data, fieldKey) === undefined) {\n\t\t\treturn CompatibilityLevel.None;\n\t\t}\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * Check {@link FactoryContentObject} for a property which could be store a field.\n *\n * @returns If the property exists, return its value. Otherwise, returns undefined.\n * @remarks\n * The currently policy is to only consider own properties.\n * See {@link InsertableObjectFromSchemaRecord} for where this policy is documented in the public API.\n *\n * Explicit undefined values are treated the same as missing properties to allow explicit use of undefined with defaulted identifiers.\n *\n * @privateRemarks\n * If we ever want to have an optional field which defaults to something other than undefined, this will need changes.\n * It would need to adjusting the handling of explicit undefined in contexts where undefined is allowed, and a default provider also exists.\n */\nfunction getFieldProperty(\n\tdata: FactoryContentObject,\n\tkey: string | symbol,\n): InsertableContent | undefined {\n\t// This policy only allows own properties.\n\tif (Object.hasOwnProperty.call(data, key)) {\n\t\treturn (data as Record<string, InsertableContent>)[key as string];\n\t}\n\treturn undefined;\n}\n\nfunction applyFieldChange(\n\tschema: ObjectNodeSchemaPrivate,\n\tfrom: { kind: \"proxy\"; node: TreeNode } | { kind: \"target\"; node: object },\n\tfieldInfo: { storedKey: FieldKey; schema: FieldSchema },\n\tvalue: InsertableContent | undefined,\n): void {\n\tconst proxy =\n\t\tfrom.kind === \"proxy\"\n\t\t\t? from.node\n\t\t\t: (targetToProxy.get(from.node) ?? fail(0xc95 /* missing proxy */));\n\tconst inner = getInnerNode(proxy);\n\tconst storedSchema = inner.context.schema.nodeSchema.get(brand(schema.identifier));\n\tassert(\n\t\tstoredSchema instanceof ObjectNodeStoredSchema,\n\t\t0xc96 /* Expected ObjectNodeStoredSchema */,\n\t);\n\n\tif (value === undefined && inner.tryGetField(fieldInfo.storedKey) === undefined) {\n\t\treturn;\n\t}\n\n\tsetField(\n\t\tinner.getBoxed(fieldInfo.storedKey),\n\t\tfieldInfo.schema,\n\t\tvalue,\n\t\tstoredSchema.getFieldSchema(fieldInfo.storedKey),\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordNode.d.ts","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAEN,QAAQ,EASR,KAAK,oBAAoB,EAMzB,KAAK,yBAAyB,EAO9B,MAAM,qBAAqB,CAAC;AAS7B,OAAO,KAAK,EACX,4BAA4B,EAE5B,6BAA6B,EAG7B,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"recordNode.d.ts","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAEN,QAAQ,EASR,KAAK,oBAAoB,EAMzB,KAAK,yBAAyB,EAO9B,MAAM,qBAAqB,CAAC;AAS7B,OAAO,KAAK,EACX,4BAA4B,EAE5B,6BAA6B,EAG7B,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EAAE,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rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type JsonCompatibleReadOnlyObject, brand } from \"../../../util/index.js\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\tgetKernel,\n\ttype InternalTreeNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\ttype TreeNodeSchemaCorePrivate,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\tCompatibilityLevel,\n\ttype TreeNodeSchemaPrivateData,\n\tAnnotatedAllowedTypesInternal,\n} from \"../../core/index.js\";\nimport { getTreeNodeSchemaInitializedData } from \"../../createContext.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { createFieldSchema, FieldKind } from \"../../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype FactoryContent,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport type {\n\tRecordNodeCustomizableSchema,\n\tRecordNodeInsertableData,\n\tRecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\tTreeRecordNode,\n} from \"./recordNodeTypes.js\";\nimport {\n\tisTreeValue,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n} from \"../../../feature-libraries/index.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport { recordLikeDataToFlexContent } from \"../common.js\";\nimport { MapNodeStoredSchema } from \"../../../core/index.js\";\nimport type { NodeSchemaOptionsAlpha } from \"../../api/index.js\";\nimport type { SchemaType, SimpleAllowedTypeAttributes } from \"../../simpleSchema.js\";\n\n/**\n * Create a proxy which implements the {@link TreeRecordNode} API.\n * @param proxyTarget - Target object of the proxy.\n * @param customizable - See {@link RecordNodeSchemaOptions.customizable}.\n * @param schema - The schema of the record node.\n */\nfunction createRecordNodeProxy(\n\tproxyTarget: object,\n\tcustomizable: boolean,\n\tschema: RecordNodeSchema,\n): TreeRecordNode {\n\tconst proxy: TreeRecordNode = new Proxy<TreeRecordNode>(proxyTarget as TreeRecordNode, {\n\t\tget: (target, key, receiver): unknown => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\tswitch (key) {\n\t\t\t\t\t// POJO mode records don't have TreeNode's build in members on their targets, so special case them:\n\t\t\t\t\tcase typeSchemaSymbol: {\n\t\t\t\t\t\treturn schema;\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\t\t\tcase typeNameSymbol: {\n\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.iterator: {\n\t\t\t\t\t\treturn () => recordIterator(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toPrimitive: {\n\t\t\t\t\t\t// Handle string interpolation and coercion to string\n\t\t\t\t\t\treturn () => Object.prototype.toString.call(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toStringTag: {\n\t\t\t\t\t\t// In order to satisfy deep equality checks in POJO (non-customizable) mode,\n\t\t\t\t\t\t// we cannot override the behavior of this.\n\t\t\t\t\t\tif (customizable) {\n\t\t\t\t\t\t\t// Generates nicer toString behavior for customizable records.\n\t\t\t\t\t\t\t// E.g. `[object My.Record]` instead of `[object Object]`.\n\t\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\t// No-op\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof key === \"string\") {\n\t\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\t\tconst field = innerNode.tryGetField(brand(key));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tset: (target, key, value: InsertableContent | undefined, receiver): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\tconst field = innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;\n\t\t\tconst kernel = getKernel(receiver);\n\t\t\tconst innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));\n\t\t\tassert(\n\t\t\t\tinnerSchema instanceof MapNodeStoredSchema,\n\t\t\t\t0xc1a /* Expected MapNodeStoredSchema */,\n\t\t\t);\n\n\t\t\tconst mapTree = prepareForInsertion(\n\t\t\t\tvalue,\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),\n\t\t\t\tinnerNode.context,\n\t\t\t\tinnerSchema.mapFields,\n\t\t\t);\n\n\t\t\tfield.editor.set(mapTree, field.length === 0);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, key): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst childField = innerNode.tryGetField(brand(key));\n\n\t\t\treturn childField !== undefined;\n\t\t},\n\t\townKeys: (target) => {\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\treturn [...innerNode.keys()];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, key) => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key));\n\n\t\t\tif (field === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tvalue: tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\t\t},\n\t\tdefineProperty(target, key, attributes) {\n\t\t\tthrow new UsageError(\"Shadowing properties of record nodes is not permitted.\");\n\t\t},\n\t\tdeleteProperty(target, key) {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key)) as FlexTreeOptionalField | undefined;\n\t\t\tif (field !== undefined) {\n\t\t\t\tfield.editor.set(undefined, field.length === 0);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n\treturn proxy;\n}\n\nabstract class CustomRecordNodeBase<\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n> extends TreeNodeValid<RecordNodeInsertableData<TAllowedTypes>> {\n\tpublic static readonly kind = NodeKind.Record;\n\n\tpublic constructor(\n\t\tinput?: InternalTreeNode | RecordNodeInsertableData<TAllowedTypes> | undefined,\n\t) {\n\t\tsuper(input ?? {});\n\t}\n}\n\n/**\n * {@link recordSchema} options.\n * @input\n */\nexport interface RecordSchemaOptions<\n\tTName extends string,\n\tTAllowedTypes extends ImplicitAllowedTypes,\n\tTImplicitlyConstructable extends boolean,\n\tTCustomMetadata = unknown,\n> {\n\t/**\n\t * Unique identifier for this schema within this factory's scope.\n\t */\n\treadonly identifier: TName;\n\n\treadonly customizable: boolean;\n\n\t/**\n\t * The kinds of nodes that are allowed as children of this record.\n\t */\n\treadonly info: TAllowedTypes;\n\n\treadonly implicitlyConstructable: TImplicitlyConstructable;\n\n\treadonly nodeOptions?: NodeSchemaOptionsAlpha<TCustomMetadata>;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeRecordNode}.\n *\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata -\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function recordSchema<\n\tTName extends string,\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n\tconst TImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\toptions: RecordSchemaOptions<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t>,\n) {\n\tconst { identifier, info, customizable, implicitlyConstructable, nodeOptions } = options;\n\tconst persistedMetadata = nodeOptions?.persistedMetadata;\n\n\tconst normalizedTypes = normalizeAllowedTypes(info);\n\tconst lazyAllowedTypesIdentifiers = new Lazy(\n\t\t() => new Set(normalizedTypes.evaluate().map((type) => type.identifier)),\n\t);\n\tconst lazySimpleAllowedTypes = new Lazy(() => {\n\t\treturn AnnotatedAllowedTypesInternal.evaluateSimpleAllowedTypes(normalizedTypes);\n\t});\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tclass Schema\n\t\textends CustomRecordNodeBase<TAllowedTypes>\n\t\timplements TreeRecordNode<TAllowedTypes>\n\t{\n\t\t/**\n\t\t * Record-like index signature for the node.\n\t\t */\n\t\t[key: string]: TreeNodeFromImplicitAllowedTypes<TAllowedTypes>;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.record(\"Foo\", schemaFactory.number);\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Record)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.record(\"Foo\", schemaFactory.number) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\treturn createRecordNodeProxy(\n\t\t\t\tproxyTarget,\n\t\t\t\tcustomizable,\n\t\t\t\tthis as unknown as RecordNodeSchema,\n\t\t\t) as unknown as Schema;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as typeof Schema);\n\t\t}\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== Schema.prototype) {\n\t\t\t\t\tfor (const key of Object.getOwnPropertyNames(prototype)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which could shadow a legal entry. Since child fields are exposed as own properties, shadowing properties of record nodes is not permitted.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomRecordNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomRecordNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst schema = this as RecordNodeSchema;\n\t\t\treturn getTreeNodeSchemaInitializedData(this, {\n\t\t\t\tshallowCompatibilityTest,\n\t\t\t\ttoFlexContent: (data: FactoryContent): FlexContent =>\n\t\t\t\t\trecordToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\t\treturn lazyAllowedTypesIdentifiers.value;\n\t\t}\n\n\t\tpublic static get simpleAllowedTypes(): ReadonlyMap<\n\t\t\tstring,\n\t\t\tSimpleAllowedTypeAttributes<SchemaType.View>\n\t\t> {\n\t\t\treturn lazySimpleAllowedTypes.value;\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: TImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn normalizedTypes.evaluateSet();\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions?.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tpersistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn Schema.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic [Symbol.iterator](): IterableIterator<\n\t\t\t[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]\n\t\t> {\n\t\t\treturn recordIterator(this);\n\t\t}\n\t\tpublic get [Symbol.toStringTag](): string {\n\t\t\treturn identifier;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(this, [normalizedTypes]));\n\t\t}\n\t}\n\n\ttype Output = RecordNodeCustomizableSchema<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t> &\n\t\tRecordNodePojoEmulationSchema<\n\t\t\tTName,\n\t\t\tTAllowedTypes,\n\t\t\tTImplicitlyConstructable,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\tTreeNodeSchemaCorePrivate;\n\n\tconst output: Output = Schema;\n\treturn output;\n}\n\nfunction* recordIterator<TAllowedTypes extends ImplicitAllowedTypes>(\n\trecord: TreeRecordNode<TAllowedTypes>,\n): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]> {\n\tfor (const [key, value] of Object.entries(record)) {\n\t\tyield [key, value];\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Record nodes.\n */\nfunction shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for Record nodes.\n *\n * Transforms data under a Record schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction recordToFlexContent(data: FactoryContent, schema: RecordNodeSchema): FlexContent {\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Record schema: ${data}`);\n\t}\n\n\tconst fieldsIterator: Iterable<readonly [string, InsertableContent]> = Object.entries(data);\n\treturn recordLikeDataToFlexContent(fieldsIterator, schema);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recordNode.js","sourceRoot":"","sources":["../../../../src/simple-tree/node-kinds/record/recordNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAqC,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElF,OAAO,EAEN,QAAQ;AACR,kDAAkD;AAClD,cAAc,EACd,gBAAgB,EAEhB,YAAY,EACZ,SAAS,EAIT,qBAAqB,EAErB,aAAa,EAIb,iBAAiB,EACjB,+BAA+B,EAE/B,kBAAkB,EAElB,6BAA6B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACN,gCAAgC,GAGhC,MAAM,2CAA2C,CAAC;AAQnD,OAAO,EACN,WAAW,GAGX,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D;;;;;GAKG;AACH,SAAS,qBAAqB,CAC7B,WAAmB,EACnB,YAAqB,EACrB,MAA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SAAS,wBAAwB,CAAC,IAAoB;IACrD,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,kBAAkB,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,kBAAkB,CAAC,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAAoB,EAAE,MAAwB;IAC1E,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,UAAU,CAAC,kDAAkD,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,cAAc,GAAmD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F,OAAO,2BAA2B,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Lazy } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type JsonCompatibleReadOnlyObject, brand } from \"../../../util/index.js\";\n\nimport {\n\ttype TreeNodeSchema,\n\tNodeKind,\n\t// eslint-disable-next-line import-x/no-deprecated\n\ttypeNameSymbol,\n\ttypeSchemaSymbol,\n\ttype UnhydratedFlexTreeNode,\n\tgetInnerNode,\n\tgetKernel,\n\ttype InternalTreeNode,\n\ttype NodeSchemaMetadata,\n\ttype ImplicitAllowedTypes,\n\tnormalizeAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\tTreeNodeValid,\n\ttype MostDerivedData,\n\ttype TreeNodeSchemaInitializedData,\n\ttype TreeNodeSchemaCorePrivate,\n\tprivateDataSymbol,\n\tcreateTreeNodeSchemaPrivateData,\n\ttype FlexContent,\n\tCompatibilityLevel,\n\ttype TreeNodeSchemaPrivateData,\n\tAnnotatedAllowedTypesInternal,\n} from \"../../core/index.js\";\nimport { getTreeNodeSchemaInitializedData } from \"../../createContext.js\";\nimport { tryGetTreeNodeForField } from \"../../getTreeNodeForField.js\";\nimport { createFieldSchema, FieldKind } from \"../../fieldSchema.js\";\nimport {\n\tunhydratedFlexTreeFromInsertable,\n\ttype FactoryContent,\n\ttype InsertableContent,\n} from \"../../unhydratedFlexTreeFromInsertable.js\";\nimport type {\n\tRecordNodeCustomizableSchema,\n\tRecordNodeInsertableData,\n\tRecordNodePojoEmulationSchema,\n\tRecordNodeSchema,\n\tTreeRecordNode,\n} from \"./recordNodeTypes.js\";\nimport {\n\tisTreeValue,\n\ttype FlexTreeNode,\n\ttype FlexTreeOptionalField,\n} from \"../../../feature-libraries/index.js\";\nimport { prepareForInsertion } from \"../../prepareForInsertion.js\";\nimport { recordLikeDataToFlexContent } from \"../common.js\";\nimport { MapNodeStoredSchema } from \"../../../core/index.js\";\nimport type { NodeSchemaOptionsAlpha } from \"../../api/index.js\";\nimport type { SchemaType, SimpleAllowedTypeAttributes } from \"../../simpleSchema.js\";\n\n/**\n * Create a proxy which implements the {@link TreeRecordNode} API.\n * @param proxyTarget - Target object of the proxy.\n * @param customizable - See {@link RecordNodeSchemaOptions.customizable}.\n * @param schema - The schema of the record node.\n */\nfunction createRecordNodeProxy(\n\tproxyTarget: object,\n\tcustomizable: boolean,\n\tschema: RecordNodeSchema,\n): TreeRecordNode {\n\tconst proxy: TreeRecordNode = new Proxy<TreeRecordNode>(proxyTarget as TreeRecordNode, {\n\t\tget: (target, key, receiver): unknown => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\tswitch (key) {\n\t\t\t\t\t// POJO mode records don't have TreeNode's build in members on their targets, so special case them:\n\t\t\t\t\tcase typeSchemaSymbol: {\n\t\t\t\t\t\treturn schema;\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\t\t\t\tcase typeNameSymbol: {\n\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.iterator: {\n\t\t\t\t\t\treturn () => recordIterator(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toPrimitive: {\n\t\t\t\t\t\t// Handle string interpolation and coercion to string\n\t\t\t\t\t\treturn () => Object.prototype.toString.call(proxy);\n\t\t\t\t\t}\n\t\t\t\t\tcase Symbol.toStringTag: {\n\t\t\t\t\t\t// In order to satisfy deep equality checks in POJO (non-customizable) mode,\n\t\t\t\t\t\t// we cannot override the behavior of this.\n\t\t\t\t\t\tif (customizable) {\n\t\t\t\t\t\t\t// Generates nicer toString behavior for customizable records.\n\t\t\t\t\t\t\t// E.g. `[object My.Record]` instead of `[object Object]`.\n\t\t\t\t\t\t\treturn schema.identifier;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t// No-op\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof key === \"string\") {\n\t\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\t\tconst field = innerNode.tryGetField(brand(key));\n\t\t\t\tif (field !== undefined) {\n\t\t\t\t\treturn tryGetTreeNodeForField(field);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tset: (target, key, value: InsertableContent | undefined, receiver): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(receiver);\n\t\t\tconst field = innerNode.getBoxed(brand(key)) as FlexTreeOptionalField;\n\t\t\tconst kernel = getKernel(receiver);\n\t\t\tconst innerSchema = innerNode.context.schema.nodeSchema.get(brand(schema.identifier));\n\t\t\tassert(\n\t\t\t\tinnerSchema instanceof MapNodeStoredSchema,\n\t\t\t\t0xc1a /* Expected MapNodeStoredSchema */,\n\t\t\t);\n\n\t\t\tconst mapTree = prepareForInsertion(\n\t\t\t\tvalue,\n\t\t\t\tcreateFieldSchema(FieldKind.Optional, kernel.schema.info as ImplicitAllowedTypes),\n\t\t\t\tinnerNode.context,\n\t\t\t\tinnerSchema.mapFields,\n\t\t\t);\n\n\t\t\tfield.editor.set(mapTree, field.length === 0);\n\t\t\treturn true;\n\t\t},\n\t\thas: (target, key): boolean => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst childField = innerNode.tryGetField(brand(key));\n\n\t\t\treturn childField !== undefined;\n\t\t},\n\t\townKeys: (target) => {\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\treturn [...innerNode.keys()];\n\t\t},\n\t\tgetOwnPropertyDescriptor: (target, key) => {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key));\n\n\t\t\tif (field === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tvalue: tryGetTreeNodeForField(field),\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true, // Must be 'configurable' if property is absent from proxy target.\n\t\t\t};\n\t\t},\n\t\tdefineProperty(target, key, attributes) {\n\t\t\tthrow new UsageError(\"Shadowing properties of record nodes is not permitted.\");\n\t\t},\n\t\tdeleteProperty(target, key) {\n\t\t\tif (typeof key === \"symbol\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst innerNode = getInnerNode(proxy);\n\t\t\tconst field = innerNode.tryGetField(brand(key)) as FlexTreeOptionalField | undefined;\n\t\t\tif (field !== undefined) {\n\t\t\t\tfield.editor.set(undefined, field.length === 0);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n\treturn proxy;\n}\n\nabstract class CustomRecordNodeBase<\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n> extends TreeNodeValid<RecordNodeInsertableData<TAllowedTypes>> {\n\tpublic static readonly kind = NodeKind.Record;\n\n\tpublic constructor(\n\t\tinput?: InternalTreeNode | RecordNodeInsertableData<TAllowedTypes> | undefined,\n\t) {\n\t\tsuper(input ?? {});\n\t}\n}\n\n/**\n * {@link recordSchema} options.\n * @input\n */\nexport interface RecordSchemaOptions<\n\tTName extends string,\n\tTAllowedTypes extends ImplicitAllowedTypes,\n\tTImplicitlyConstructable extends boolean,\n\tTCustomMetadata = unknown,\n> {\n\t/**\n\t * Unique identifier for this schema within this factory's scope.\n\t */\n\treadonly identifier: TName;\n\n\treadonly customizable: boolean;\n\n\t/**\n\t * The kinds of nodes that are allowed as children of this record.\n\t */\n\treadonly info: TAllowedTypes;\n\n\treadonly implicitlyConstructable: TImplicitlyConstructable;\n\n\treadonly nodeOptions?: NodeSchemaOptionsAlpha<TCustomMetadata>;\n}\n\n/**\n * Define a {@link TreeNodeSchema} for a {@link TreeRecordNode}.\n *\n * @param fields - Schema for fields of the object node's schema. Defines what children can be placed under each key.\n * @param persistedMetadata -\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function recordSchema<\n\tTName extends string,\n\tconst TAllowedTypes extends ImplicitAllowedTypes,\n\tconst TImplicitlyConstructable extends boolean,\n\tconst TCustomMetadata = unknown,\n>(\n\toptions: RecordSchemaOptions<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t>,\n) {\n\tconst { identifier, info, customizable, implicitlyConstructable, nodeOptions } = options;\n\tconst persistedMetadata = nodeOptions?.persistedMetadata;\n\n\tconst normalizedTypes = normalizeAllowedTypes(info);\n\tconst lazyAllowedTypesIdentifiers = new Lazy(\n\t\t() => new Set(normalizedTypes.evaluate().map((type) => type.identifier)),\n\t);\n\tconst lazySimpleAllowedTypes = new Lazy(() => {\n\t\treturn AnnotatedAllowedTypesInternal.evaluateSimpleAllowedTypes(normalizedTypes);\n\t});\n\n\tlet privateData: TreeNodeSchemaPrivateData | undefined;\n\n\tclass Schema\n\t\textends CustomRecordNodeBase<TAllowedTypes>\n\t\timplements TreeRecordNode<TAllowedTypes>\n\t{\n\t\t/**\n\t\t * Record-like index signature for the node.\n\t\t */\n\t\t[key: string]: TreeNodeFromImplicitAllowedTypes<TAllowedTypes>;\n\n\t\tpublic static override prepareInstance<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tflexNode: FlexTreeNode,\n\t\t): TreeNodeValid<T2> {\n\t\t\t// Differentiate between the following cases:\n\t\t\t//\n\t\t\t// Case 1: Direct construction (POJO emulation)\n\t\t\t//\n\t\t\t// const Foo = schemaFactory.record(\"Foo\", schemaFactory.number);\n\t\t\t//\n\t\t\t// assert.deepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t//\t\t \"Prototype chain equivalent to POJO.\");\n\t\t\t//\n\t\t\t// Case 2: Subclass construction (Customizable Record)\n\t\t\t//\n\t\t\t// \t class Foo extends schemaFactory.record(\"Foo\", schemaFactory.number) {}\n\t\t\t//\n\t\t\t// \t assert.notDeepEqual(new Foo({ bar: 42 }), { bar: 42 },\n\t\t\t// \t \"Subclass prototype chain differs from POJO.\");\n\t\t\t//\n\t\t\t// In Case 1 (POJO emulation), the prototype chain match '{}' (proxyTarget = undefined)\n\t\t\t// In Case 2 (Customizable Object), the prototype chain include the user's subclass (proxyTarget = this)\n\t\t\tconst proxyTarget = customizable ? instance : {};\n\t\t\treturn createRecordNodeProxy(\n\t\t\t\tproxyTarget,\n\t\t\t\tcustomizable,\n\t\t\t\tthis as unknown as RecordNodeSchema,\n\t\t\t) as unknown as Schema;\n\t\t}\n\n\t\tpublic static override buildRawNode<T2>(\n\t\t\tthis: typeof TreeNodeValid<T2>,\n\t\t\tinstance: TreeNodeValid<T2>,\n\t\t\tinput: T2,\n\t\t): UnhydratedFlexTreeNode {\n\t\t\treturn unhydratedFlexTreeFromInsertable(input as object, this as typeof Schema);\n\t\t}\n\n\t\tprotected static override oneTimeSetup(): TreeNodeSchemaInitializedData {\n\t\t\t// First run, do extra validation.\n\t\t\t// TODO: provide a way for TreeConfiguration to trigger this same validation to ensure it gets run early.\n\t\t\t// Scan for shadowing inherited members which won't work, but stop scan early to allow shadowing built in (which seems to work ok).\n\t\t\t{\n\t\t\t\tlet prototype: object = this.prototype;\n\t\t\t\t// There isn't a clear cleaner way to author this loop.\n\t\t\t\twhile (prototype !== Schema.prototype) {\n\t\t\t\t\tfor (const key of Object.getOwnPropertyNames(prototype)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t// constructor is a special case, since one is built in on the derived type, and shadowing it works fine since we only use it before fields are applied.\n\t\t\t\t\t\t\tkey !== \"constructor\" &&\n\t\t\t\t\t\t\tReflect.getOwnPropertyDescriptor(prototype, key) !== undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t\t`Schema ${identifier} defines an inherited property \"${key.toString()}\" which could shadow a legal entry. Since child fields are exposed as own properties, shadowing properties of record nodes is not permitted.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Since this stops at CustomRecordNode, it should never see a null prototype, so this case is safe.\n\t\t\t\t\t// Additionally, if the prototype chain is ever messed up such that CustomRecordNode is not in it,\n\t\t\t\t\t// the null that would show up here does at least ensure this code throws instead of hanging.\n\t\t\t\t\tprototype = Reflect.getPrototypeOf(prototype) as object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst schema = this as RecordNodeSchema;\n\t\t\treturn getTreeNodeSchemaInitializedData(this, {\n\t\t\t\tshallowCompatibilityTest,\n\t\t\t\ttoFlexContent: (data: FactoryContent): FlexContent =>\n\t\t\t\t\trecordToFlexContent(data, schema),\n\t\t\t});\n\t\t}\n\n\t\tpublic static get allowedTypesIdentifiers(): ReadonlySet<string> {\n\t\t\treturn lazyAllowedTypesIdentifiers.value;\n\t\t}\n\n\t\tpublic static get simpleAllowedTypes(): ReadonlyMap<\n\t\t\tstring,\n\t\t\tSimpleAllowedTypeAttributes<SchemaType.View>\n\t\t> {\n\t\t\treturn lazySimpleAllowedTypes.value;\n\t\t}\n\n\t\tprotected static override constructorCached: MostDerivedData | undefined = undefined;\n\n\t\tpublic static readonly identifier = identifier;\n\t\tpublic static readonly info = info;\n\t\tpublic static readonly implicitlyConstructable: TImplicitlyConstructable =\n\t\t\timplicitlyConstructable;\n\t\tpublic static get childTypes(): ReadonlySet<TreeNodeSchema> {\n\t\t\treturn normalizedTypes.evaluateSet();\n\t\t}\n\t\tpublic static readonly metadata: NodeSchemaMetadata<TCustomMetadata> =\n\t\t\tnodeOptions?.metadata ?? {};\n\t\tpublic static readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined =\n\t\t\tpersistedMetadata;\n\n\t\t// eslint-disable-next-line import-x/no-deprecated\n\t\tpublic get [typeNameSymbol](): TName {\n\t\t\treturn identifier;\n\t\t}\n\t\tpublic get [typeSchemaSymbol](): Output {\n\t\t\treturn Schema.constructorCached?.constructor as unknown as Output;\n\t\t}\n\n\t\tpublic [Symbol.iterator](): IterableIterator<\n\t\t\t[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]\n\t\t> {\n\t\t\treturn recordIterator(this);\n\t\t}\n\t\tpublic get [Symbol.toStringTag](): string {\n\t\t\treturn identifier;\n\t\t}\n\n\t\tpublic static get [privateDataSymbol](): TreeNodeSchemaPrivateData {\n\t\t\treturn (privateData ??= createTreeNodeSchemaPrivateData(this, [normalizedTypes]));\n\t\t}\n\t}\n\n\ttype Output = RecordNodeCustomizableSchema<\n\t\tTName,\n\t\tTAllowedTypes,\n\t\tTImplicitlyConstructable,\n\t\tTCustomMetadata\n\t> &\n\t\tRecordNodePojoEmulationSchema<\n\t\t\tTName,\n\t\t\tTAllowedTypes,\n\t\t\tTImplicitlyConstructable,\n\t\t\tTCustomMetadata\n\t\t> &\n\t\tTreeNodeSchemaCorePrivate;\n\n\tconst output: Output = Schema;\n\treturn output;\n}\n\nfunction* recordIterator<TAllowedTypes extends ImplicitAllowedTypes>(\n\trecord: TreeRecordNode<TAllowedTypes>,\n): IterableIterator<[string, TreeNodeFromImplicitAllowedTypes<TAllowedTypes>]> {\n\tfor (const [key, value] of Object.entries(record)) {\n\t\tyield [key, value];\n\t}\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.shallowCompatibilityTest} for Record nodes.\n */\nfunction shallowCompatibilityTest(data: FactoryContent): CompatibilityLevel {\n\tif (isTreeValue(data)) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\tif (Symbol.iterator in data) {\n\t\treturn CompatibilityLevel.None;\n\t}\n\n\treturn CompatibilityLevel.Normal;\n}\n\n/**\n * {@link TreeNodeSchemaInitializedData.toFlexContent} for Record nodes.\n *\n * Transforms data under a Record schema.\n * @param data - The tree data to be transformed. Must be a Record-like object.\n * @param schema - The schema to comply with.\n */\nfunction recordToFlexContent(data: FactoryContent, schema: RecordNodeSchema): FlexContent {\n\tif (!(typeof data === \"object\" && data !== null)) {\n\t\tthrow new UsageError(`Input data is incompatible with Record schema: ${data}`);\n\t}\n\n\tconst fieldsIterator: Iterable<readonly [string, InsertableContent]> = Object.entries(data);\n\treturn recordLikeDataToFlexContent(fieldsIterator, schema);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAS/E,OAAO,EACN,YAAY,EAE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AiC,GACxC,gBAAgB,CAAC;AAoEpB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,iCAAiC,GACxC,kBAAkB,CAUpB"}
|
|
@@ -89,27 +89,31 @@ export function toStoredSchema(root, options) {
|
|
|
89
89
|
export function transformSimpleSchema(schema, options) {
|
|
90
90
|
const simpleNodeSchema = new Map();
|
|
91
91
|
const root = filterFieldAllowedTypes(schema.root, options);
|
|
92
|
-
const queue =
|
|
92
|
+
const queue = [...root.simpleAllowedTypes.keys()];
|
|
93
93
|
for (const identifier of queue) {
|
|
94
94
|
getOrCreate(simpleNodeSchema, identifier, (id) => {
|
|
95
95
|
const nodeSchema = schema.definitions.get(id) ?? fail(0xca8 /* missing schema */);
|
|
96
96
|
const transformed = transformSimpleNodeSchema(nodeSchema, options);
|
|
97
97
|
const kind = transformed.kind;
|
|
98
98
|
switch (kind) {
|
|
99
|
-
case NodeKind.Leaf:
|
|
99
|
+
case NodeKind.Leaf: {
|
|
100
100
|
break;
|
|
101
|
+
}
|
|
101
102
|
case NodeKind.Array:
|
|
102
103
|
case NodeKind.Map:
|
|
103
|
-
case NodeKind.Record:
|
|
104
|
+
case NodeKind.Record: {
|
|
104
105
|
queue.push(...transformed.simpleAllowedTypes.keys());
|
|
105
106
|
break;
|
|
106
|
-
|
|
107
|
+
}
|
|
108
|
+
case NodeKind.Object: {
|
|
107
109
|
for (const fieldSchema of transformed.fields.values()) {
|
|
108
110
|
queue.push(...fieldSchema.simpleAllowedTypes.keys());
|
|
109
111
|
}
|
|
110
112
|
break;
|
|
111
|
-
|
|
113
|
+
}
|
|
114
|
+
default: {
|
|
112
115
|
unreachableCase(kind);
|
|
116
|
+
}
|
|
113
117
|
}
|
|
114
118
|
return transformed;
|
|
115
119
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"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C9B,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,UAAU,CACnB,mQAAmQ,CACnQ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,IAAI,UAAU,CACnB,wSAAwS,CACxS,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,gBAAgB,CACxB,OAA0C;IAE1C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,eAAe,IAAI,OAAO,CAAC;AAClE,CAAC;AAED,SAAS,cAAc,CACtB,OAA0C,EAC1C,IAAO;IAEP,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,OAA0C;IACpE,sHAAsH;IACtH,uIAAuI;IACvI,kGAAkG;IAClG,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tunreachableCase,\n\tfail,\n\ttransformMapValues,\n\tassert,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport {\n\tbrand,\n\tfilterIterable,\n\tgetOrCreate,\n\tmapIterable,\n\ttype JsonCompatibleReadOnlyObject,\n} from \"../util/index.js\";\n\nimport {\n\tExpectStored,\n\tNodeKind,\n\tUnchanged,\n\ttype SimpleSchemaTransformationOptions,\n\ttype StoredFromViewSchemaGenerationOptions,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport type {\n\tSchemaType,\n\tSimpleAllowedTypeAttributes,\n\tSimpleAllowedTypes,\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleRecordNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { createTreeSchema } from \"./treeSchema.js\";\n\n// TODO: this file, src/simple-tree/api/storedSchema.ts and src/simple-tree/core/toStored.ts should be refactored to group the logic more logically.\n// The content of src/simple-tree/api/storedSchema.ts should probably removed from the API surface, replaced by simple schema snapshotting APIs.\n// The logic from this file for converting stored-simple-schema to the persisted format can be moved to its own file.\n// The simple-schema related logic from this file and src/simple-tree/core/toStored.ts can be unified and `toStoredSchema` and its other ImplicitFieldSchema consuming variants should probably be removed in favor of acting on TreeSchema and SimpleTreeSchema directly.\n\nconst viewToStoredCache = new WeakMap<\n\tStoredFromViewSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\n/**\n * Maximally restrictive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.\n * This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.\n */\nexport const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions =\n\t{\n\t\tincludeStaged: () => false,\n\t};\n\n/**\n * Maximally permissive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.\n * This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.\n *\n * This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.\n *\n * TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.\n * If done, then this could take in an existing stored schema, and attempt to generate a valid superset.\n * This could be useful to use as the schema for unhydrated content cloned from hydrated content.\n */\nexport const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * Even if this took in a SimpleTreeSchema,\n * it would still need to walk the schema to avoid including schema that become unreachable due to filtered out staged schema.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitFieldSchema,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst treeSchema = createTreeSchema(normalizeFieldSchema(root));\n\t\tconst simpleSchema = transformSimpleSchema(treeSchema, options);\n\t\treturn simpleStoredSchemaToStoredSchema(simpleSchema);\n\t});\n}\n\n/**\n * Converts a {@link SimpleTreeSchema} from `SchemaType.View` to `SchemaType.Stored`.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a `SchemaType.Stored` {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.Stored>,\n\toptions: ExpectStored,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema<T extends SchemaType>(\n\tschema: SimpleTreeSchema<T>,\n\toptions: Unchanged,\n): SimpleTreeSchema<T>;\n\n/**\n * Converts a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema;\n\n/**\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema {\n\tconst simpleNodeSchema = new Map<string, SimpleNodeSchema>();\n\tconst root = filterFieldAllowedTypes(schema.root, options);\n\tconst queue = Array.from(root.simpleAllowedTypes.keys());\n\tfor (const identifier of queue) {\n\t\tgetOrCreate(simpleNodeSchema, identifier, (id) => {\n\t\t\tconst nodeSchema = schema.definitions.get(id) ?? fail(0xca8 /* missing schema */);\n\t\t\tconst transformed = transformSimpleNodeSchema(nodeSchema, options);\n\t\t\tconst kind = transformed.kind;\n\t\t\tswitch (kind) {\n\t\t\t\tcase NodeKind.Leaf:\n\t\t\t\t\tbreak;\n\t\t\t\tcase NodeKind.Array:\n\t\t\t\tcase NodeKind.Map:\n\t\t\t\tcase NodeKind.Record:\n\t\t\t\t\tqueue.push(...transformed.simpleAllowedTypes.keys());\n\t\t\t\t\tbreak;\n\t\t\t\tcase NodeKind.Object:\n\t\t\t\t\tfor (const fieldSchema of transformed.fields.values()) {\n\t\t\t\t\t\tqueue.push(...fieldSchema.simpleAllowedTypes.keys());\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(kind);\n\t\t\t}\n\t\t\treturn transformed;\n\t\t});\n\t}\n\t// Copy simpleNodeSchema, but in the order from the original schema.definitions\n\t// Currently we do not specify anything about the order of definitions, but it is nicer to have a stable order and some tests rely on it.\n\tconst definitions = new Map<string, SimpleNodeSchema>(\n\t\tmapIterable(\n\t\t\tfilterIterable(schema.definitions.keys(), (id) => simpleNodeSchema.has(id)),\n\t\t\t(id) => [id, simpleNodeSchema.get(id) ?? fail(0xca9 /* missing schema */)],\n\t\t),\n\t);\n\tassert(\n\t\tdefinitions.size === simpleNodeSchema.size,\n\t\t0xcaa /* Reachable schema missing from input TreeSchema */,\n\t);\n\treturn { root, definitions };\n}\n\n/**\n * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.\n * @remarks\n * This only supports simple schemas that are already logically stored schemas.\n * @privateRemarks\n * To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.\n * @see {@link ExpectStored}.\n */\nexport function simpleStoredSchemaToStoredSchema(\n\ttreeSchema: SimpleTreeSchema<SchemaType.Stored>,\n): TreeStoredSchema {\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema: transformMapValues(treeSchema.definitions, (schema) =>\n\t\t\tgetStoredSchema(schema),\n\t\t) as Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t\trootFieldSchema: convertField(treeSchema.root),\n\t};\n\treturn result;\n}\n\n/**\n * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema<SchemaType.Stored>,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema<SchemaType.Stored>,\n): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn arrayNodeStoredSchema(schema.simpleAllowedTypes, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link SimpleNodeSchema} from view to stored.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleNodeSchema<SchemaType.Stored>;\n\n/**\n * Converts a {@link SimpleNodeSchema}.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema;\n\n/**\n * TODO: Persist node metadata once schema FormatV2 is supported.\n *\n * This is only exported for use by tests: if other users need them more overloads could be provided, but this is currently sufficient.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema {\n\tconst metadata = {\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: schema.metadata.custom,\n\t\t\t\t\tdescription: schema.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t};\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tleafKind: schema.leafKind,\n\t\t\t\t...metadata,\n\t\t\t} satisfies SimpleLeafNodeSchema;\n\t\t}\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tsimpleAllowedTypes: filterAllowedTypes(schema.simpleAllowedTypes, options),\n\t\t\t} satisfies SimpleMapNodeSchema | SimpleRecordNodeSchema | SimpleArrayNodeSchema;\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tfields: transformMapValues(schema.fields, (f) => ({\n\t\t\t\t\t...filterFieldAllowedTypes(f, options),\n\t\t\t\t\tstoredKey: f.storedKey,\n\t\t\t\t})),\n\t\t\t\tallowUnknownOptionalFields: filterViewData(options, schema.allowUnknownOptionalFields),\n\t\t\t} satisfies SimpleObjectNodeSchema;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nfunction arrayNodeStoredSchema(\n\tschema: SimpleAllowedTypes<SchemaType.Stored>,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes: convertAllowedTypes(schema),\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n\n/**\n * Converts a {@link SimpleAllowedTypes} to a stored schema.\n * @param schema - The schema to convert.\n * @param options - The options to use for filtering.\n * @returns The converted stored schema.\n */\nexport function filterAllowedTypes(\n\tschema: SimpleAllowedTypes,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleAllowedTypes {\n\tconst filtered: Map<string, SimpleAllowedTypeAttributes> = new Map();\n\tfor (const [type, data] of schema) {\n\t\tif (options === Unchanged) {\n\t\t\tfiltered.set(type, { isStaged: data.isStaged });\n\t\t} else if (allowedTypeFilter(data, options)) {\n\t\t\tfiltered.set(type, { isStaged: undefined });\n\t\t}\n\t}\n\treturn filtered;\n}\n\nfunction filterFieldAllowedTypes(\n\tf: SimpleFieldSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleFieldSchema {\n\treturn {\n\t\tkind: f.kind,\n\t\tpersistedMetadata: f.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: f.metadata.custom,\n\t\t\t\t\tdescription: f.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t\tsimpleAllowedTypes: filterAllowedTypes(f.simpleAllowedTypes, options),\n\t};\n}\n\n/**\n * Converts a stored {@link SimpleAllowedTypes} to a {@link TreeTypeSet}.\n */\nfunction convertAllowedTypes(schema: SimpleAllowedTypes<SchemaType.Stored>): TreeTypeSet {\n\treturn new Set(schema.keys() as Iterable<TreeNodeSchemaIdentifier>);\n}\n\n/**\n * Filters an allowed type based on the provided options.\n * @param allowedType - The allowed type to filter.\n * @param options - The options to use for filtering.\n * @returns Whether the allowed type passes the filter.\n */\nfunction allowedTypeFilter(\n\tdata: SimpleAllowedTypeAttributes,\n\toptions: StoredSchemaGenerationOptions,\n): boolean {\n\tif (options === ExpectStored) {\n\t\tif (data.isStaged !== undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StoredFromViewSchemaGenerationOptions` to process.\",\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (data.isStaged === undefined) {\n\t\tthrow new UsageError(\n\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided as the view schema was actually a stored schema. If this was intended, use `ExpectStored` for the `StoredSchemaGenerationOptions` to indicate the input is already a stored schema and only a format conversion is required.\",\n\t\t);\n\t}\n\n\t// If the allowed type is staged, only include it if the options allow it.\n\tif (data.isStaged === false) {\n\t\treturn true;\n\t}\n\n\treturn options.includeStaged(data.isStaged);\n}\n\nfunction isStoredFromView(\n\toptions: SimpleSchemaTransformationOptions,\n): options is StoredFromViewSchemaGenerationOptions {\n\treturn typeof options === \"object\" && \"includeStaged\" in options;\n}\n\nfunction filterViewData<T>(\n\toptions: SimpleSchemaTransformationOptions,\n\tdata: T,\n): T | undefined {\n\treturn preservesViewData(options) ? data : undefined;\n}\n\n/**\n * Determines if the provided options indicate that view specific data should be preserved.\n * @remarks\n * This assumes that stored simple schema should not contain view specific data.\n * Therefore the only case where what this returns should matter is when the input schema is view schema\n * (and thus there might be view specific data).\n */\nfunction preservesViewData(options: SimpleSchemaTransformationOptions): boolean {\n\t// As noted above in the doc comment, the only case we care about the return value is when the input is a view schema.\n\t// There are two such cases: isStoredFromView where we return false, and Unchanged when applied to a view schema, where we return true.\n\t// It does not matter what we return in other cases, so for simplicity they just end up as \"true\".\n\treturn isStoredFromView(options) ? false : true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,IAAI,EACJ,kBAAkB,EAClB,MAAM,GACN,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GAQtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAsB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EACN,KAAK,EACL,cAAc,EACd,WAAW,EACX,WAAW,GAEX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACN,YAAY,EACZ,QAAQ,EACR,SAAS,GAIT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA4B,MAAM,kBA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AC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,gBAAgB,CACxB,OAA0C;IAE1C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,eAAe,IAAI,OAAO,CAAC;AAClE,CAAC;AAED,SAAS,cAAc,CACtB,OAA0C,EAC1C,IAAO;IAEP,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,OAA0C;IACpE,sHAAsH;IACtH,uIAAuI;IACvI,kGAAkG;IAClG,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tunreachableCase,\n\tfail,\n\ttransformMapValues,\n\tassert,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport {\n\tbrand,\n\tfilterIterable,\n\tgetOrCreate,\n\tmapIterable,\n\ttype JsonCompatibleReadOnlyObject,\n} from \"../util/index.js\";\n\nimport {\n\tExpectStored,\n\tNodeKind,\n\tUnchanged,\n\ttype SimpleSchemaTransformationOptions,\n\ttype StoredFromViewSchemaGenerationOptions,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport type {\n\tSchemaType,\n\tSimpleAllowedTypeAttributes,\n\tSimpleAllowedTypes,\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleRecordNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { createTreeSchema } from \"./treeSchema.js\";\n\n// TODO: this file, src/simple-tree/api/storedSchema.ts and src/simple-tree/core/toStored.ts should be refactored to group the logic more logically.\n// The content of src/simple-tree/api/storedSchema.ts should probably removed from the API surface, replaced by simple schema snapshotting APIs.\n// The logic from this file for converting stored-simple-schema to the persisted format can be moved to its own file.\n// The simple-schema related logic from this file and src/simple-tree/core/toStored.ts can be unified and `toStoredSchema` and its other ImplicitFieldSchema consuming variants should probably be removed in favor of acting on TreeSchema and SimpleTreeSchema directly.\n\nconst viewToStoredCache = new WeakMap<\n\tStoredFromViewSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\n/**\n * Maximally restrictive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.\n * This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.\n */\nexport const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions =\n\t{\n\t\tincludeStaged: () => false,\n\t};\n\n/**\n * Maximally permissive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.\n * This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.\n *\n * This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.\n *\n * TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.\n * If done, then this could take in an existing stored schema, and attempt to generate a valid superset.\n * This could be useful to use as the schema for unhydrated content cloned from hydrated content.\n */\nexport const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * Even if this took in a SimpleTreeSchema,\n * it would still need to walk the schema to avoid including schema that become unreachable due to filtered out staged schema.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitFieldSchema,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst treeSchema = createTreeSchema(normalizeFieldSchema(root));\n\t\tconst simpleSchema = transformSimpleSchema(treeSchema, options);\n\t\treturn simpleStoredSchemaToStoredSchema(simpleSchema);\n\t});\n}\n\n/**\n * Converts a {@link SimpleTreeSchema} from `SchemaType.View` to `SchemaType.Stored`.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a `SchemaType.Stored` {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.Stored>,\n\toptions: ExpectStored,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema<T extends SchemaType>(\n\tschema: SimpleTreeSchema<T>,\n\toptions: Unchanged,\n): SimpleTreeSchema<T>;\n\n/**\n * Converts a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema;\n\n/**\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema {\n\tconst simpleNodeSchema = new Map<string, SimpleNodeSchema>();\n\tconst root = filterFieldAllowedTypes(schema.root, options);\n\tconst queue = [...root.simpleAllowedTypes.keys()];\n\tfor (const identifier of queue) {\n\t\tgetOrCreate(simpleNodeSchema, identifier, (id) => {\n\t\t\tconst nodeSchema = schema.definitions.get(id) ?? fail(0xca8 /* missing schema */);\n\t\t\tconst transformed = transformSimpleNodeSchema(nodeSchema, options);\n\t\t\tconst kind = transformed.kind;\n\t\t\tswitch (kind) {\n\t\t\t\tcase NodeKind.Leaf: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase NodeKind.Array:\n\t\t\t\tcase NodeKind.Map:\n\t\t\t\tcase NodeKind.Record: {\n\t\t\t\t\tqueue.push(...transformed.simpleAllowedTypes.keys());\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase NodeKind.Object: {\n\t\t\t\t\tfor (const fieldSchema of transformed.fields.values()) {\n\t\t\t\t\t\tqueue.push(...fieldSchema.simpleAllowedTypes.keys());\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(kind);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn transformed;\n\t\t});\n\t}\n\t// Copy simpleNodeSchema, but in the order from the original schema.definitions\n\t// Currently we do not specify anything about the order of definitions, but it is nicer to have a stable order and some tests rely on it.\n\tconst definitions = new Map<string, SimpleNodeSchema>(\n\t\tmapIterable(\n\t\t\tfilterIterable(schema.definitions.keys(), (id) => simpleNodeSchema.has(id)),\n\t\t\t(id) => [id, simpleNodeSchema.get(id) ?? fail(0xca9 /* missing schema */)],\n\t\t),\n\t);\n\tassert(\n\t\tdefinitions.size === simpleNodeSchema.size,\n\t\t0xcaa /* Reachable schema missing from input TreeSchema */,\n\t);\n\treturn { root, definitions };\n}\n\n/**\n * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.\n * @remarks\n * This only supports simple schemas that are already logically stored schemas.\n * @privateRemarks\n * To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.\n * @see {@link ExpectStored}.\n */\nexport function simpleStoredSchemaToStoredSchema(\n\ttreeSchema: SimpleTreeSchema<SchemaType.Stored>,\n): TreeStoredSchema {\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema: transformMapValues(treeSchema.definitions, (schema) =>\n\t\t\tgetStoredSchema(schema),\n\t\t) as Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t\trootFieldSchema: convertField(treeSchema.root),\n\t};\n\treturn result;\n}\n\n/**\n * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema<SchemaType.Stored>,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema<SchemaType.Stored>,\n): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn arrayNodeStoredSchema(schema.simpleAllowedTypes, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link SimpleNodeSchema} from view to stored.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleNodeSchema<SchemaType.Stored>;\n\n/**\n * Converts a {@link SimpleNodeSchema}.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema;\n\n/**\n * TODO: Persist node metadata once schema FormatV2 is supported.\n *\n * This is only exported for use by tests: if other users need them more overloads could be provided, but this is currently sufficient.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema {\n\tconst metadata = {\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: schema.metadata.custom,\n\t\t\t\t\tdescription: schema.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t};\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tleafKind: schema.leafKind,\n\t\t\t\t...metadata,\n\t\t\t} satisfies SimpleLeafNodeSchema;\n\t\t}\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tsimpleAllowedTypes: filterAllowedTypes(schema.simpleAllowedTypes, options),\n\t\t\t} satisfies SimpleMapNodeSchema | SimpleRecordNodeSchema | SimpleArrayNodeSchema;\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tfields: transformMapValues(schema.fields, (f) => ({\n\t\t\t\t\t...filterFieldAllowedTypes(f, options),\n\t\t\t\t\tstoredKey: f.storedKey,\n\t\t\t\t})),\n\t\t\t\tallowUnknownOptionalFields: filterViewData(options, schema.allowUnknownOptionalFields),\n\t\t\t} satisfies SimpleObjectNodeSchema;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nfunction arrayNodeStoredSchema(\n\tschema: SimpleAllowedTypes<SchemaType.Stored>,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes: convertAllowedTypes(schema),\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n\n/**\n * Converts a {@link SimpleAllowedTypes} to a stored schema.\n * @param schema - The schema to convert.\n * @param options - The options to use for filtering.\n * @returns The converted stored schema.\n */\nexport function filterAllowedTypes(\n\tschema: SimpleAllowedTypes,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleAllowedTypes {\n\tconst filtered: Map<string, SimpleAllowedTypeAttributes> = new Map();\n\tfor (const [type, data] of schema) {\n\t\tif (options === Unchanged) {\n\t\t\tfiltered.set(type, { isStaged: data.isStaged });\n\t\t} else if (allowedTypeFilter(data, options)) {\n\t\t\tfiltered.set(type, { isStaged: undefined });\n\t\t}\n\t}\n\treturn filtered;\n}\n\nfunction filterFieldAllowedTypes(\n\tf: SimpleFieldSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleFieldSchema {\n\treturn {\n\t\tkind: f.kind,\n\t\tpersistedMetadata: f.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: f.metadata.custom,\n\t\t\t\t\tdescription: f.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t\tsimpleAllowedTypes: filterAllowedTypes(f.simpleAllowedTypes, options),\n\t};\n}\n\n/**\n * Converts a stored {@link SimpleAllowedTypes} to a {@link TreeTypeSet}.\n */\nfunction convertAllowedTypes(schema: SimpleAllowedTypes<SchemaType.Stored>): TreeTypeSet {\n\treturn new Set(schema.keys() as Iterable<TreeNodeSchemaIdentifier>);\n}\n\n/**\n * Filters an allowed type based on the provided options.\n * @param allowedType - The allowed type to filter.\n * @param options - The options to use for filtering.\n * @returns Whether the allowed type passes the filter.\n */\nfunction allowedTypeFilter(\n\tdata: SimpleAllowedTypeAttributes,\n\toptions: StoredSchemaGenerationOptions,\n): boolean {\n\tif (options === ExpectStored) {\n\t\tif (data.isStaged !== undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StoredFromViewSchemaGenerationOptions` to process.\",\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (data.isStaged === undefined) {\n\t\tthrow new UsageError(\n\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided as the view schema was actually a stored schema. If this was intended, use `ExpectStored` for the `StoredSchemaGenerationOptions` to indicate the input is already a stored schema and only a format conversion is required.\",\n\t\t);\n\t}\n\n\t// If the allowed type is staged, only include it if the options allow it.\n\tif (data.isStaged === false) {\n\t\treturn true;\n\t}\n\n\treturn options.includeStaged(data.isStaged);\n}\n\nfunction isStoredFromView(\n\toptions: SimpleSchemaTransformationOptions,\n): options is StoredFromViewSchemaGenerationOptions {\n\treturn typeof options === \"object\" && \"includeStaged\" in options;\n}\n\nfunction filterViewData<T>(\n\toptions: SimpleSchemaTransformationOptions,\n\tdata: T,\n): T | undefined {\n\treturn preservesViewData(options) ? data : undefined;\n}\n\n/**\n * Determines if the provided options indicate that view specific data should be preserved.\n * @remarks\n * This assumes that stored simple schema should not contain view specific data.\n * Therefore the only case where what this returns should matter is when the input schema is view schema\n * (and thus there might be view specific data).\n */\nfunction preservesViewData(options: SimpleSchemaTransformationOptions): boolean {\n\t// As noted above in the doc comment, the only case we care about the return value is when the input is a view schema.\n\t// There are two such cases: isStoredFromView where we return false, and Unchanged when applied to a view schema, where we return true.\n\t// It does not matter what we return in other cases, so for simplicity they just end up as \"true\".\n\treturn isStoredFromView(options) ? false : true;\n}\n"]}
|
package/lib/treeFactory.js
CHANGED
|
@@ -133,15 +133,19 @@ export function configuredSharedTreeInternal(options) {
|
|
|
133
133
|
}
|
|
134
134
|
export function resolveOptions(options) {
|
|
135
135
|
const internal = {
|
|
136
|
-
...
|
|
136
|
+
...resolveFormatOptions(options),
|
|
137
137
|
};
|
|
138
138
|
for (const optionName of Object.keys(options)) {
|
|
139
139
|
copyProperty(options, optionName, internal);
|
|
140
140
|
}
|
|
141
141
|
return internal;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
143
|
+
function resolveFormatOptions(options) {
|
|
144
|
+
const enableSharedBranches = options.enableSharedBranches ?? false;
|
|
145
|
+
if (enableSharedBranches) {
|
|
146
|
+
return sharedBranchesOptions;
|
|
147
|
+
}
|
|
148
|
+
return {};
|
|
145
149
|
}
|
|
146
150
|
const sharedBranchesOptions = {
|
|
147
151
|
messageFormatSelector: messageFormatVersionSelectorForSharedBranches,
|