@fluidframework/tree 2.63.0-358419 → 2.63.0-359461
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 +4 -0
- package/api-report/tree.alpha.api.md +31 -5
- package/api-report/tree.beta.api.md +26 -0
- package/api-report/tree.legacy.beta.api.md +26 -0
- package/dist/alpha.d.ts +4 -3
- package/dist/beta.d.ts +3 -0
- package/dist/codec/codec.d.ts +32 -0
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +32 -1
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/index.d.ts +1 -1
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/codec/index.js +3 -1
- package/dist/codec/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 +4 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema-stored/index.d.ts +1 -1
- package/dist/core/schema-stored/index.d.ts.map +1 -1
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +5 -7
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +3 -6
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +4 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +5 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/core/tree/index.d.ts +1 -0
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +3 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +3 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +5 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts +2 -0
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
- package/dist/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/dist/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/index.js +2 -1
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +19 -5
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts +1 -1
- package/dist/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/index.js +2 -1
- package/dist/feature-libraries/default-schema/index.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +4 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +5 -1
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts +1 -0
- package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/index.js +3 -1
- package/dist/feature-libraries/forest-summary/index.js.map +1 -1
- package/dist/feature-libraries/index.d.ts +5 -5
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +7 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js +1 -1
- package/dist/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/dist/feature-libraries/schema-edits/index.d.ts +1 -1
- package/dist/feature-libraries/schema-edits/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/index.js +2 -1
- package/dist/feature-libraries/schema-edits/index.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +4 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +9 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +2 -1
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +5 -1
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/index.d.ts +1 -1
- package/dist/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/index.js +2 -1
- package/dist/feature-libraries/schema-index/index.js.map +1 -1
- package/dist/legacy.d.ts +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializableDomainSchema.d.ts +12 -16
- package/dist/serializableDomainSchema.d.ts.map +1 -1
- package/dist/serializableDomainSchema.js +8 -8
- package/dist/serializableDomainSchema.js.map +1 -1
- package/dist/shared-tree/index.d.ts +2 -1
- package/dist/shared-tree/index.d.ts.map +1 -1
- package/dist/shared-tree/index.js +4 -1
- package/dist/shared-tree/index.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +18 -2
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +122 -8
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +17 -2
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +31 -18
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts +7 -12
- package/dist/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/defaultResubmitMachine.js +53 -73
- package/dist/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +7 -4
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +42 -11
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +2 -1
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +6 -1
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts +7 -4
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +44 -23
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/resubmitMachine.d.ts +9 -18
- package/dist/shared-tree-core/resubmitMachine.d.ts.map +1 -1
- package/dist/shared-tree-core/resubmitMachine.js.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.d.ts +6 -4
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +12 -13
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +7 -166
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +11 -44
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +90 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js +55 -0
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +37 -18
- package/dist/simple-tree/api/tree.d.ts.map +1 -1
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/treeBeta.d.ts +12 -2
- package/dist/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/treeBeta.js +6 -0
- package/dist/simple-tree/api/treeBeta.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts +3 -2
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNode.js +3 -2
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/dist/util/brand.d.ts +1 -1
- package/dist/util/brand.js.map +1 -1
- package/docs/main/compatibility.md +8 -0
- package/lib/alpha.d.ts +4 -3
- package/lib/beta.d.ts +3 -0
- package/lib/codec/codec.d.ts +32 -0
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +28 -0
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/index.d.ts +1 -1
- 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/core/index.d.ts +2 -2
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/schema-stored/index.d.ts +1 -1
- package/lib/core/schema-stored/index.d.ts.map +1 -1
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +5 -7
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -6
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +4 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +3 -0
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/core/tree/index.d.ts +1 -0
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -0
- package/lib/core/tree/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +3 -2
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +3 -0
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts +2 -0
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts +2 -2
- package/lib/feature-libraries/chunked-forest/codec/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts +1 -1
- package/lib/feature-libraries/chunked-forest/index.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/index.js +1 -1
- package/lib/feature-libraries/chunked-forest/index.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +5 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +17 -4
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts +1 -1
- package/lib/feature-libraries/default-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/index.js +1 -1
- package/lib/feature-libraries/default-schema/index.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +4 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +3 -0
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts +1 -0
- package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/index.js +1 -0
- package/lib/feature-libraries/forest-summary/index.js.map +1 -1
- package/lib/feature-libraries/index.d.ts +5 -5
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +5 -5
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js +1 -1
- package/lib/feature-libraries/modular-schema/modularChangeFamily.js.map +1 -1
- package/lib/feature-libraries/schema-edits/index.d.ts +1 -1
- package/lib/feature-libraries/schema-edits/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/index.js +1 -1
- package/lib/feature-libraries/schema-edits/index.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +4 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +8 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +2 -1
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +3 -0
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/index.d.ts +1 -1
- package/lib/feature-libraries/schema-index/index.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/index.js +1 -1
- package/lib/feature-libraries/schema-index/index.js.map +1 -1
- package/lib/legacy.d.ts +3 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serializableDomainSchema.d.ts +12 -16
- package/lib/serializableDomainSchema.d.ts.map +1 -1
- package/lib/serializableDomainSchema.js +9 -9
- package/lib/serializableDomainSchema.js.map +1 -1
- package/lib/shared-tree/index.d.ts +2 -1
- package/lib/shared-tree/index.d.ts.map +1 -1
- package/lib/shared-tree/index.js +2 -1
- package/lib/shared-tree/index.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +18 -2
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +126 -13
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +17 -2
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +30 -18
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts +7 -12
- package/lib/shared-tree-core/defaultResubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/defaultResubmitMachine.js +55 -75
- package/lib/shared-tree-core/defaultResubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +7 -4
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +40 -10
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +2 -1
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +2 -1
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts +7 -4
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +42 -22
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/resubmitMachine.d.ts +9 -18
- package/lib/shared-tree-core/resubmitMachine.d.ts.map +1 -1
- package/lib/shared-tree-core/resubmitMachine.js.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.d.ts +6 -4
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +13 -14
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +7 -166
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +12 -45
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +90 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js +56 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +37 -18
- package/lib/simple-tree/api/tree.d.ts.map +1 -1
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/treeBeta.d.ts +12 -2
- package/lib/simple-tree/api/treeBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/treeBeta.js +7 -1
- package/lib/simple-tree/api/treeBeta.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts +3 -2
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNode.js +3 -2
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/core/treeNodeKernel.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/lib/util/brand.d.ts +1 -1
- package/lib/util/brand.js.map +1 -1
- package/package.json +21 -21
- package/src/codec/codec.ts +60 -0
- package/src/codec/index.ts +3 -0
- package/src/core/index.ts +3 -0
- package/src/core/schema-stored/index.ts +1 -0
- package/src/core/schema-stored/schema.ts +5 -6
- package/src/core/tree/detachedFieldIndexCodecs.ts +9 -0
- package/src/core/tree/index.ts +6 -0
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +6 -1
- package/src/feature-libraries/chunked-forest/codec/format.ts +2 -0
- package/src/feature-libraries/chunked-forest/codec/index.ts +2 -1
- package/src/feature-libraries/chunked-forest/index.ts +2 -0
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +29 -5
- package/src/feature-libraries/default-schema/index.ts +2 -0
- package/src/feature-libraries/forest-summary/codec.ts +7 -0
- package/src/feature-libraries/forest-summary/index.ts +1 -0
- package/src/feature-libraries/index.ts +12 -1
- package/src/feature-libraries/modular-schema/modularChangeFamily.ts +1 -1
- package/src/feature-libraries/schema-edits/index.ts +5 -1
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +17 -1
- package/src/feature-libraries/schema-index/codec.ts +5 -0
- package/src/feature-libraries/schema-index/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/serializableDomainSchema.ts +12 -11
- package/src/shared-tree/index.ts +6 -0
- package/src/shared-tree/sharedTree.ts +151 -11
- package/src/shared-tree/sharedTreeChangeCodecs.ts +68 -30
- package/src/shared-tree/treeCheckout.ts +1 -1
- package/src/shared-tree-core/defaultResubmitMachine.ts +77 -120
- package/src/shared-tree-core/editManagerCodecs.ts +62 -9
- package/src/shared-tree-core/index.ts +12 -1
- package/src/shared-tree-core/messageCodecs.ts +70 -27
- package/src/shared-tree-core/resubmitMachine.ts +12 -20
- package/src/shared-tree-core/sharedTreeCore.ts +26 -18
- package/src/simple-tree/api/schemaFactoryAlpha.ts +16 -296
- package/src/simple-tree/api/schemaFactoryBeta.ts +269 -1
- package/src/simple-tree/api/tree.ts +37 -18
- package/src/simple-tree/api/treeBeta.ts +36 -1
- package/src/simple-tree/api/typesUnsafe.ts +1 -1
- package/src/simple-tree/core/treeNode.ts +3 -2
- package/src/simple-tree/core/treeNodeKernel.ts +1 -1
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +2 -2
- package/src/util/brand.ts +1 -1
|
@@ -3,7 +3,41 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import type {
|
|
7
|
+
ImplicitAllowedTypes,
|
|
8
|
+
NodeKind,
|
|
9
|
+
TreeNodeSchema,
|
|
10
|
+
TreeNodeSchemaBoth,
|
|
11
|
+
TreeNodeSchemaClass,
|
|
12
|
+
TreeNodeSchemaNonClass,
|
|
13
|
+
WithType,
|
|
14
|
+
} from "../core/index.js";
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
recordSchema,
|
|
18
|
+
type RecordNodeInsertableData,
|
|
19
|
+
type TreeRecordNode,
|
|
20
|
+
} from "../node-kinds/index.js";
|
|
21
|
+
import {
|
|
22
|
+
SchemaFactory,
|
|
23
|
+
scoped,
|
|
24
|
+
structuralName,
|
|
25
|
+
type NodeSchemaOptions,
|
|
26
|
+
type ScopedSchemaName,
|
|
27
|
+
} from "./schemaFactory.js";
|
|
28
|
+
import type { System_Unsafe, TreeRecordNodeUnsafe } from "./typesUnsafe.js";
|
|
29
|
+
|
|
30
|
+
// These imports prevent a large number of type references in the API reports from showing up as *_2.
|
|
31
|
+
/* eslint-disable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */
|
|
32
|
+
import type {
|
|
33
|
+
FieldProps,
|
|
34
|
+
FieldSchemaAlpha,
|
|
35
|
+
FieldPropsAlpha,
|
|
36
|
+
FieldKind,
|
|
37
|
+
} from "../fieldSchema.js";
|
|
38
|
+
import type { LeafSchema } from "../leafNodeSchema.js";
|
|
39
|
+
import type { SimpleLeafNodeSchema } from "../simpleSchema.js";
|
|
40
|
+
/* eslint-enable unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars, import/no-duplicates */
|
|
7
41
|
|
|
8
42
|
/**
|
|
9
43
|
* {@link SchemaFactory} with additional beta APIs.
|
|
@@ -25,4 +59,238 @@ export class SchemaFactoryBeta<
|
|
|
25
59
|
): SchemaFactoryBeta<ScopedSchemaName<TScope, T>, TNameInner> {
|
|
26
60
|
return new SchemaFactoryBeta(scoped(this, name));
|
|
27
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Define a structurally typed {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.
|
|
65
|
+
*
|
|
66
|
+
* @param allowedTypes - The types that may appear in the record.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* The identifier for this record is defined as a function of the provided types.
|
|
70
|
+
* It is still scoped to this `SchemaFactory`, but multiple calls with the same arguments will return the same
|
|
71
|
+
* schema object, providing somewhat structural typing.
|
|
72
|
+
* This does not support recursive types.
|
|
73
|
+
*
|
|
74
|
+
* If using these structurally named records, other types in this schema builder should avoid names of the form `Record<${string}>`.
|
|
75
|
+
*
|
|
76
|
+
* The underlying data format for `Record` nodes is the same as that for `Map` nodes.
|
|
77
|
+
* Therefore, changing an existing `Map` schema to a `Record` schema (or vice versa) is
|
|
78
|
+
* a non-breaking change and does not require schema migration.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* The returned schema should be used as a schema directly:
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const MyRecord = factory.record(factory.number);
|
|
84
|
+
* type MyRecord = NodeFromSchema<typeof Record>;
|
|
85
|
+
* ```
|
|
86
|
+
* Or inline:
|
|
87
|
+
* ```typescript
|
|
88
|
+
* factory.object("Foo", { myRecord: factory.record(factory.number) });
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @privateRemarks
|
|
92
|
+
* The name produced at the type-level here is not as specific as it could be; however, doing type-level sorting and escaping is a real mess.
|
|
93
|
+
* There are cases where not having this full type provided will be less than ideal, since TypeScript's structural types will allow assignment between runtime incompatible types at compile time.
|
|
94
|
+
* For example, attempts to narrow unions of structural records by name won't work.
|
|
95
|
+
* Planned future changes to move to a class based schema system as well as factor function based node construction should mostly avoid these issues,
|
|
96
|
+
* though there may still be some problematic cases even after that work is done.
|
|
97
|
+
*
|
|
98
|
+
* The return value is a class, but its type is intentionally not specific enough to indicate it is a class.
|
|
99
|
+
* This prevents callers of this from sub-classing it, which is unlikely to work well (due to the ease of accidentally giving two different calls to this different subclasses)
|
|
100
|
+
* when working with structural typing.
|
|
101
|
+
*
|
|
102
|
+
* {@label STRUCTURAL}
|
|
103
|
+
*/
|
|
104
|
+
public record<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(
|
|
105
|
+
allowedTypes: T,
|
|
106
|
+
): TreeNodeSchemaNonClass<
|
|
107
|
+
/* Name */ ScopedSchemaName<TScope, `Record<${string}>`>,
|
|
108
|
+
/* Kind */ NodeKind.Record,
|
|
109
|
+
/* TNode */ TreeRecordNode<T> &
|
|
110
|
+
WithType<ScopedSchemaName<TScope, `Record<${string}>`>, NodeKind.Record>,
|
|
111
|
+
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
112
|
+
/* ImplicitlyConstructable */ true,
|
|
113
|
+
/* Info */ T,
|
|
114
|
+
/* TConstructorExtra */ undefined
|
|
115
|
+
>;
|
|
116
|
+
/**
|
|
117
|
+
* Define (and add to this library) a {@link TreeNodeSchemaClass} for a {@link (TreeRecordNode:interface)}.
|
|
118
|
+
*
|
|
119
|
+
* @param name - Unique identifier for this schema within this factory's scope.
|
|
120
|
+
* @param allowedTypes - The types that may appear in the record.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* The underlying data format for `Record` nodes is the same as that for `Map` nodes.
|
|
124
|
+
* Therefore, changing an existing `Map` schema to a `Record` schema (or vice versa) is
|
|
125
|
+
* a non-breaking change and does not require schema migration.
|
|
126
|
+
*
|
|
127
|
+
* Like TypeScript `Record`s, record nodes have some potential pitfalls.
|
|
128
|
+
* For example: TypeScript makes assumptions about built-in keys being present (e.g. `toString`, `hasOwnProperty`, etc.).
|
|
129
|
+
* Since these are otherwise valid keys in a record, this can lead to unexpected behavior.
|
|
130
|
+
* To prevent inconsistent behavior, these built-ins are hidden by record nodes.
|
|
131
|
+
* This means that if you try to call these built-ins (e.g. `toString()`) on a record node, you will get an error.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* class NamedRecord extends factory.record("name", factory.number) {}
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* {@label NAMED}
|
|
139
|
+
*/
|
|
140
|
+
public record<const Name extends TName, const T extends ImplicitAllowedTypes>(
|
|
141
|
+
name: Name,
|
|
142
|
+
allowedTypes: T,
|
|
143
|
+
): TreeNodeSchemaClass<
|
|
144
|
+
/* Name */ ScopedSchemaName<TScope, Name>,
|
|
145
|
+
/* Kind */ NodeKind.Record,
|
|
146
|
+
/* TNode */ TreeRecordNode<T> & WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,
|
|
147
|
+
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
148
|
+
/* ImplicitlyConstructable */ true,
|
|
149
|
+
/* Info */ T,
|
|
150
|
+
/* TConstructorExtra */ undefined
|
|
151
|
+
>;
|
|
152
|
+
/**
|
|
153
|
+
* {@link SchemaFactoryBeta.record} implementation.
|
|
154
|
+
*
|
|
155
|
+
* @privateRemarks
|
|
156
|
+
* This should return {@link TreeNodeSchemaBoth}: see note on {@link SchemaFactory.map} implementation for details.
|
|
157
|
+
*/
|
|
158
|
+
public record<const T extends ImplicitAllowedTypes>(
|
|
159
|
+
nameOrAllowedTypes: TName | ((T & TreeNodeSchema) | readonly TreeNodeSchema[]),
|
|
160
|
+
maybeAllowedTypes?: T,
|
|
161
|
+
): TreeNodeSchema<
|
|
162
|
+
/* Name */ ScopedSchemaName<TScope, string>,
|
|
163
|
+
/* Kind */ NodeKind.Record,
|
|
164
|
+
/* TNode */ TreeRecordNode<T>,
|
|
165
|
+
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
166
|
+
/* ImplicitlyConstructable */ true,
|
|
167
|
+
/* Info */ T
|
|
168
|
+
> {
|
|
169
|
+
if (maybeAllowedTypes === undefined) {
|
|
170
|
+
const types = nameOrAllowedTypes as (T & TreeNodeSchema) | readonly TreeNodeSchema[];
|
|
171
|
+
const fullName = structuralName("Record", types);
|
|
172
|
+
return this.getStructuralType(fullName, types, () =>
|
|
173
|
+
this.namedRecord(
|
|
174
|
+
fullName,
|
|
175
|
+
nameOrAllowedTypes as T,
|
|
176
|
+
/* customizable */ false,
|
|
177
|
+
/* implicitlyConstructable */ true,
|
|
178
|
+
),
|
|
179
|
+
) as TreeNodeSchemaClass<
|
|
180
|
+
/* Name */ ScopedSchemaName<TScope, string>,
|
|
181
|
+
/* Kind */ NodeKind.Record,
|
|
182
|
+
/* TNode */ TreeRecordNode<T>,
|
|
183
|
+
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
184
|
+
/* ImplicitlyConstructable */ true,
|
|
185
|
+
/* Info */ T,
|
|
186
|
+
/* TConstructorExtra */ undefined
|
|
187
|
+
>;
|
|
188
|
+
}
|
|
189
|
+
const out: TreeNodeSchemaBoth<
|
|
190
|
+
/* Name */ ScopedSchemaName<TScope, string>,
|
|
191
|
+
/* Kind */ NodeKind.Record,
|
|
192
|
+
/* TNode */ TreeRecordNode<T>,
|
|
193
|
+
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
194
|
+
/* ImplicitlyConstructable */ true,
|
|
195
|
+
/* Info */ T,
|
|
196
|
+
/* TConstructorExtra */ undefined
|
|
197
|
+
> = this.namedRecord(
|
|
198
|
+
nameOrAllowedTypes as TName,
|
|
199
|
+
maybeAllowedTypes,
|
|
200
|
+
/* customizable */ true,
|
|
201
|
+
/* implicitlyConstructable */ true,
|
|
202
|
+
);
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Define a {@link TreeNodeSchema} for a {@link (TreeRecordNode:interface)}.
|
|
208
|
+
*
|
|
209
|
+
* @param name - Unique identifier for this schema within this factory's scope.
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* This is not intended to be used directly, use the overload of `record` which takes a name instead.
|
|
213
|
+
*/
|
|
214
|
+
private namedRecord<
|
|
215
|
+
Name extends TName | string,
|
|
216
|
+
const T extends ImplicitAllowedTypes,
|
|
217
|
+
const ImplicitlyConstructable extends boolean,
|
|
218
|
+
const TCustomMetadata = unknown,
|
|
219
|
+
>(
|
|
220
|
+
name: Name,
|
|
221
|
+
allowedTypes: T,
|
|
222
|
+
customizable: boolean,
|
|
223
|
+
implicitlyConstructable: ImplicitlyConstructable,
|
|
224
|
+
options?: NodeSchemaOptions<TCustomMetadata>,
|
|
225
|
+
): TreeNodeSchemaBoth<
|
|
226
|
+
/* Name */ ScopedSchemaName<TScope, Name>,
|
|
227
|
+
/* Kind */ NodeKind.Record,
|
|
228
|
+
/* TNode */ TreeRecordNode<T> &
|
|
229
|
+
WithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,
|
|
230
|
+
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
231
|
+
/* ImplicitlyConstructable */ ImplicitlyConstructable,
|
|
232
|
+
/* Info */ T,
|
|
233
|
+
/* TConstructorExtra */ undefined
|
|
234
|
+
> {
|
|
235
|
+
const record = recordSchema({
|
|
236
|
+
identifier: scoped<TScope, TName, Name>(this, name),
|
|
237
|
+
info: allowedTypes,
|
|
238
|
+
customizable,
|
|
239
|
+
implicitlyConstructable,
|
|
240
|
+
metadata: options?.metadata,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
return record as TreeNodeSchemaBoth<
|
|
244
|
+
/* Name */ ScopedSchemaName<TScope, Name>,
|
|
245
|
+
/* Kind */ NodeKind.Record,
|
|
246
|
+
/* TNode */ TreeRecordNode<T> &
|
|
247
|
+
WithType<ScopedSchemaName<TScope, string>, NodeKind.Record>,
|
|
248
|
+
/* TInsertable */ RecordNodeInsertableData<T>,
|
|
249
|
+
/* ImplicitlyConstructable */ ImplicitlyConstructable,
|
|
250
|
+
/* Info */ T,
|
|
251
|
+
/* TConstructorExtra */ undefined
|
|
252
|
+
>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* {@link SchemaFactoryBeta.(record:2)} except tweaked to work better for recursive types.
|
|
257
|
+
* Use with {@link ValidateRecursiveSchema} for improved type safety.
|
|
258
|
+
* @remarks
|
|
259
|
+
* This version of `SchemaFactory.record` uses the same workarounds as {@link SchemaFactory.objectRecursive}.
|
|
260
|
+
* See {@link ValidateRecursiveSchema} for additional information about using recursive schema.
|
|
261
|
+
*/
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
263
|
+
public recordRecursive<
|
|
264
|
+
Name extends TName,
|
|
265
|
+
const T extends System_Unsafe.ImplicitAllowedTypesUnsafe,
|
|
266
|
+
const TCustomMetadata = unknown,
|
|
267
|
+
>(name: Name, allowedTypes: T, options?: NodeSchemaOptions<TCustomMetadata>) {
|
|
268
|
+
const RecordSchema = this.namedRecord(
|
|
269
|
+
name,
|
|
270
|
+
allowedTypes as T & ImplicitAllowedTypes,
|
|
271
|
+
/* customizable */ true,
|
|
272
|
+
// Setting this to true seems to work ok currently, but not for other node kinds.
|
|
273
|
+
// Supporting this could be fragile and might break other future changes, so it's being kept as false for now.
|
|
274
|
+
/* implicitlyConstructable */ false,
|
|
275
|
+
options,
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
return RecordSchema as TreeNodeSchemaClass<
|
|
279
|
+
/* Name */ ScopedSchemaName<TScope, Name>,
|
|
280
|
+
/* Kind */ NodeKind.Record,
|
|
281
|
+
/* TNode */ TreeRecordNodeUnsafe<T> &
|
|
282
|
+
WithType<ScopedSchemaName<TScope, Name>, NodeKind.Record>,
|
|
283
|
+
/* TInsertable */ {
|
|
284
|
+
// Ideally this would be
|
|
285
|
+
// RestrictiveStringRecord<InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>>,
|
|
286
|
+
// but doing so breaks recursive types.
|
|
287
|
+
// Instead we do a less nice version:
|
|
288
|
+
readonly [P in string]: System_Unsafe.InsertableTreeNodeFromImplicitAllowedTypesUnsafe<T>;
|
|
289
|
+
},
|
|
290
|
+
/* ImplicitlyConstructable */ false,
|
|
291
|
+
/* Info */ T,
|
|
292
|
+
/* TConstructorExtra */ undefined,
|
|
293
|
+
/* TCustomMetadata */ TCustomMetadata
|
|
294
|
+
>;
|
|
295
|
+
}
|
|
28
296
|
}
|
|
@@ -322,18 +322,25 @@ export interface TreeView<in out TSchema extends ImplicitFieldSchema> extends ID
|
|
|
322
322
|
readonly compatibility: SchemaCompatibilityStatus;
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
|
-
* When
|
|
325
|
+
* When {@link SchemaCompatibilityStatus.canUpgrade} is true,
|
|
326
326
|
* this can be used to modify the stored schema to make it match the view schema.
|
|
327
|
-
* This will update the compatibility state, and allow access to `root`.
|
|
328
|
-
* Beware that this may impact other clients' ability to view the document depending on the application's schema compatibility policy!
|
|
329
327
|
* @remarks
|
|
330
|
-
*
|
|
328
|
+
* This will update the {@link TreeView.compatibility}, allowing access to `root`.
|
|
329
|
+
* Beware that this may impact other clients' ability to view the document: see {@link SchemaCompatibilityStatus.canView} for more information.
|
|
330
|
+
*
|
|
331
|
+
* It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.
|
|
332
|
+
* {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.
|
|
331
333
|
* @privateRemarks
|
|
332
334
|
* In the future, more upgrade options could be provided here.
|
|
333
335
|
* Some options that could be added:
|
|
334
336
|
* - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.
|
|
335
337
|
* - apply converters and upgrade the document.
|
|
336
338
|
* - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).
|
|
339
|
+
* - update only a specific change (add an optional field, or apply a staged upgrade)
|
|
340
|
+
* - update persistedMetadata or not
|
|
341
|
+
*
|
|
342
|
+
* As persisted metadata becomes more supported, how it interacts with isEquivalent and upgradeSchema should be clarified:
|
|
343
|
+
* for now the docs are being left somewhat vague to allow flexibility in this area.
|
|
337
344
|
*/
|
|
338
345
|
upgradeSchema(): void;
|
|
339
346
|
|
|
@@ -382,6 +389,8 @@ export interface TreeViewAlpha<
|
|
|
382
389
|
* Information about a view schema's compatibility with the document's stored schema.
|
|
383
390
|
*
|
|
384
391
|
* See SharedTree's README for more information about choosing a compatibility policy.
|
|
392
|
+
* @privateRemarks
|
|
393
|
+
* See {@link SchemaCompatibilityTester} for the implementation of this compatibility checking.
|
|
385
394
|
* @sealed @public
|
|
386
395
|
*/
|
|
387
396
|
export interface SchemaCompatibilityStatus {
|
|
@@ -396,38 +405,41 @@ export interface SchemaCompatibilityStatus {
|
|
|
396
405
|
*
|
|
397
406
|
* - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)
|
|
398
407
|
*
|
|
399
|
-
* - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (
|
|
408
|
+
* - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (for example: an object node type containing a required field with no allowed types)
|
|
400
409
|
*
|
|
401
410
|
* These cases are typically not interesting to applications.
|
|
411
|
+
*
|
|
412
|
+
* Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.
|
|
413
|
+
*
|
|
414
|
+
* For the computation of this equivalence, {@link SchemaStaticsAlpha.staged | staged} schemas are not included.
|
|
415
|
+
* If there are any unknown optional fields, even if allowed by {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.
|
|
402
416
|
*/
|
|
403
417
|
readonly isEquivalent: boolean;
|
|
404
418
|
|
|
405
419
|
/**
|
|
406
420
|
* Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.
|
|
407
421
|
* If false, {@link TreeView.root} will throw upon access.
|
|
422
|
+
* @remarks
|
|
423
|
+
* If the view schema does not opt into supporting any additional cases, then `canView` is only true when `isEquivalent` is also true.
|
|
424
|
+
* The view schema can however opt into supporting additional cases, and thus can also view documents with stored schema which would be equivalent, except for the following discrepancies:
|
|
408
425
|
*
|
|
409
|
-
*
|
|
410
|
-
* Do not rely on this:
|
|
411
|
-
* there are near-term plans to extend support for viewing documents when the stored schema contains additional optional fields not present in the view schema.
|
|
412
|
-
* The other two types of backward-compatible changes (field relaxations and addition of allowed field types) will eventually be supported as well,
|
|
413
|
-
* likely through out-of-schema content adapters that the application can provide alongside their view schema.
|
|
426
|
+
* - An object node with {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.
|
|
414
427
|
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
428
|
+
* - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsAlpha.staged | staged} in the view schema.
|
|
429
|
+
*
|
|
430
|
+
* In these cases `canUpgrade` and `isEquivalent` will be false.
|
|
418
431
|
*
|
|
419
|
-
* @remarks
|
|
420
432
|
* When the documents allowed by the view schema is a strict superset of those by the stored schema,
|
|
421
|
-
*
|
|
433
|
+
* `canView` is false because writes to the document using the view schema could make the document violate its stored schema.
|
|
422
434
|
* In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.
|
|
423
435
|
* See {@link SchemaCompatibilityStatus.canUpgrade}.
|
|
424
436
|
*
|
|
425
|
-
* Future
|
|
437
|
+
* Future versions of SharedTree may provide readonly access to the document in this case because that would be safe,
|
|
426
438
|
* but this is not currently supported.
|
|
427
439
|
*
|
|
428
440
|
* @privateRemarks
|
|
429
441
|
* A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.
|
|
430
|
-
* This is not sufficient: the simple-tree layer's read APIs
|
|
442
|
+
* This is not sufficient: the simple-tree layer's read APIs only tolerate very specific cases beyond their schema (unknown optional fields).
|
|
431
443
|
* For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,
|
|
432
444
|
* read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.
|
|
433
445
|
* Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.
|
|
@@ -435,8 +447,15 @@ export interface SchemaCompatibilityStatus {
|
|
|
435
447
|
readonly canView: boolean;
|
|
436
448
|
|
|
437
449
|
/**
|
|
438
|
-
* True
|
|
450
|
+
* True when {@link TreeView.upgradeSchema} can add support for all content required to be supported by the view schema.
|
|
451
|
+
* @remarks
|
|
439
452
|
* When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).
|
|
453
|
+
*
|
|
454
|
+
* When adding optional fields to schema which previously were marked with {@link SchemaFactoryObjectOptions.allowUnknownOptionalFields}
|
|
455
|
+
* the schema upgrade (assuming no other changes are included) will allow the previous version to view.
|
|
456
|
+
* Even this case must still must be done with caution however as only clients with the newly added field will be able to do future upgrades.
|
|
457
|
+
* Thus if a version of an application is shipped that adds an unknown optional field, all future versions should include it, even if its no longer used,
|
|
458
|
+
* to ensure that documents containing it can still be upgraded.
|
|
440
459
|
*/
|
|
441
460
|
readonly canUpgrade: boolean;
|
|
442
461
|
|
|
@@ -9,6 +9,7 @@ import { brand } from "../../util/index.js";
|
|
|
9
9
|
import {
|
|
10
10
|
Context,
|
|
11
11
|
getKernel,
|
|
12
|
+
getOrCreateNodeFromInnerNode,
|
|
12
13
|
isTreeNode,
|
|
13
14
|
UnhydratedContext,
|
|
14
15
|
type NodeKind,
|
|
@@ -17,7 +18,15 @@ import {
|
|
|
17
18
|
type WithType,
|
|
18
19
|
} from "../core/index.js";
|
|
19
20
|
import { getUnhydratedContext } from "../createContext.js";
|
|
20
|
-
import type {
|
|
21
|
+
import type {
|
|
22
|
+
ImplicitFieldSchema,
|
|
23
|
+
InsertableTreeFieldFromImplicitField,
|
|
24
|
+
TreeFieldFromImplicitField,
|
|
25
|
+
} from "../fieldSchema.js";
|
|
26
|
+
import {
|
|
27
|
+
unhydratedFlexTreeFromInsertable,
|
|
28
|
+
type InsertableContent,
|
|
29
|
+
} from "../unhydratedFlexTreeFromInsertable.js";
|
|
21
30
|
|
|
22
31
|
import { createFromCursor } from "./create.js";
|
|
23
32
|
import type { TreeChangeEvents } from "./treeChangeEvents.js";
|
|
@@ -159,6 +168,20 @@ export interface TreeBeta {
|
|
|
159
168
|
// replaceIdentifiers?: true;
|
|
160
169
|
// },
|
|
161
170
|
// ): TreeFieldFromImplicitField<TSchema>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Construct tree content that is compatible with the field defined by the provided `schema`.
|
|
174
|
+
* @param schema - The schema for what to construct. As this is an {@link ImplicitFieldSchema}, a {@link FieldSchema}, {@link TreeNodeSchema} or {@link AllowedTypes} array can be provided.
|
|
175
|
+
* @param data - The data used to construct the field content.
|
|
176
|
+
* @remarks
|
|
177
|
+
* When providing a {@link TreeNodeSchemaClass}, this is the same as invoking its constructor except that an unhydrated node can also be provided.
|
|
178
|
+
* This function exists as a generalization that can be used in other cases as well,
|
|
179
|
+
* such as when `undefined` might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.
|
|
180
|
+
*/
|
|
181
|
+
create<const TSchema extends ImplicitFieldSchema>(
|
|
182
|
+
schema: TSchema,
|
|
183
|
+
data: InsertableTreeFieldFromImplicitField<TSchema>,
|
|
184
|
+
): Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
162
185
|
}
|
|
163
186
|
|
|
164
187
|
/**
|
|
@@ -202,4 +225,16 @@ export const TreeBeta: TreeBeta = {
|
|
|
202
225
|
TreeFieldFromImplicitField<TSchema>
|
|
203
226
|
>;
|
|
204
227
|
},
|
|
228
|
+
|
|
229
|
+
create<const TSchema extends ImplicitFieldSchema>(
|
|
230
|
+
schema: TSchema,
|
|
231
|
+
data: InsertableTreeFieldFromImplicitField<TSchema>,
|
|
232
|
+
): Unhydrated<TreeFieldFromImplicitField<TSchema>> {
|
|
233
|
+
const mapTree = unhydratedFlexTreeFromInsertable(
|
|
234
|
+
data as InsertableContent | undefined,
|
|
235
|
+
schema,
|
|
236
|
+
);
|
|
237
|
+
const result = mapTree === undefined ? undefined : getOrCreateNodeFromInnerNode(mapTree);
|
|
238
|
+
return result as Unhydrated<TreeFieldFromImplicitField<TSchema>>;
|
|
239
|
+
},
|
|
205
240
|
};
|
|
@@ -533,7 +533,7 @@ export interface MapNodeCustomizableSchemaUnsafe<
|
|
|
533
533
|
* {@link Unenforced} version of {@link TreeRecordNode}.
|
|
534
534
|
* @remarks
|
|
535
535
|
* Do not use this type directly: it's only needed in the implementation of generic logic which define recursive schema, not when using recursive schema.
|
|
536
|
-
* @system @sealed @
|
|
536
|
+
* @system @sealed @beta
|
|
537
537
|
*/
|
|
538
538
|
export interface TreeRecordNodeUnsafe<
|
|
539
539
|
TAllowedTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe,
|
|
@@ -28,13 +28,14 @@ import { markEager } from "./flexList.js";
|
|
|
28
28
|
*
|
|
29
29
|
* 2. Explicit construction of {@link Unhydrated} nodes using either {@link TreeNodeSchemaClass} as a constructor or {@link TreeNodeSchemaNonClass|TreeNodeSchemaNonClass.create}.
|
|
30
30
|
* Either way the {@link TreeNodeSchema} produced must be produced using a {@link SchemaFactory}.
|
|
31
|
+
* There are also higher level APIs which wrap these, including {@link (TreeBeta:interface).create}, {@link (TreeBeta:interface).clone},
|
|
32
|
+
* and import APIs like {@link (TreeAlpha:interface).importConcise}, {@link (TreeAlpha:interface).importVerbose}, and {@link (TreeAlpha:interface).importCompressed}.
|
|
31
33
|
*
|
|
32
34
|
* 3. Implicit construction: Several APIs which logically require an unhydrated TreeNode also allow passing in a value which could be used to explicitly construct the node instead.
|
|
33
|
-
* These APIs internally call the constructor with the provided value, so it's really just a special case of the above option.
|
|
35
|
+
* These APIs internally call the constructor with the provided value (typically behaving like {@link (TreeAlpha:interface).create}), so it's really just a special case of the above option.
|
|
34
36
|
* Note that when constructing nodes, sometimes implicit construction is not allowed
|
|
35
37
|
* (either at runtime due to ambiguous types or at compile time due to TypeScript limitations):
|
|
36
38
|
* in such cases, explicit construction must be used.
|
|
37
|
-
*
|
|
38
39
|
* @privateRemarks
|
|
39
40
|
* This is a class not an interface to enable stricter type checking (see {@link TreeNode.#brand})
|
|
40
41
|
* and some runtime enforcement of schema class policy (see the the validation in the constructor).
|
|
@@ -385,7 +385,7 @@ class KernelEventBuffer implements Listenable<KernelEvents> {
|
|
|
385
385
|
readonly #events = createEmitter<KernelEvents>();
|
|
386
386
|
|
|
387
387
|
#eventSource: Listenable<KernelEvents> & HasListeners<KernelEvents>;
|
|
388
|
-
#disposeSourceListeners: Map<keyof KernelEvents, Off> = new Map();
|
|
388
|
+
readonly #disposeSourceListeners: Map<keyof KernelEvents, Off> = new Map();
|
|
389
389
|
|
|
390
390
|
/**
|
|
391
391
|
* Buffer of fields that have changed since events were paused.
|
|
@@ -28,7 +28,7 @@ import type { RestrictiveStringRecord } from "../../../util/index.js";
|
|
|
28
28
|
* Therefore code assigning to these fields must explicitly construct nodes using the schema's constructor or create method,
|
|
29
29
|
* or using some other method like {@link (TreeAlpha:interface).create}.
|
|
30
30
|
*
|
|
31
|
-
* @
|
|
31
|
+
* @beta
|
|
32
32
|
*/
|
|
33
33
|
export interface TreeRecordNode<
|
|
34
34
|
TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes,
|
|
@@ -44,7 +44,7 @@ export interface TreeRecordNode<
|
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Content which can be used to construct a Record node, explicitly or implicitly.
|
|
47
|
-
* @system @
|
|
47
|
+
* @system @beta
|
|
48
48
|
*/
|
|
49
49
|
export type RecordNodeInsertableData<T extends ImplicitAllowedTypes> = RestrictiveStringRecord<
|
|
50
50
|
InsertableTreeNodeFromImplicitAllowedTypes<T>
|
package/src/util/brand.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { Covariant } from "./typeCheck.js";
|
|
|
17
17
|
* mismatched branded types will be:
|
|
18
18
|
* `Type 'Name1' is not assignable to type 'Name2'.`
|
|
19
19
|
*
|
|
20
|
-
* These branded types are not opaque: A `Brand<A, B>` can still be used as a `
|
|
20
|
+
* These branded types are not opaque: A `Brand<A, B>` can still be used as a `A`.
|
|
21
21
|
*/
|
|
22
22
|
export type Brand<ValueType, Name> = ValueType & BrandedType<ValueType, Name>;
|
|
23
23
|
|