@fluidframework/tree 2.52.0 → 2.53.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 +14 -2
- package/CHANGELOG.md +125 -0
- package/api-report/tree.alpha.api.md +48 -41
- package/dist/alpha.d.ts +2 -1
- package/dist/core/tree/visitDelta.d.ts +1 -1
- package/dist/core/tree/visitDelta.d.ts.map +1 -1
- package/dist/core/tree/visitDelta.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -0
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +3 -1
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts +2 -4
- package/dist/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js +3 -0
- package/dist/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts +1 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +4 -0
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +5 -5
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +4 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
- 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 +1 -0
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js +1 -0
- package/dist/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +49 -20
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/dist/feature-libraries/optional-field/optionalField.js +3 -0
- package/dist/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
- package/dist/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/dist/feature-libraries/sequence-field/types.d.ts +1 -1
- package/dist/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/dist/feature-libraries/sequence-field/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/jsonDomainSchema.d.ts +5 -3
- package/dist/jsonDomainSchema.d.ts.map +1 -1
- package/dist/jsonDomainSchema.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/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +1 -1
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/index.d.ts +0 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/schematizeTree.d.ts +23 -60
- package/dist/shared-tree/schematizeTree.d.ts.map +1 -1
- package/dist/shared-tree/schematizeTree.js +59 -151
- package/dist/shared-tree/schematizeTree.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +11 -11
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +9 -3
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts +2 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/dist/simple-tree/api/configuration.d.ts +3 -0
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +5 -1
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/create.d.ts +4 -4
- package/dist/simple-tree/api/create.d.ts.map +1 -1
- package/dist/simple-tree/api/create.js +3 -6
- package/dist/simple-tree/api/create.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts +5 -9
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js +11 -10
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +3 -2
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +3 -2
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js +3 -4
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaFactory.d.ts +9 -155
- package/dist/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactory.js +4 -47
- package/dist/simple-tree/api/schemaFactory.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +33 -11
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js +1 -7
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/schemaStatics.d.ts +158 -0
- package/dist/simple-tree/api/schemaStatics.d.ts.map +1 -0
- package/dist/simple-tree/api/schemaStatics.js +59 -0
- package/dist/simple-tree/api/schemaStatics.js.map +1 -0
- package/dist/simple-tree/api/storedSchema.d.ts +5 -3
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +4 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js +12 -6
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +46 -30
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js +20 -12
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +5 -3
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +6 -1
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
- package/dist/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
- package/dist/simple-tree/core/simpleNodeSchemaBase.js +7 -0
- package/dist/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
- package/dist/simple-tree/core/toStored.d.ts +32 -0
- package/dist/simple-tree/core/toStored.d.ts.map +1 -0
- package/dist/simple-tree/core/toStored.js +37 -0
- package/dist/simple-tree/core/toStored.js.map +1 -0
- package/dist/simple-tree/core/treeNode.d.ts +0 -3
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNode.js +3 -3
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.d.ts +7 -2
- package/dist/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts +6 -1
- package/dist/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNodeValid.js +11 -6
- package/dist/simple-tree/core/treeNodeValid.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts +19 -5
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +4 -2
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.d.ts.map +1 -1
- package/dist/simple-tree/createContext.js +1 -1
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +2 -1
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js +1 -1
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +4 -4
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +9 -2
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/leafNodeSchema.js +1 -0
- package/dist/simple-tree/leafNodeSchema.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +18 -4
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +9 -2
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
- package/dist/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +37 -26
- 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 +9 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/prepareForInsertion.d.ts +5 -5
- package/dist/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/dist/simple-tree/prepareForInsertion.js +10 -10
- package/dist/simple-tree/prepareForInsertion.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +6 -21
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +35 -11
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +68 -33
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/tableSchema.d.ts +25 -32
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +10 -24
- package/dist/tableSchema.js.map +1 -1
- package/docs/.attachments/cell-ordering/C-knows-of-ABC.png +0 -0
- package/docs/.attachments/cell-ordering/C-knows-of-C.png +0 -0
- package/docs/.attachments/cell-ordering/XvsA.png +0 -0
- package/docs/.attachments/cell-ordering/compose-a-b.png +0 -0
- package/docs/.attachments/cell-ordering/compose-a-ref-p1-b-ref-p2.png +0 -0
- package/docs/.attachments/cell-ordering/compose-b-no-ref-to-ca.png +0 -0
- package/docs/.attachments/cell-ordering/rebase-ab-over-x.png +0 -0
- package/docs/.attachments/cell-ordering/rebase-b-over-x.png +0 -0
- package/docs/.attachments/cell-ordering/rebase-b2-over-x.png +0 -0
- package/docs/.attachments/cell-ordering/rebase-b2.png +0 -0
- package/docs/.attachments/cell-ordering/rebase-to-abprime.png +0 -0
- package/docs/.attachments/cell-ordering/rebase-to-bprime.png +0 -0
- package/docs/main/cell-ordering.md +638 -0
- package/lib/alpha.d.ts +2 -1
- package/lib/core/tree/visitDelta.d.ts +1 -1
- package/lib/core/tree/visitDelta.d.ts.map +1 -1
- package/lib/core/tree/visitDelta.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -0
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -0
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts +2 -4
- package/lib/feature-libraries/default-schema/defaultEditBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js +4 -1
- package/lib/feature-libraries/default-schema/defaultEditBuilder.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +1 -0
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts +1 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/noChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +4 -0
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts +7 -0
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldChangeHandler.js +1 -0
- 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 +1 -0
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js +1 -0
- package/lib/feature-libraries/modular-schema/modularChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts +9 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +50 -21
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.d.ts.map +1 -1
- package/lib/feature-libraries/optional-field/optionalField.js +3 -0
- package/lib/feature-libraries/optional-field/optionalField.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts +1 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js +4 -0
- package/lib/feature-libraries/sequence-field/sequenceFieldChangeRebaser.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV1.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV2.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecV3.js.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/sequenceFieldCodecs.js.map +1 -1
- package/lib/feature-libraries/sequence-field/types.d.ts +1 -1
- package/lib/feature-libraries/sequence-field/types.d.ts.map +1 -1
- package/lib/feature-libraries/sequence-field/types.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jsonDomainSchema.d.ts +5 -3
- package/lib/jsonDomainSchema.d.ts.map +1 -1
- package/lib/jsonDomainSchema.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/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +2 -2
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/index.d.ts +0 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/schematizeTree.d.ts +23 -60
- package/lib/shared-tree/schematizeTree.d.ts.map +1 -1
- package/lib/shared-tree/schematizeTree.js +60 -150
- package/lib/shared-tree/schematizeTree.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +14 -14
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +10 -4
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts +2 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/lib/simple-tree/api/configuration.d.ts +3 -0
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +6 -2
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/create.d.ts +4 -4
- package/lib/simple-tree/api/create.d.ts.map +1 -1
- package/lib/simple-tree/api/create.js +3 -6
- package/lib/simple-tree/api/create.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts +5 -9
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js +11 -10
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +2 -1
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js +4 -5
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaFactory.d.ts +9 -155
- package/lib/simple-tree/api/schemaFactory.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactory.js +2 -45
- package/lib/simple-tree/api/schemaFactory.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +157 -16
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +23 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts +1 -3
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -5
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/schemaStatics.d.ts +158 -0
- package/lib/simple-tree/api/schemaStatics.d.ts.map +1 -0
- package/lib/simple-tree/api/schemaStatics.js +56 -0
- package/lib/simple-tree/api/schemaStatics.js.map +1 -0
- package/lib/simple-tree/api/storedSchema.d.ts +5 -3
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +6 -4
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js +8 -2
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +46 -30
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js +23 -12
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +5 -3
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +3 -2
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts +25 -0
- package/lib/simple-tree/core/simpleNodeSchemaBase.d.ts.map +1 -0
- package/lib/simple-tree/core/simpleNodeSchemaBase.js +6 -0
- package/lib/simple-tree/core/simpleNodeSchemaBase.js.map +1 -0
- package/lib/simple-tree/core/toStored.d.ts +32 -0
- package/lib/simple-tree/core/toStored.d.ts.map +1 -0
- package/lib/simple-tree/core/toStored.js +32 -0
- package/lib/simple-tree/core/toStored.js.map +1 -0
- package/lib/simple-tree/core/treeNode.d.ts +0 -3
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNode.js +3 -3
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.d.ts +7 -2
- package/lib/simple-tree/core/treeNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeSchema.js.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts +6 -1
- package/lib/simple-tree/core/treeNodeValid.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNodeValid.js +9 -5
- package/lib/simple-tree/core/treeNodeValid.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts +19 -5
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +4 -2
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.d.ts.map +1 -1
- package/lib/simple-tree/createContext.js +2 -2
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +2 -1
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js +1 -1
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +4 -4
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -2
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/leafNodeSchema.js +2 -1
- package/lib/simple-tree/leafNodeSchema.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +21 -7
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +12 -5
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts +2 -2
- package/lib/simple-tree/node-kinds/object/objectNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +16 -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 +12 -5
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/prepareForInsertion.d.ts +5 -5
- package/lib/simple-tree/prepareForInsertion.d.ts.map +1 -1
- package/lib/simple-tree/prepareForInsertion.js +10 -10
- package/lib/simple-tree/prepareForInsertion.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +6 -21
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +35 -11
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +67 -34
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/tableSchema.d.ts +25 -32
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +11 -25
- package/lib/tableSchema.js.map +1 -1
- package/package.json +21 -21
- package/src/core/tree/visitDelta.ts +3 -1
- package/src/feature-libraries/chunked-forest/index.ts +1 -0
- package/src/feature-libraries/default-schema/defaultEditBuilder.ts +12 -5
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +1 -0
- package/src/feature-libraries/default-schema/noChangeCodecs.ts +1 -1
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -1
- package/src/feature-libraries/index.ts +2 -0
- package/src/feature-libraries/modular-schema/fieldChangeHandler.ts +9 -0
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +1 -0
- package/src/feature-libraries/modular-schema/modularChangeCodecs.ts +1 -0
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +61 -19
- package/src/feature-libraries/optional-field/optionalField.ts +4 -0
- package/src/feature-libraries/sequence-field/sequenceFieldChangeRebaser.ts +4 -0
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV1.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV2.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecV3.ts +4 -2
- package/src/feature-libraries/sequence-field/sequenceFieldCodecs.ts +1 -1
- package/src/feature-libraries/sequence-field/types.ts +1 -1
- package/src/index.ts +2 -1
- package/src/jsonDomainSchema.ts +4 -0
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +6 -2
- package/src/shared-tree/index.ts +0 -2
- package/src/shared-tree/schematizeTree.ts +83 -199
- package/src/shared-tree/schematizingTreeView.ts +26 -12
- package/src/shared-tree/treeAlpha.ts +18 -4
- package/src/shared-tree-core/defaultResubmitMachine.ts +2 -1
- package/src/simple-tree/api/configuration.ts +10 -2
- package/src/simple-tree/api/create.ts +5 -10
- package/src/simple-tree/api/discrepancies.ts +18 -17
- package/src/simple-tree/api/index.ts +2 -3
- package/src/simple-tree/api/schemaCompatibilityTester.ts +5 -9
- package/src/simple-tree/api/schemaFactory.ts +6 -250
- package/src/simple-tree/api/schemaFactoryAlpha.ts +174 -1
- package/src/simple-tree/api/schemaFactoryRecursive.ts +1 -25
- package/src/simple-tree/api/schemaStatics.ts +291 -0
- package/src/simple-tree/api/storedSchema.ts +12 -5
- package/src/simple-tree/api/treeBeta.ts +9 -2
- package/src/simple-tree/core/allowedTypes.ts +71 -42
- package/src/simple-tree/core/index.ts +9 -1
- package/src/simple-tree/core/simpleNodeSchemaBase.ts +30 -0
- package/src/simple-tree/core/toStored.ts +58 -0
- package/src/simple-tree/core/treeNode.ts +3 -3
- package/src/simple-tree/core/treeNodeSchema.ts +8 -2
- package/src/simple-tree/core/treeNodeValid.ts +14 -5
- package/src/simple-tree/core/walkSchema.ts +23 -6
- package/src/simple-tree/createContext.ts +5 -2
- package/src/simple-tree/fieldSchema.ts +4 -2
- package/src/simple-tree/index.ts +15 -6
- package/src/simple-tree/leafNodeSchema.ts +2 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +58 -37
- package/src/simple-tree/node-kinds/map/mapNode.ts +26 -2
- package/src/simple-tree/node-kinds/object/objectNode.ts +37 -4
- package/src/simple-tree/node-kinds/record/recordNode.ts +23 -2
- package/src/simple-tree/prepareForInsertion.ts +12 -7
- package/src/simple-tree/simpleSchema.ts +6 -26
- package/src/simple-tree/toStoredSchema.ts +107 -44
- package/src/tableSchema.ts +40 -35
|
@@ -3,240 +3,124 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { assert
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
CursorLocationType,
|
|
10
|
-
type ITreeCursorSynchronous,
|
|
11
|
-
type TreeStoredSchema,
|
|
12
|
-
rootFieldKey,
|
|
13
|
-
schemaDataIsEmpty,
|
|
14
|
-
} from "../core/index.js";
|
|
8
|
+
import { type TreeStoredSchema, rootFieldKey, schemaDataIsEmpty } from "../core/index.js";
|
|
15
9
|
import {
|
|
16
10
|
FieldKinds,
|
|
17
11
|
allowsRepoSuperset,
|
|
18
|
-
cursorForMapTreeField,
|
|
19
12
|
defaultSchemaPolicy,
|
|
20
|
-
|
|
13
|
+
type IDefaultEditBuilder,
|
|
14
|
+
type TreeChunk,
|
|
21
15
|
} from "../feature-libraries/index.js";
|
|
22
|
-
import { toStoredSchema, type SchemaCompatibilityTester } from "../simple-tree/index.js";
|
|
23
|
-
import { isReadonlyArray } from "../util/index.js";
|
|
24
16
|
|
|
25
17
|
import type { ITreeCheckout } from "./treeCheckout.js";
|
|
26
18
|
|
|
19
|
+
export function canInitialize(checkout: ITreeCheckout): boolean {
|
|
20
|
+
// Check for empty.
|
|
21
|
+
return checkout.forest.isEmpty && schemaDataIsEmpty(checkout.storedSchema);
|
|
22
|
+
}
|
|
23
|
+
|
|
27
24
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* Requires `storedSchema` to be in its default/empty state.
|
|
31
|
-
*
|
|
32
|
-
* This is done in such a way that if the content (implicitly assumed to start empty)
|
|
33
|
-
* is never out of schema.
|
|
34
|
-
* This means that if the root field of the new schema requires content (like a value field),
|
|
35
|
-
* a temporary intermediate schema is used so the initial empty state is not out of schema.
|
|
25
|
+
* Initialize a checkout with a schema and tree content.
|
|
26
|
+
* This function should only be called when the tree is uninitialized (no schema or content).
|
|
36
27
|
*
|
|
37
|
-
*
|
|
28
|
+
* @param checkout - The tree checkout to initialize.
|
|
29
|
+
* @param newSchema - The new schema to apply.
|
|
30
|
+
* @param contentFactory - A function that sets the initial tree content.
|
|
31
|
+
* Invoked after a schema containing all nodes from newSchema is applied.
|
|
32
|
+
* Note that the final root field schema may not have been applied yet: if the root is required, it will be optional at this time
|
|
33
|
+
* (so the root being empty before the insertion is not out of schema).
|
|
34
|
+
* @remarks
|
|
35
|
+
* If `newSchema` is not compatible with the empty tree, this function handles it using an intermediate schema
|
|
36
|
+
* which supports the empty tree as well as the final tree content.
|
|
37
|
+
* @privateRemarks
|
|
38
|
+
* This takes in a checkout using a subset of the checkout interface to enable easier unit testing.
|
|
38
39
|
*/
|
|
39
|
-
export function
|
|
40
|
-
|
|
41
|
-
storedSchema: ITreeCheckout["storedSchema"];
|
|
42
|
-
updateSchema: ITreeCheckout["updateSchema"];
|
|
43
|
-
},
|
|
40
|
+
export function initialize(
|
|
41
|
+
checkout: Pick<ITreeCheckout, "storedSchema" | "updateSchema">,
|
|
44
42
|
newSchema: TreeStoredSchema,
|
|
45
43
|
setInitialTree: () => void,
|
|
46
44
|
): void {
|
|
47
45
|
assert(
|
|
48
|
-
schemaDataIsEmpty(
|
|
46
|
+
schemaDataIsEmpty(checkout.storedSchema),
|
|
49
47
|
0x743 /* cannot initialize after a schema is set */,
|
|
50
48
|
);
|
|
51
49
|
|
|
52
|
-
const rootSchema = newSchema.rootFieldSchema;
|
|
53
|
-
const rootKind = rootSchema.kind;
|
|
54
|
-
|
|
55
50
|
// To keep the data in schema during the update, first define a schema that tolerates the current (empty) tree as well as the final (initial) tree.
|
|
56
|
-
let
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
rootKind
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
51
|
+
let intermediateSchema: TreeStoredSchema;
|
|
52
|
+
{
|
|
53
|
+
const rootSchema = newSchema.rootFieldSchema;
|
|
54
|
+
const rootKind = rootSchema.kind;
|
|
55
|
+
if (
|
|
56
|
+
rootKind === FieldKinds.sequence.identifier ||
|
|
57
|
+
rootKind === FieldKinds.optional.identifier
|
|
58
|
+
) {
|
|
59
|
+
// These kinds are known to tolerate empty, so use the schema as is:
|
|
60
|
+
intermediateSchema = newSchema;
|
|
61
|
+
} else {
|
|
62
|
+
assert(rootKind === FieldKinds.required.identifier, 0x5c8 /* Unexpected kind */);
|
|
63
|
+
// Replace value kind with optional kind in root field schema:
|
|
64
|
+
intermediateSchema = {
|
|
65
|
+
nodeSchema: newSchema.nodeSchema,
|
|
66
|
+
rootFieldSchema: {
|
|
67
|
+
kind: FieldKinds.optional.identifier,
|
|
68
|
+
types: rootSchema.types,
|
|
69
|
+
persistedMetadata: rootSchema.persistedMetadata,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
assert(
|
|
77
|
-
allowsRepoSuperset(defaultSchemaPolicy, newSchema,
|
|
76
|
+
allowsRepoSuperset(defaultSchemaPolicy, newSchema, intermediateSchema),
|
|
78
77
|
0x5c9 /* Incremental Schema during update should allow a superset of the final schema */,
|
|
79
78
|
);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// Insert initial tree
|
|
79
|
+
|
|
80
|
+
checkout.updateSchema(intermediateSchema);
|
|
83
81
|
setInitialTree();
|
|
84
82
|
|
|
85
83
|
// If intermediate schema is not final desired schema, update to the final schema:
|
|
86
|
-
if (
|
|
84
|
+
if (intermediateSchema !== newSchema) {
|
|
87
85
|
// This makes the root more strict, so set allowNonSupersetSchema to true.
|
|
88
|
-
|
|
86
|
+
checkout.updateSchema(newSchema, true);
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
export enum UpdateType {
|
|
93
|
-
/**
|
|
94
|
-
* Already compatible, no update needed.
|
|
95
|
-
*/
|
|
96
|
-
None,
|
|
97
|
-
/**
|
|
98
|
-
* Schema can be upgraded leaving tree as is.
|
|
99
|
-
*/
|
|
100
|
-
SchemaCompatible,
|
|
101
|
-
/**
|
|
102
|
-
* No update currently supported.
|
|
103
|
-
*/
|
|
104
|
-
Incompatible,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
90
|
/**
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
): UpdateType {
|
|
114
|
-
const compatibility = viewSchema.checkCompatibility(checkout.storedSchema);
|
|
115
|
-
|
|
116
|
-
if (compatibility.canUpgrade && compatibility.canView) {
|
|
117
|
-
// Compatible as is
|
|
118
|
-
return UpdateType.None;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (!compatibility.canUpgrade) {
|
|
122
|
-
// Existing stored schema permits trees which are incompatible with the view schema, so schema can not be updated
|
|
123
|
-
return UpdateType.Incompatible;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
assert(!compatibility.canView, 0x8bd /* unexpected case */);
|
|
127
|
-
assert(compatibility.canUpgrade, 0x8be /* unexpected case */);
|
|
128
|
-
|
|
129
|
-
return UpdateType.SchemaCompatible;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function canInitialize(checkout: ITreeCheckout): boolean {
|
|
133
|
-
// Check for empty.
|
|
134
|
-
return checkout.forest.isEmpty && schemaDataIsEmpty(checkout.storedSchema);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function normalizeNewFieldContent(
|
|
138
|
-
content: readonly ITreeCursorSynchronous[] | ITreeCursorSynchronous | undefined,
|
|
139
|
-
): ITreeCursorSynchronous {
|
|
140
|
-
if (content === undefined) {
|
|
141
|
-
return cursorForMapTreeField([]);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (isReadonlyArray(content)) {
|
|
145
|
-
return cursorForMapTreeField(content.map((c) => mapTreeFromCursor(c)));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (content.mode === CursorLocationType.Fields) {
|
|
149
|
-
return content;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return cursorForMapTreeField([mapTreeFromCursor(content)]);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Initialize a checkout with a schema and tree content.
|
|
157
|
-
* This function should only be called when the tree is uninitialized (no schema or content).
|
|
158
|
-
* @remarks
|
|
159
|
-
*
|
|
160
|
-
* If the proposed schema (from `treeContent`) is not compatible with the empty tree, this function handles using an intermediate schema
|
|
161
|
-
* which supports the empty tree as well as the final tree content.
|
|
162
|
-
*/
|
|
163
|
-
export function initialize(checkout: ITreeCheckout, treeContent: TreeStoredContent): void {
|
|
164
|
-
checkout.transaction.start();
|
|
165
|
-
try {
|
|
166
|
-
initializeContent(checkout, treeContent.schema, () => {
|
|
167
|
-
const field = { field: rootFieldKey, parent: undefined };
|
|
168
|
-
const content = normalizeNewFieldContent(treeContent.initialTree);
|
|
169
|
-
const contentChunk = checkout.forest.chunkField(content);
|
|
170
|
-
|
|
171
|
-
switch (checkout.storedSchema.rootFieldSchema.kind) {
|
|
172
|
-
case FieldKinds.optional.identifier: {
|
|
173
|
-
const fieldEditor = checkout.editor.optionalField(field);
|
|
174
|
-
assert(
|
|
175
|
-
content.getFieldLength() <= 1,
|
|
176
|
-
0x7f4 /* optional field content should normalize at most one item */,
|
|
177
|
-
);
|
|
178
|
-
fieldEditor.set(contentChunk.topLevelLength === 0 ? undefined : contentChunk, true);
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
case FieldKinds.sequence.identifier: {
|
|
182
|
-
const fieldEditor = checkout.editor.sequenceField(field);
|
|
183
|
-
// TODO: should do an idempotent edit here.
|
|
184
|
-
fieldEditor.insert(0, contentChunk);
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
default: {
|
|
188
|
-
fail(0xac7 /* unexpected root field kind during initialize */);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
} finally {
|
|
193
|
-
checkout.transaction.commit();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Ensure a {@link ITreeCheckout} can be used with a given {@link SchemaCompatibilityTester}.
|
|
199
|
-
*
|
|
91
|
+
* Construct a general purpose `setInitialTree` for use with {@link initialize} from a function that returns a chunk.
|
|
92
|
+
* @param contentFactory - A function that returns the initial tree content as a chunk.
|
|
93
|
+
* Invoked after a schema containing all nodes from newSchema is applied.
|
|
94
|
+
* Note that the final root field schema may not have been applied yet: if the root is required, it will be optional at this time
|
|
95
|
+
* (so the root being empty before the insertion is not out of schema).
|
|
200
96
|
* @remarks
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* @param viewSchema - View schema that `checkout` should be made compatible with.
|
|
204
|
-
* @param allowedSchemaModifications - Flags enum describing the ways this is allowed to modify `checkout`.
|
|
205
|
-
* @param checkout - To be modified as needed to be compatible with `viewSchema`.
|
|
206
|
-
* @param treeContent - Content to be used to initialize `checkout`'s the tree if needed and allowed.
|
|
207
|
-
* @returns true iff checkout now is compatible with `viewSchema`.
|
|
97
|
+
* This does not support sequence roots as they are not allowed in the public API surface.
|
|
98
|
+
* A test utility for them can be found as `initializeSequenceRoot` for testing internal logic which uses a sequence root.
|
|
208
99
|
*/
|
|
209
|
-
export function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
case UpdateType.Incompatible: {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
case UpdateType.SchemaCompatible: {
|
|
222
|
-
checkout.updateSchema(toStoredSchema(viewSchema.viewSchema.root));
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
default: {
|
|
226
|
-
unreachableCase(updatedNeeded);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
100
|
+
export function initializerFromChunk(
|
|
101
|
+
checkout: Pick<ITreeCheckout, "storedSchema"> & {
|
|
102
|
+
readonly editor: IDefaultEditBuilder;
|
|
103
|
+
},
|
|
104
|
+
contentFactory: () => TreeChunk,
|
|
105
|
+
): () => void {
|
|
106
|
+
return () => initializeFromChunk(checkout, contentFactory());
|
|
229
107
|
}
|
|
230
108
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
109
|
+
function initializeFromChunk(
|
|
110
|
+
checkout: Pick<ITreeCheckout, "storedSchema"> & {
|
|
111
|
+
readonly editor: IDefaultEditBuilder;
|
|
112
|
+
},
|
|
113
|
+
contentChunk: TreeChunk,
|
|
114
|
+
): void {
|
|
115
|
+
const field = { field: rootFieldKey, parent: undefined };
|
|
116
|
+
assert(
|
|
117
|
+
checkout.storedSchema.rootFieldSchema.kind === FieldKinds.optional.identifier,
|
|
118
|
+
0xc11 /* initializerFromChunk only supports optional roots */,
|
|
119
|
+
);
|
|
120
|
+
const fieldEditor = checkout.editor.optionalField(field);
|
|
121
|
+
assert(
|
|
122
|
+
contentChunk.topLevelLength <= 1,
|
|
123
|
+
0x7f4 /* optional field content should normalize at most one item */,
|
|
124
|
+
);
|
|
125
|
+
fieldEditor.set(contentChunk.topLevelLength === 0 ? undefined : contentChunk, true);
|
|
242
126
|
}
|
|
@@ -16,7 +16,7 @@ import { anchorSlot } from "../core/index.js";
|
|
|
16
16
|
import {
|
|
17
17
|
type NodeIdentifierManager,
|
|
18
18
|
defaultSchemaPolicy,
|
|
19
|
-
|
|
19
|
+
cursorForMapTreeField,
|
|
20
20
|
TreeStatus,
|
|
21
21
|
Context,
|
|
22
22
|
} from "../feature-libraries/index.js";
|
|
@@ -51,10 +51,11 @@ import {
|
|
|
51
51
|
areImplicitFieldSchemaEqual,
|
|
52
52
|
prepareForInsertionContextless,
|
|
53
53
|
type FieldSchema,
|
|
54
|
-
toStoredSchema,
|
|
55
54
|
tryDisposeTreeNode,
|
|
56
55
|
FieldSchemaAlpha,
|
|
57
56
|
TreeViewConfigurationAlpha,
|
|
57
|
+
toInitialSchema,
|
|
58
|
+
toUpgradeSchema,
|
|
58
59
|
} from "../simple-tree/index.js";
|
|
59
60
|
import {
|
|
60
61
|
type Breakable,
|
|
@@ -63,7 +64,7 @@ import {
|
|
|
63
64
|
type WithBreakable,
|
|
64
65
|
} from "../util/index.js";
|
|
65
66
|
|
|
66
|
-
import { canInitialize,
|
|
67
|
+
import { canInitialize, initialize, initializerFromChunk } from "./schematizeTree.js";
|
|
67
68
|
import type { ITreeCheckout, TreeCheckout } from "./treeCheckout.js";
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -172,7 +173,7 @@ export class SchematizingSimpleTreeView<
|
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
this.runSchemaEdit(() => {
|
|
175
|
-
const schema =
|
|
176
|
+
const schema = toInitialSchema(this.config.schema);
|
|
176
177
|
const mapTree = prepareForInsertionContextless(
|
|
177
178
|
content as InsertableContent | undefined,
|
|
178
179
|
this.rootFieldSchema,
|
|
@@ -181,12 +182,22 @@ export class SchematizingSimpleTreeView<
|
|
|
181
182
|
policy: defaultSchemaPolicy,
|
|
182
183
|
},
|
|
183
184
|
this,
|
|
185
|
+
schema.rootFieldSchema,
|
|
184
186
|
);
|
|
185
187
|
|
|
186
|
-
|
|
188
|
+
this.checkout.transaction.start();
|
|
189
|
+
|
|
190
|
+
initialize(
|
|
191
|
+
this.checkout,
|
|
187
192
|
schema,
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
initializerFromChunk(this.checkout, () => {
|
|
194
|
+
// This must be done after initial schema is set!
|
|
195
|
+
return this.checkout.forest.chunkField(
|
|
196
|
+
cursorForMapTreeField(mapTree === undefined ? [] : [mapTree]),
|
|
197
|
+
);
|
|
198
|
+
}),
|
|
199
|
+
);
|
|
200
|
+
this.checkout.transaction.commit();
|
|
190
201
|
});
|
|
191
202
|
}
|
|
192
203
|
|
|
@@ -205,10 +216,8 @@ export class SchematizingSimpleTreeView<
|
|
|
205
216
|
);
|
|
206
217
|
}
|
|
207
218
|
|
|
208
|
-
this.
|
|
209
|
-
|
|
210
|
-
assert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);
|
|
211
|
-
});
|
|
219
|
+
const newSchema = toUpgradeSchema(this.viewSchema.viewSchema.root);
|
|
220
|
+
this.runSchemaEdit(() => this.checkout.updateSchema(newSchema));
|
|
212
221
|
}
|
|
213
222
|
|
|
214
223
|
/**
|
|
@@ -436,7 +445,12 @@ export class SchematizingSimpleTreeView<
|
|
|
436
445
|
);
|
|
437
446
|
}
|
|
438
447
|
const view = this.getFlexTreeContext();
|
|
439
|
-
setField(
|
|
448
|
+
setField(
|
|
449
|
+
view.root,
|
|
450
|
+
this.rootFieldSchema,
|
|
451
|
+
newRoot as InsertableContent | undefined,
|
|
452
|
+
this.checkout.storedSchema.rootFieldSchema,
|
|
453
|
+
);
|
|
440
454
|
}
|
|
441
455
|
|
|
442
456
|
// #region Branching
|
|
@@ -36,7 +36,6 @@ import {
|
|
|
36
36
|
verboseFromCursor,
|
|
37
37
|
type TreeEncodingOptions,
|
|
38
38
|
type VerboseTree,
|
|
39
|
-
toStoredSchema,
|
|
40
39
|
extractPersistedSchema,
|
|
41
40
|
type TreeBranch,
|
|
42
41
|
TreeViewConfigurationAlpha,
|
|
@@ -52,6 +51,9 @@ import {
|
|
|
52
51
|
tryGetTreeNodeForField,
|
|
53
52
|
isObjectNodeSchema,
|
|
54
53
|
isTreeNode,
|
|
54
|
+
toInitialSchema,
|
|
55
|
+
convertField,
|
|
56
|
+
toUnhydratedSchema,
|
|
55
57
|
} from "../simple-tree/index.js";
|
|
56
58
|
import { brand, extractFromOpaque, type JsonCompatible } from "../util/index.js";
|
|
57
59
|
import {
|
|
@@ -493,7 +495,11 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
493
495
|
return undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
494
496
|
}
|
|
495
497
|
const cursor = cursorFromVerbose(data, schemalessConfig);
|
|
496
|
-
return createFromCursor(
|
|
498
|
+
return createFromCursor(
|
|
499
|
+
schema,
|
|
500
|
+
cursor,
|
|
501
|
+
convertField(normalizeFieldSchema(schema), toUnhydratedSchema),
|
|
502
|
+
);
|
|
497
503
|
},
|
|
498
504
|
|
|
499
505
|
exportConcise,
|
|
@@ -523,11 +529,18 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
523
529
|
const batch: FieldBatch = [cursor];
|
|
524
530
|
// If none provided, create a compressor which will not compress anything.
|
|
525
531
|
const idCompressor = options.idCompressor ?? createIdCompressor();
|
|
532
|
+
|
|
533
|
+
// Grabbing an existing stored schema from the node is important to ensure that unknown optional fields can be preserved.
|
|
534
|
+
// Note that if the node is unhydrated, this can result in all staged allowed types being included in the schema, which might be undesired.
|
|
535
|
+
const storedSchema = isTreeNode(node)
|
|
536
|
+
? getKernel(node).context.flexContext.schema
|
|
537
|
+
: toInitialSchema(schema);
|
|
538
|
+
|
|
526
539
|
const context: FieldBatchEncodingContext = {
|
|
527
540
|
encodeType: TreeCompressionStrategy.Compressed,
|
|
528
541
|
idCompressor,
|
|
529
542
|
originatorId: idCompressor.localSessionId, // TODO: Why is this needed?
|
|
530
|
-
schema: { schema:
|
|
543
|
+
schema: { schema: storedSchema, policy: defaultSchemaPolicy },
|
|
531
544
|
};
|
|
532
545
|
const result = codec.encode(batch, context);
|
|
533
546
|
return result;
|
|
@@ -543,7 +556,8 @@ export const TreeAlpha: TreeAlpha = {
|
|
|
543
556
|
const config = new TreeViewConfigurationAlpha({ schema });
|
|
544
557
|
const content: ViewContent = {
|
|
545
558
|
// Always use a v1 schema codec for consistency.
|
|
546
|
-
|
|
559
|
+
// TODO: reevaluate how staged schema should behave in schema import/export APIs before stabilizing this.
|
|
560
|
+
schema: extractPersistedSchema(config.schema, FluidClientVersion.v2_0, () => true),
|
|
547
561
|
tree: compressedData,
|
|
548
562
|
idCompressor: options.idCompressor ?? createIdCompressor(),
|
|
549
563
|
};
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
import type { GraphCommit, TaggedChange } from "../core/index.js";
|
|
15
15
|
import { disposeSymbol, hasSome } from "../util/index.js";
|
|
16
16
|
|
|
17
|
-
import type { ChangeEnricherReadonlyCheckout
|
|
17
|
+
import type { ChangeEnricherReadonlyCheckout } from "./changeEnricher.js";
|
|
18
|
+
import type { ResubmitMachine } from "./resubmitMachine.js";
|
|
18
19
|
|
|
19
20
|
interface PendingChange<TChange> {
|
|
20
21
|
commit: GraphCommit<TChange>;
|
|
@@ -25,7 +25,11 @@ import {
|
|
|
25
25
|
evaluateLazySchema,
|
|
26
26
|
markSchemaMostDerived,
|
|
27
27
|
} from "../core/index.js";
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
permissiveStoredSchemaGenerationOptions,
|
|
30
|
+
restrictiveStoredSchemaGenerationOptions,
|
|
31
|
+
toStoredSchema,
|
|
32
|
+
} from "../toStoredSchema.js";
|
|
29
33
|
import {
|
|
30
34
|
isArrayNodeSchema,
|
|
31
35
|
isMapNodeSchema,
|
|
@@ -161,6 +165,9 @@ export interface ITreeViewConfiguration<
|
|
|
161
165
|
|
|
162
166
|
/**
|
|
163
167
|
* Configuration for {@link ViewableTree.viewWith}.
|
|
168
|
+
* @privateRemarks
|
|
169
|
+
* When `ImplicitAnnotatedFieldSchema` is stabilized, TSchema should be updated to use it.
|
|
170
|
+
* When doing this, the example for `staged` will need to be updated/simplified.
|
|
164
171
|
* @sealed @public
|
|
165
172
|
*/
|
|
166
173
|
export class TreeViewConfiguration<
|
|
@@ -213,7 +220,8 @@ export class TreeViewConfiguration<
|
|
|
213
220
|
|
|
214
221
|
// Eagerly perform this conversion to surface errors sooner.
|
|
215
222
|
// Includes detection of duplicate schema identifiers.
|
|
216
|
-
toStoredSchema(config.schema);
|
|
223
|
+
toStoredSchema(config.schema, restrictiveStoredSchemaGenerationOptions);
|
|
224
|
+
toStoredSchema(config.schema, permissiveStoredSchemaGenerationOptions);
|
|
217
225
|
|
|
218
226
|
const definitions = new Map<string, SimpleNodeSchema & TreeNodeSchema>();
|
|
219
227
|
|
|
@@ -13,12 +13,9 @@ import {
|
|
|
13
13
|
mapCursorFields,
|
|
14
14
|
type ITreeCursorSynchronous,
|
|
15
15
|
type SchemaAndPolicy,
|
|
16
|
+
type TreeFieldStoredSchema,
|
|
16
17
|
} from "../../core/index.js";
|
|
17
|
-
import {
|
|
18
|
-
normalizeFieldSchema,
|
|
19
|
-
type ImplicitFieldSchema,
|
|
20
|
-
type TreeFieldFromImplicitField,
|
|
21
|
-
} from "../fieldSchema.js";
|
|
18
|
+
import type { ImplicitFieldSchema, TreeFieldFromImplicitField } from "../fieldSchema.js";
|
|
22
19
|
import {
|
|
23
20
|
type Context,
|
|
24
21
|
getOrCreateNodeFromInnerNode,
|
|
@@ -32,33 +29,31 @@ import {
|
|
|
32
29
|
throwOutOfSchema,
|
|
33
30
|
} from "../../feature-libraries/index.js";
|
|
34
31
|
import { getUnhydratedContext } from "../createContext.js";
|
|
35
|
-
import { convertField } from "../toStoredSchema.js";
|
|
36
32
|
import { unknownTypeError } from "./customTree.js";
|
|
37
33
|
|
|
38
34
|
/**
|
|
39
35
|
* Creates an unhydrated simple-tree field from a cursor in nodes mode.
|
|
40
36
|
* @remarks
|
|
41
37
|
* Does not support providing missing defaults values.
|
|
42
|
-
* Validates the field is in schema using the provided `contextForNewNodes`
|
|
38
|
+
* Validates the field is in schema using `destinationSchema` the provided `contextForNewNodes` or the default unhydrated context if not provided.
|
|
43
39
|
*/
|
|
44
40
|
export function createFromCursor<const TSchema extends ImplicitFieldSchema>(
|
|
45
41
|
schema: TSchema,
|
|
46
42
|
cursor: ITreeCursorSynchronous | undefined,
|
|
43
|
+
destinationSchema: TreeFieldStoredSchema,
|
|
47
44
|
contextForNewNodes?: Context,
|
|
48
45
|
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
49
46
|
const context = contextForNewNodes ?? getUnhydratedContext(schema);
|
|
50
47
|
assert(context.flexContext.isHydrated() === false, 0xbfe /* Expected unhydrated context */);
|
|
51
48
|
const mapTrees = cursor === undefined ? [] : [unhydratedFlexTreeFromCursor(context, cursor)];
|
|
52
49
|
|
|
53
|
-
const rootFieldSchema = convertField(normalizeFieldSchema(schema));
|
|
54
|
-
|
|
55
50
|
const schemaAndPolicy: SchemaAndPolicy = {
|
|
56
51
|
policy: defaultSchemaPolicy,
|
|
57
52
|
schema: context.flexContext.schema,
|
|
58
53
|
};
|
|
59
54
|
|
|
60
55
|
// Assuming the caller provides the correct `contextForNewNodes`, this should handle unknown optional fields.
|
|
61
|
-
isFieldInSchema(mapTrees,
|
|
56
|
+
isFieldInSchema(mapTrees, destinationSchema, schemaAndPolicy, throwOutOfSchema);
|
|
62
57
|
|
|
63
58
|
if (mapTrees.length === 0) {
|
|
64
59
|
return undefined as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
@@ -89,11 +89,13 @@ export interface FieldDiscrepancyLocation {
|
|
|
89
89
|
export interface AllowedTypeDiscrepancy extends FieldDiscrepancyLocation {
|
|
90
90
|
readonly mismatch: "allowedTypes";
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Annotated allowed types in viewed schema
|
|
93
|
+
* (excluding {@link SchemaStaticsAlpha.staged | staged} schema) which are not allowed in stored schema.
|
|
93
94
|
*/
|
|
94
95
|
readonly view: readonly AnnotatedAllowedType<TreeNodeSchema>[];
|
|
95
96
|
/**
|
|
96
|
-
*
|
|
97
|
+
* Allowed type identifiers in stored schema which are not allowed in view schema
|
|
98
|
+
* (including the view schema's {@link SchemaStaticsAlpha.staged | staged} schema).
|
|
97
99
|
*/
|
|
98
100
|
readonly stored: readonly TreeNodeSchemaIdentifier[];
|
|
99
101
|
}
|
|
@@ -296,28 +298,28 @@ function* getNodeDiscrepancies(
|
|
|
296
298
|
|
|
297
299
|
/**
|
|
298
300
|
* Returns the allowed types that are not present in both the given view and stored schemas.
|
|
299
|
-
* It returns a tuple containing two arrays:
|
|
300
|
-
* 1. The first array contains the allowed types that are present in the view schema but not in the stored schema.
|
|
301
|
-
* 2. The second array contains the allowed types that are present in the stored schema but not in the view schema.
|
|
302
301
|
*/
|
|
303
302
|
export function findExtraAllowedTypes(
|
|
304
303
|
viewAllowedTypes: readonly AnnotatedAllowedType<TreeNodeSchema>[],
|
|
305
304
|
storedAllowedTypes: TreeTypeSet,
|
|
306
|
-
): {
|
|
307
|
-
viewExtra: readonly AnnotatedAllowedType<TreeNodeSchema>[];
|
|
308
|
-
storedExtra: TreeNodeSchemaIdentifier[];
|
|
309
|
-
} {
|
|
305
|
+
): Pick<AllowedTypeDiscrepancy, "view" | "stored"> {
|
|
310
306
|
const viewNodeSchemaIdentifiers = new Set(
|
|
311
307
|
viewAllowedTypes.map((value) => value.type.identifier),
|
|
312
308
|
);
|
|
313
309
|
|
|
314
|
-
|
|
315
|
-
|
|
310
|
+
// TODO:
|
|
311
|
+
// Add detecting which SchemaUpgrades have been made.
|
|
312
|
+
// When doing so, each will fall into one of three states: staged, partially applied, or fully applied.
|
|
313
|
+
// This would allow for nicer compatibility errors and more detailed compatibility status in the future.
|
|
314
|
+
const view = viewAllowedTypes.filter(
|
|
315
|
+
(value) =>
|
|
316
|
+
!storedAllowedTypes.has(brand(value.type.identifier)) &&
|
|
317
|
+
value.metadata.stagedSchemaUpgrade === undefined,
|
|
316
318
|
);
|
|
317
|
-
const
|
|
319
|
+
const stored = [...storedAllowedTypes].filter(
|
|
318
320
|
(value) => !viewNodeSchemaIdentifiers.has(value),
|
|
319
321
|
);
|
|
320
|
-
return {
|
|
322
|
+
return { view, stored };
|
|
321
323
|
}
|
|
322
324
|
|
|
323
325
|
/**
|
|
@@ -384,14 +386,13 @@ function* getAllowedTypeDiscrepancies(
|
|
|
384
386
|
identifier: TreeNodeSchemaIdentifier | undefined,
|
|
385
387
|
fieldKey: FieldKey | undefined,
|
|
386
388
|
): Iterable<FieldDiscrepancy> {
|
|
387
|
-
const
|
|
388
|
-
if (
|
|
389
|
+
const discrepancies = findExtraAllowedTypes(view, stored);
|
|
390
|
+
if (discrepancies.view.length > 0 || discrepancies.stored.length > 0) {
|
|
389
391
|
yield {
|
|
392
|
+
...discrepancies,
|
|
390
393
|
identifier,
|
|
391
394
|
fieldKey,
|
|
392
395
|
mismatch: "allowedTypes",
|
|
393
|
-
view: viewExtra,
|
|
394
|
-
stored: storedExtra,
|
|
395
396
|
} satisfies AllowedTypeDiscrepancy;
|
|
396
397
|
}
|
|
397
398
|
}
|
|
@@ -24,16 +24,15 @@ export type {
|
|
|
24
24
|
ITreeAlpha,
|
|
25
25
|
} from "./tree.js";
|
|
26
26
|
export { asTreeViewAlpha } from "./tree.js";
|
|
27
|
+
export { type SchemaStatics, schemaStatics } from "./schemaStatics.js";
|
|
27
28
|
export {
|
|
28
29
|
SchemaFactory,
|
|
29
30
|
type ScopedSchemaName,
|
|
30
31
|
type SchemaFactoryObjectOptions,
|
|
31
|
-
type SchemaStatics,
|
|
32
|
-
schemaStatics,
|
|
33
32
|
type NodeSchemaOptions,
|
|
34
33
|
type NodeSchemaOptionsAlpha,
|
|
35
34
|
} from "./schemaFactory.js";
|
|
36
|
-
export { SchemaFactoryAlpha } from "./schemaFactoryAlpha.js";
|
|
35
|
+
export { SchemaFactoryAlpha, type SchemaStaticsAlpha } from "./schemaFactoryAlpha.js";
|
|
37
36
|
export type {
|
|
38
37
|
ValidateRecursiveSchema,
|
|
39
38
|
FixRecursiveArraySchema,
|