@fluidframework/tree 2.71.0 → 2.72.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/CHANGELOG.md +26 -40
- package/api-report/tree.alpha.api.md +27 -18
- package/api-report/tree.beta.api.md +42 -0
- package/api-report/tree.legacy.beta.api.md +42 -0
- package/dist/alpha.d.ts +9 -7
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/beta.d.ts +7 -0
- package/dist/codec/codec.d.ts +16 -1
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +16 -3
- package/dist/codec/codec.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -2
- 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 +2 -2
- package/dist/core/schema-stored/index.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +6 -6
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +6 -7
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV1.js +3 -2
- package/dist/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js +3 -1
- package/dist/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
- package/dist/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexCodecs.js +29 -8
- package/dist/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.js +8 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
- package/dist/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatV1.js +3 -3
- package/dist/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
- package/dist/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatV2.js +3 -3
- package/dist/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
- package/dist/core/tree/index.d.ts +2 -1
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js.map +1 -1
- package/dist/external-utilities/typeboxValidator.js +1 -1
- package/dist/external-utilities/typeboxValidator.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +12 -8
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +9 -4
- 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 +1 -2
- package/dist/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.js +1 -1
- package/dist/feature-libraries/chunked-forest/codec/uncompressedEncode.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 +1 -2
- package/dist/feature-libraries/chunked-forest/index.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +1 -9
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +3 -21
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +4 -5
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +15 -4
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/format.d.ts +8 -1
- package/dist/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/format.js +8 -3
- package/dist/feature-libraries/forest-summary/format.js.map +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts +2 -1
- 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 +3 -3
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +2 -2
- package/dist/feature-libraries/index.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.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +5 -4
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts +10 -10
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +22 -18
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.d.ts +2 -2
- package/dist/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.js +1 -1
- package/dist/feature-libraries/schema-index/formatV1.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -2
- package/dist/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/formatV2.js +1 -1
- package/dist/feature-libraries/schema-index/formatV2.js.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +7 -0
- 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 +1 -1
- package/dist/shared-tree/independentView.d.ts.map +1 -1
- package/dist/shared-tree/independentView.js +22 -15
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +12 -16
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +87 -127
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
- package/dist/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +12 -11
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
- package/dist/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts +1 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +4 -2
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +1 -3
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts +19 -6
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +35 -17
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +43 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.js +4 -4
- package/dist/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV5.d.ts +2 -2
- package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV5.js +1 -1
- package/dist/shared-tree-core/editManagerFormatV5.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +5 -3
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +11 -3
- package/dist/shared-tree-core/index.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/dist/shared-tree-core/messageCodecV5.d.ts +2 -1
- package/dist/shared-tree-core/messageCodecV5.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecV5.js.map +1 -1
- package/dist/shared-tree-core/messageCodecs.d.ts +19 -6
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +38 -21
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +50 -0
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -0
- package/dist/shared-tree-core/messageFormat.js +51 -0
- package/dist/shared-tree-core/messageFormat.js.map +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts +8 -8
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +3 -3
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts +2 -2
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
- package/dist/simple-tree/api/incrementalAllowedTypes.js +1 -1
- package/dist/simple-tree/api/incrementalAllowedTypes.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 +4 -1
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js +1 -52
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
- package/dist/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryBeta.js +61 -7
- package/dist/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +6 -3
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
- package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
- package/dist/simple-tree/api/simpleSchemaCodec.js +292 -0
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -0
- package/dist/simple-tree/api/storedSchema.d.ts +2 -2
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +8 -6
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +2 -2
- package/dist/simple-tree/api/tree.js.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.d.ts +6 -6
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +18 -3
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +78 -35
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +3 -3
- package/dist/simple-tree/core/allowedTypes.js +1 -1
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/treeNode.js +1 -1
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +4 -0
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNode.js +2 -2
- package/dist/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js +2 -2
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +11 -3
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
- package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
- package/dist/simple-tree/simpleSchemaFormatV1.js +115 -0
- package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -0
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +1 -1
- package/dist/tableSchema.js.map +1 -1
- package/dist/treeFactory.d.ts +3 -1
- package/dist/treeFactory.d.ts.map +1 -1
- package/dist/treeFactory.js +26 -2
- package/dist/treeFactory.js.map +1 -1
- package/dist/util/brand.d.ts +31 -2
- package/dist/util/brand.d.ts.map +1 -1
- package/dist/util/brand.js +28 -2
- package/dist/util/brand.js.map +1 -1
- package/dist/util/brandedMap.d.ts +3 -1
- package/dist/util/brandedMap.d.ts.map +1 -1
- package/dist/util/brandedMap.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +3 -2
- package/dist/util/index.js.map +1 -1
- package/lib/alpha.d.ts +9 -7
- package/lib/api.js +2 -2
- package/lib/api.js.map +1 -1
- package/lib/beta.d.ts +7 -0
- package/lib/codec/codec.d.ts +16 -1
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +16 -3
- package/lib/codec/codec.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +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 +1 -1
- package/lib/core/schema-stored/index.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +6 -6
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +6 -7
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts +2 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecCommon.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV1.js +3 -2
- package/lib/core/tree/detachedFieldIndexCodecV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecV2.js +4 -2
- package/lib/core/tree/detachedFieldIndexCodecV2.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts +2 -3
- package/lib/core/tree/detachedFieldIndexCodecs.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexCodecs.js +29 -8
- package/lib/core/tree/detachedFieldIndexCodecs.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +10 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.js +7 -0
- package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatV1.d.ts +2 -2
- package/lib/core/tree/detachedFieldIndexFormatV1.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatV1.js +3 -3
- package/lib/core/tree/detachedFieldIndexFormatV1.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatV2.d.ts +2 -2
- package/lib/core/tree/detachedFieldIndexFormatV2.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatV2.js +3 -3
- package/lib/core/tree/detachedFieldIndexFormatV2.js.map +1 -1
- package/lib/core/tree/index.d.ts +2 -1
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +1 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/external-utilities/typeboxValidator.js +1 -1
- package/lib/external-utilities/typeboxValidator.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts +4 -10
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +13 -8
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/compressedEncode.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts +8 -3
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +8 -3
- 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 +2 -2
- package/lib/feature-libraries/chunked-forest/codec/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.js +2 -2
- package/lib/feature-libraries/chunked-forest/codec/uncompressedEncode.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 +1 -9
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +2 -20
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +4 -5
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +16 -5
- package/lib/feature-libraries/forest-summary/codec.js.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/forest-summary/format.d.ts +8 -1
- package/lib/feature-libraries/forest-summary/format.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/format.js +7 -2
- package/lib/feature-libraries/forest-summary/format.js.map +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts +2 -1
- 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 +3 -3
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +2 -2
- package/lib/feature-libraries/index.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.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts +6 -7
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +6 -5
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts +10 -10
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +24 -20
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.d.ts +2 -2
- package/lib/feature-libraries/schema-index/formatV1.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.js +2 -2
- package/lib/feature-libraries/schema-index/formatV1.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -2
- package/lib/feature-libraries/schema-index/formatV2.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/formatV2.js +2 -2
- package/lib/feature-libraries/schema-index/formatV2.js.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +2 -2
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.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/legacy.d.ts +7 -0
- 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 +1 -1
- package/lib/shared-tree/independentView.d.ts.map +1 -1
- package/lib/shared-tree/independentView.js +11 -4
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +12 -16
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +90 -130
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts +7 -6
- package/lib/shared-tree/sharedTreeChangeCodecs.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +7 -6
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts +2 -2
- package/lib/shared-tree/sharedTreeChangeFamily.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeFamily.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts +1 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +5 -3
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +1 -3
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts +19 -6
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +32 -16
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +37 -0
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +42 -0
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +2 -2
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.js +5 -5
- package/lib/shared-tree-core/editManagerFormatV1toV4.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV5.d.ts +2 -2
- package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV5.js +2 -2
- package/lib/shared-tree-core/editManagerFormatV5.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +5 -3
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +4 -2
- package/lib/shared-tree-core/index.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts +2 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV1ToV4.js.map +1 -1
- package/lib/shared-tree-core/messageCodecV5.d.ts +2 -1
- package/lib/shared-tree-core/messageCodecV5.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecV5.js.map +1 -1
- package/lib/shared-tree-core/messageCodecs.d.ts +19 -6
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +35 -20
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +50 -0
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -0
- package/lib/shared-tree-core/messageFormat.js +48 -0
- package/lib/shared-tree-core/messageFormat.js.map +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts +8 -8
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +3 -3
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts +2 -2
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.js +1 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +3 -2
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +1 -0
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +2 -98
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js +1 -52
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts +98 -2
- package/lib/simple-tree/api/schemaFactoryBeta.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryBeta.js +58 -4
- package/lib/simple-tree/api/schemaFactoryBeta.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +6 -3
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaCodec.d.ts +28 -0
- package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -0
- package/lib/simple-tree/api/simpleSchemaCodec.js +264 -0
- package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -0
- package/lib/simple-tree/api/storedSchema.d.ts +2 -2
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +5 -3
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +2 -2
- package/lib/simple-tree/api/tree.js.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.d.ts +6 -6
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +18 -3
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +75 -34
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +3 -3
- package/lib/simple-tree/core/allowedTypes.js +1 -1
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/treeNode.js +1 -1
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +1 -0
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js +2 -2
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js +2 -2
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNode.js +3 -3
- package/lib/simple-tree/node-kinds/object/objectNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js +3 -3
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +11 -3
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.d.ts +249 -0
- package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -0
- package/lib/simple-tree/simpleSchemaFormatV1.js +112 -0
- package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -0
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +1 -1
- package/lib/tableSchema.js.map +1 -1
- package/lib/treeFactory.d.ts +3 -1
- package/lib/treeFactory.d.ts.map +1 -1
- package/lib/treeFactory.js +23 -1
- package/lib/treeFactory.js.map +1 -1
- package/lib/util/brand.d.ts +31 -2
- package/lib/util/brand.d.ts.map +1 -1
- package/lib/util/brand.js +26 -1
- package/lib/util/brand.js.map +1 -1
- package/lib/util/brandedMap.d.ts +3 -1
- package/lib/util/brandedMap.d.ts.map +1 -1
- package/lib/util/brandedMap.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/package.json +24 -24
- package/src/api.ts +2 -2
- package/src/codec/codec.ts +17 -3
- package/src/core/index.ts +1 -2
- package/src/core/schema-stored/index.ts +1 -2
- package/src/core/schema-stored/schema.ts +10 -7
- package/src/core/tree/detachedFieldIndexCodecCommon.ts +2 -1
- package/src/core/tree/detachedFieldIndexCodecV1.ts +4 -2
- package/src/core/tree/detachedFieldIndexCodecV2.ts +4 -6
- package/src/core/tree/detachedFieldIndexCodecs.ts +33 -11
- package/src/core/tree/detachedFieldIndexFormatCommon.ts +17 -2
- package/src/core/tree/detachedFieldIndexFormatV1.ts +6 -4
- package/src/core/tree/detachedFieldIndexFormatV2.ts +6 -4
- package/src/core/tree/index.ts +2 -4
- package/src/external-utilities/typeboxValidator.ts +1 -1
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +18 -13
- package/src/feature-libraries/chunked-forest/codec/compressedEncode.ts +2 -2
- package/src/feature-libraries/chunked-forest/codec/format.ts +15 -4
- package/src/feature-libraries/chunked-forest/codec/index.ts +4 -2
- package/src/feature-libraries/chunked-forest/codec/uncompressedEncode.ts +2 -2
- package/src/feature-libraries/chunked-forest/index.ts +0 -1
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +2 -29
- package/src/feature-libraries/forest-summary/codec.ts +24 -9
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +1 -1
- package/src/feature-libraries/forest-summary/format.ts +12 -2
- package/src/feature-libraries/forest-summary/index.ts +2 -1
- package/src/feature-libraries/index.ts +1 -2
- package/src/feature-libraries/schema-edits/index.ts +0 -1
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +16 -16
- package/src/feature-libraries/schema-index/codec.ts +34 -22
- package/src/feature-libraries/schema-index/formatV1.ts +2 -2
- package/src/feature-libraries/schema-index/formatV2.ts +2 -2
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +2 -1
- package/src/index.ts +3 -1
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +16 -5
- package/src/shared-tree/sharedTree.ts +112 -172
- package/src/shared-tree/sharedTreeChangeCodecs.ts +15 -9
- package/src/shared-tree/sharedTreeChangeFamily.ts +2 -2
- package/src/shared-tree/treeAlpha.ts +6 -5
- package/src/shared-tree/treeCheckout.ts +1 -3
- package/src/shared-tree-core/editManagerCodecs.ts +56 -19
- package/src/shared-tree-core/editManagerFormatCommons.ts +47 -0
- package/src/shared-tree-core/editManagerFormatV1toV4.ts +10 -5
- package/src/shared-tree-core/editManagerFormatV5.ts +3 -3
- package/src/shared-tree-core/index.ts +11 -5
- package/src/shared-tree-core/messageCodecV1ToV4.ts +6 -1
- package/src/shared-tree-core/messageCodecV5.ts +2 -1
- package/src/shared-tree-core/messageCodecs.ts +60 -26
- package/src/shared-tree-core/messageFormat.ts +56 -0
- package/src/shared-tree-core/sharedTreeCore.ts +11 -13
- package/src/simple-tree/api/discrepancies.ts +2 -2
- package/src/simple-tree/api/incrementalAllowedTypes.ts +1 -1
- package/src/simple-tree/api/index.ts +6 -2
- package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -168
- package/src/simple-tree/api/schemaFactoryBeta.ts +180 -14
- package/src/simple-tree/api/schemaFromSimple.ts +6 -3
- package/src/simple-tree/api/simpleSchemaCodec.ts +360 -0
- package/src/simple-tree/api/storedSchema.ts +8 -5
- package/src/simple-tree/api/tree.ts +2 -2
- package/src/simple-tree/api/typesUnsafe.ts +6 -6
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +80 -47
- package/src/simple-tree/core/allowedTypes.ts +3 -3
- package/src/simple-tree/core/treeNode.ts +2 -2
- package/src/simple-tree/index.ts +5 -1
- package/src/simple-tree/node-kinds/array/arrayNode.ts +2 -2
- package/src/simple-tree/node-kinds/map/mapNode.ts +2 -2
- package/src/simple-tree/node-kinds/object/objectNode.ts +3 -3
- package/src/simple-tree/node-kinds/record/recordNode.ts +3 -3
- package/src/simple-tree/simpleSchema.ts +12 -3
- package/src/simple-tree/simpleSchemaFormatV1.ts +179 -0
- package/src/tableSchema.ts +5 -2
- package/src/treeFactory.ts +33 -1
- package/src/util/brand.ts +40 -2
- package/src/util/brandedMap.ts +3 -1
- package/src/util/index.ts +1 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { objectToMap, type JsonCompatibleReadOnly } from "../../util/index.js";
|
|
7
|
+
import { unreachableCase, transformMapValues } from "@fluidframework/core-utils/internal";
|
|
8
|
+
import type {
|
|
9
|
+
SimpleAllowedTypeAttributes,
|
|
10
|
+
SimpleArrayNodeSchema,
|
|
11
|
+
SimpleFieldSchema,
|
|
12
|
+
SimpleLeafNodeSchema,
|
|
13
|
+
SimpleMapNodeSchema,
|
|
14
|
+
SimpleNodeSchema,
|
|
15
|
+
SimpleObjectFieldSchema,
|
|
16
|
+
SimpleObjectNodeSchema,
|
|
17
|
+
SimpleRecordNodeSchema,
|
|
18
|
+
SimpleTreeSchema,
|
|
19
|
+
} from "../simpleSchema.js";
|
|
20
|
+
import { NodeKind } from "../core/index.js";
|
|
21
|
+
import type { FieldKind } from "../fieldSchema.js";
|
|
22
|
+
import type { ValueSchema } from "../../core/index.js";
|
|
23
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
24
|
+
import * as Format from "../simpleSchemaFormatV1.js";
|
|
25
|
+
import {
|
|
26
|
+
DiscriminatedUnionDispatcher,
|
|
27
|
+
extractJsonValidator,
|
|
28
|
+
FormatValidatorNoOp,
|
|
29
|
+
type FormatValidator,
|
|
30
|
+
} from "../../codec/index.js";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Encodes a simple schema (view or stored) into a serializable format.
|
|
34
|
+
* @remarks The JSON-compatible schema returned from this method is only intended for use in snapshots/comparisons of schemas.
|
|
35
|
+
* It is not possible to reconstruct a full schema (including metadata and persistedMetadata) from the encoded format.
|
|
36
|
+
* @param treeSchema - The tree schema to convert.
|
|
37
|
+
* @returns A serializable representation of the schema.
|
|
38
|
+
*
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
export function encodeSimpleSchema(simpleSchema: SimpleTreeSchema): JsonCompatibleReadOnly {
|
|
42
|
+
// Convert types to serializable forms
|
|
43
|
+
const encodedDefinitions: Format.SimpleSchemaDefinitionsFormat = {};
|
|
44
|
+
|
|
45
|
+
for (const [identifier, schema] of simpleSchema.definitions) {
|
|
46
|
+
const encodedDefinition = encodeNodeSchema(schema);
|
|
47
|
+
encodedDefinitions[identifier] = encodedDefinition;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const encodedSchema: Format.SimpleTreeSchemaFormat = {
|
|
51
|
+
version: Format.SimpleSchemaFormatVersion.v1,
|
|
52
|
+
root: encodeField(simpleSchema.root),
|
|
53
|
+
definitions: encodedDefinitions,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return encodedSchema;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Decodes a JSON-compatible schema into a simple schema.
|
|
61
|
+
* @param encodedSchema - The encoded schema to decode.
|
|
62
|
+
* @param validator - The format validator to use to validate the encoded schema.
|
|
63
|
+
* @returns A decoded simple schema.
|
|
64
|
+
* @throws Will throw a usage error if the encoded schema is not in the expected format.
|
|
65
|
+
*
|
|
66
|
+
* @alpha
|
|
67
|
+
*/
|
|
68
|
+
export function decodeSimpleSchema(
|
|
69
|
+
encodedSchema: JsonCompatibleReadOnly,
|
|
70
|
+
validator?: FormatValidator,
|
|
71
|
+
): SimpleTreeSchema {
|
|
72
|
+
const effectiveValidator = validator ?? FormatValidatorNoOp;
|
|
73
|
+
const compiledValidator = extractJsonValidator(effectiveValidator).compile(
|
|
74
|
+
Format.SimpleTreeSchemaFormat,
|
|
75
|
+
);
|
|
76
|
+
if (!compiledValidator.check(encodedSchema)) {
|
|
77
|
+
throw new UsageError(
|
|
78
|
+
"The provided simple schema is not valid according to the schema format.",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
root: decodeSimpleFieldSchema(encodedSchema.root),
|
|
84
|
+
definitions: new Map(
|
|
85
|
+
transformMapValues(objectToMap(encodedSchema.definitions), (value, key) => {
|
|
86
|
+
return decodeNodeSchema(value);
|
|
87
|
+
}),
|
|
88
|
+
),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Encodes a node schema to a serializable object.
|
|
94
|
+
* @param schema - The node schema to convert.
|
|
95
|
+
* @returns A serializable representation of the node schema.
|
|
96
|
+
*/
|
|
97
|
+
function encodeNodeSchema(schema: SimpleNodeSchema): Format.SimpleNodeSchemaUnionFormat {
|
|
98
|
+
const kind = schema.kind;
|
|
99
|
+
switch (kind) {
|
|
100
|
+
case NodeKind.Leaf:
|
|
101
|
+
return { leaf: encodeLeafNode(schema) };
|
|
102
|
+
case NodeKind.Array:
|
|
103
|
+
return { array: encodeContainerNode(schema) };
|
|
104
|
+
case NodeKind.Map:
|
|
105
|
+
return { map: encodeContainerNode(schema) };
|
|
106
|
+
case NodeKind.Record:
|
|
107
|
+
return { record: encodeContainerNode(schema) };
|
|
108
|
+
case NodeKind.Object:
|
|
109
|
+
return { object: encodeObjectNode(schema) };
|
|
110
|
+
default: {
|
|
111
|
+
unreachableCase(kind);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Encodes a leaf node schema to a serializable object.
|
|
118
|
+
* @param schema - The leaf node schema to convert.
|
|
119
|
+
* @returns A serializable representation of the leaf node schema.
|
|
120
|
+
*/
|
|
121
|
+
function encodeLeafNode(schema: SimpleLeafNodeSchema): Format.SimpleLeafNodeSchemaFormat {
|
|
122
|
+
return {
|
|
123
|
+
kind: schema.kind,
|
|
124
|
+
leafKind: schema.leafKind,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Encodes a container node schema (a simple schema that is a Map, Array, or Record) to a serializable object.
|
|
130
|
+
* @param schema - The container node schema to convert.
|
|
131
|
+
* @returns A serializable representation of the container node schema. Includes the `kind` for disambiguation between different
|
|
132
|
+
* container kinds.
|
|
133
|
+
*/
|
|
134
|
+
function encodeContainerNode(
|
|
135
|
+
schema: SimpleArrayNodeSchema | SimpleMapNodeSchema | SimpleRecordNodeSchema,
|
|
136
|
+
):
|
|
137
|
+
| Format.SimpleArrayNodeSchemaFormat
|
|
138
|
+
| Format.SimpleMapNodeSchemaFormat
|
|
139
|
+
| Format.SimpleRecordNodeSchemaFormat {
|
|
140
|
+
return {
|
|
141
|
+
kind: schema.kind,
|
|
142
|
+
simpleAllowedTypes: encodeSimpleAllowedTypes(schema.simpleAllowedTypes),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Encodes a simple allowed types map to a serializable object. Needed because JSON serialization does not support Maps.
|
|
148
|
+
* @param simpleAllowedTypes - The simple allowed types map to convert.
|
|
149
|
+
* @returns A serializable representation of the simple allowed types.
|
|
150
|
+
*/
|
|
151
|
+
function encodeSimpleAllowedTypes(
|
|
152
|
+
simpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>,
|
|
153
|
+
): Format.SimpleAllowedTypesFormat {
|
|
154
|
+
const encodedAllowedTypes: Format.SimpleAllowedTypesFormat = {};
|
|
155
|
+
for (const [identifier, attributes] of simpleAllowedTypes) {
|
|
156
|
+
encodedAllowedTypes[identifier] = {
|
|
157
|
+
isStaged: attributes.isStaged,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return encodedAllowedTypes;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Encodes an object node schema to a serializable object.
|
|
165
|
+
* @param schema - The object node schema to convert.
|
|
166
|
+
* @returns A serializable representation of the object node schema.
|
|
167
|
+
*/
|
|
168
|
+
function encodeObjectNode(
|
|
169
|
+
schema: SimpleObjectNodeSchema,
|
|
170
|
+
): Format.SimpleObjectNodeSchemaFormat {
|
|
171
|
+
const encodedFields: Format.SimpleObjectFieldSchemasFormat = {};
|
|
172
|
+
for (const [fieldKey, fieldSchema] of schema.fields) {
|
|
173
|
+
encodedFields[fieldKey] = encodeObjectField(fieldSchema);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
kind: schema.kind,
|
|
178
|
+
fields: encodedFields,
|
|
179
|
+
allowUnknownOptionalFields: schema.allowUnknownOptionalFields,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Encodes an object field schema to a serializable object.
|
|
185
|
+
* @param fieldSchema - The object field schema to convert.
|
|
186
|
+
* @returns A serializable representation of the object field schema.
|
|
187
|
+
*/
|
|
188
|
+
function encodeObjectField(
|
|
189
|
+
fieldSchema: SimpleObjectFieldSchema,
|
|
190
|
+
): Format.SimpleObjectFieldSchemaFormat {
|
|
191
|
+
const encodedField = encodeField(fieldSchema);
|
|
192
|
+
return { ...encodedField, storedKey: fieldSchema.storedKey };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Encodes a field schema to a serializable object.
|
|
197
|
+
* @param fieldSchema - The field schema to convert.
|
|
198
|
+
* @returns A serializable representation of the field schema.
|
|
199
|
+
*/
|
|
200
|
+
function encodeField(fieldSchema: SimpleFieldSchema): Format.SimpleFieldSchemaFormat {
|
|
201
|
+
return {
|
|
202
|
+
kind: fieldSchema.kind,
|
|
203
|
+
simpleAllowedTypes: encodeSimpleAllowedTypes(fieldSchema.simpleAllowedTypes),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const decodeNodeSchemaDispatcher: DiscriminatedUnionDispatcher<
|
|
208
|
+
Format.SimpleNodeSchemaUnionFormat,
|
|
209
|
+
[],
|
|
210
|
+
| SimpleLeafNodeSchema
|
|
211
|
+
| SimpleArrayNodeSchema
|
|
212
|
+
| SimpleMapNodeSchema
|
|
213
|
+
| SimpleRecordNodeSchema
|
|
214
|
+
| SimpleObjectNodeSchema
|
|
215
|
+
> = new DiscriminatedUnionDispatcher({
|
|
216
|
+
leaf: decodeLeafNode,
|
|
217
|
+
array: decodeContainerNode,
|
|
218
|
+
map: decodeContainerNode,
|
|
219
|
+
record: decodeContainerNode,
|
|
220
|
+
object: decodeObjectNode,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Decodes a node schema from a JSON-compatible object.
|
|
225
|
+
* @param encodedNodeSchema - The encoded node schema to decode.
|
|
226
|
+
* @returns The decoded node schema.
|
|
227
|
+
*/
|
|
228
|
+
function decodeNodeSchema(
|
|
229
|
+
encodedNodeSchema: Format.SimpleNodeSchemaUnionFormat,
|
|
230
|
+
):
|
|
231
|
+
| SimpleLeafNodeSchema
|
|
232
|
+
| SimpleArrayNodeSchema
|
|
233
|
+
| SimpleMapNodeSchema
|
|
234
|
+
| SimpleRecordNodeSchema
|
|
235
|
+
| SimpleObjectNodeSchema {
|
|
236
|
+
return decodeNodeSchemaDispatcher.dispatch(encodedNodeSchema);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Decodes a container node schema (array, map, record) from a JSON-compatible object.
|
|
241
|
+
* @param encodedContainerSchema - The encoded schema to decode.
|
|
242
|
+
* @returns The decoded container node schema.
|
|
243
|
+
*/
|
|
244
|
+
function decodeContainerNode(
|
|
245
|
+
encodedContainerSchema:
|
|
246
|
+
| Format.SimpleArrayNodeSchemaFormat
|
|
247
|
+
| Format.SimpleMapNodeSchemaFormat
|
|
248
|
+
| Format.SimpleRecordNodeSchemaFormat,
|
|
249
|
+
): SimpleArrayNodeSchema | SimpleMapNodeSchema | SimpleRecordNodeSchema {
|
|
250
|
+
return {
|
|
251
|
+
kind: encodedContainerSchema.kind as NodeKind.Array | NodeKind.Map | NodeKind.Record,
|
|
252
|
+
simpleAllowedTypes: decodeSimpleAllowedTypes(encodedContainerSchema.simpleAllowedTypes),
|
|
253
|
+
// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values.
|
|
254
|
+
persistedMetadata: undefined,
|
|
255
|
+
metadata: {},
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Decodes a leaf node schema from a JSON-compatible object.
|
|
261
|
+
* @param encodedLeafSchema - The encoded leaf node schema.
|
|
262
|
+
* @returns The decoded leaf node schema.
|
|
263
|
+
*/
|
|
264
|
+
function decodeLeafNode(
|
|
265
|
+
encodedLeafSchema: Format.SimpleLeafNodeSchemaFormat,
|
|
266
|
+
): SimpleLeafNodeSchema {
|
|
267
|
+
return {
|
|
268
|
+
kind: NodeKind.Leaf,
|
|
269
|
+
leafKind: encodedLeafSchema.leafKind as ValueSchema,
|
|
270
|
+
// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values.
|
|
271
|
+
persistedMetadata: undefined,
|
|
272
|
+
metadata: {},
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Decodes a object node schema from a JSON-compatible object.
|
|
278
|
+
* @param encodedObjectSchema - The encoded object node schema.
|
|
279
|
+
* @returns The decoded object node schema.
|
|
280
|
+
*/
|
|
281
|
+
function decodeObjectNode(
|
|
282
|
+
encodedObjectSchema: Format.SimpleObjectNodeSchemaFormat,
|
|
283
|
+
): SimpleObjectNodeSchema {
|
|
284
|
+
return {
|
|
285
|
+
kind: NodeKind.Object,
|
|
286
|
+
fields: decodeObjectFields(encodedObjectSchema.fields),
|
|
287
|
+
// It is possible for allowUnknownOptionalFields to be undefined. This happens when serializing a Simple Schema derived
|
|
288
|
+
// from a stored schema.
|
|
289
|
+
allowUnknownOptionalFields: encodedObjectSchema.allowUnknownOptionalFields,
|
|
290
|
+
// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values when decoding.
|
|
291
|
+
persistedMetadata: undefined,
|
|
292
|
+
metadata: {},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Decodes a map of object fields from a JSON-compatible object.
|
|
298
|
+
* @param encodedFields - The encoded fields.
|
|
299
|
+
* @returns A map of the decoded object fields.
|
|
300
|
+
*/
|
|
301
|
+
function decodeObjectFields(
|
|
302
|
+
encodedFields: Format.SimpleObjectFieldSchemasFormat,
|
|
303
|
+
): ReadonlyMap<string, SimpleObjectFieldSchema> {
|
|
304
|
+
const fields = new Map<string, SimpleObjectFieldSchema>();
|
|
305
|
+
for (const [fieldKey, fieldSchema] of Object.entries(encodedFields)) {
|
|
306
|
+
fields.set(fieldKey, decodeObjectField(fieldSchema));
|
|
307
|
+
}
|
|
308
|
+
return fields;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Decodes a {@link SimpleObjectFieldSchema} from a JSON-compatible object.
|
|
313
|
+
* @param encodedField - The encoded field schema.
|
|
314
|
+
* @returns The decoded simple object field schema.
|
|
315
|
+
*/
|
|
316
|
+
function decodeObjectField(
|
|
317
|
+
encodedField: Format.SimpleObjectFieldSchemaFormat,
|
|
318
|
+
): SimpleObjectFieldSchema {
|
|
319
|
+
const baseField = decodeSimpleFieldSchema(encodedField);
|
|
320
|
+
return {
|
|
321
|
+
...baseField,
|
|
322
|
+
storedKey: encodedField.storedKey,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Decodes a {@link SimpleFieldSchema} from a JSON-compatible object.
|
|
328
|
+
* @param encodedField - The encoded field schema.
|
|
329
|
+
* @returns The decoded simple field schema.
|
|
330
|
+
*/
|
|
331
|
+
function decodeSimpleFieldSchema(
|
|
332
|
+
encodedField: Format.SimpleFieldSchemaFormat,
|
|
333
|
+
): SimpleFieldSchema {
|
|
334
|
+
return {
|
|
335
|
+
kind: encodedField.kind as FieldKind,
|
|
336
|
+
simpleAllowedTypes: decodeSimpleAllowedTypes(encodedField.simpleAllowedTypes),
|
|
337
|
+
// We cannot encode persistedMetadata or metadata, so we explicitly set them to empty values when decoding.
|
|
338
|
+
persistedMetadata: undefined,
|
|
339
|
+
metadata: {},
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Decodes a simple allowed types map from a JSON-compatible object.
|
|
345
|
+
* @param encodedAllowedTypes - The encoded simple allowed types.
|
|
346
|
+
* @returns A map of the decoded simple allowed types.
|
|
347
|
+
*/
|
|
348
|
+
function decodeSimpleAllowedTypes(
|
|
349
|
+
encodedAllowedTypes: Format.SimpleAllowedTypesFormat,
|
|
350
|
+
): ReadonlyMap<string, SimpleAllowedTypeAttributes> {
|
|
351
|
+
const untypedMap = objectToMap(encodedAllowedTypes);
|
|
352
|
+
|
|
353
|
+
const simpleAllowedTypes = transformMapValues(untypedMap, (value) => {
|
|
354
|
+
return {
|
|
355
|
+
isStaged: value.isStaged,
|
|
356
|
+
} satisfies SimpleAllowedTypeAttributes;
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
return simpleAllowedTypes;
|
|
360
|
+
}
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
|
|
7
|
-
import type
|
|
8
|
-
import {
|
|
7
|
+
import { FluidClientVersion, type ICodecOptions } from "../../codec/index.js";
|
|
8
|
+
import { SchemaFormatVersion } from "../../core/index.js";
|
|
9
9
|
import { encodeTreeSchema, makeSchemaCodec } from "../../feature-libraries/index.js";
|
|
10
10
|
import {
|
|
11
11
|
clientVersionToSchemaVersion,
|
|
12
12
|
type FormatV1,
|
|
13
|
-
// eslint-disable-next-line import/no-internal-modules
|
|
13
|
+
// eslint-disable-next-line import-x/no-internal-modules
|
|
14
14
|
} from "../../feature-libraries/schema-index/index.js";
|
|
15
|
-
import type
|
|
15
|
+
import { brand, type JsonCompatible } from "../../util/index.js";
|
|
16
16
|
import type { SchemaUpgrade } from "../core/index.js";
|
|
17
17
|
import { normalizeFieldSchema, type ImplicitFieldSchema } from "../fieldSchema.js";
|
|
18
18
|
import { toStoredSchema } from "../toStoredSchema.js";
|
|
@@ -100,7 +100,10 @@ export function comparePersistedSchema(
|
|
|
100
100
|
): Omit<SchemaCompatibilityStatus, "canInitialize"> {
|
|
101
101
|
// Any version can be passed down to makeSchemaCodec here.
|
|
102
102
|
// We only use the decode part, which always dispatches to the correct codec based on the version in the data, not the version passed to `makeSchemaCodec`.
|
|
103
|
-
const schemaCodec = makeSchemaCodec(
|
|
103
|
+
const schemaCodec = makeSchemaCodec(
|
|
104
|
+
{ ...options, minVersionForCollab: FluidClientVersion.v2_0 },
|
|
105
|
+
brand(SchemaFormatVersion.v1),
|
|
106
|
+
);
|
|
104
107
|
const stored = schemaCodec.decode(persisted as FormatV1);
|
|
105
108
|
const config = new TreeViewConfigurationAlpha({
|
|
106
109
|
schema: normalizeFieldSchema(view),
|
|
@@ -431,7 +431,7 @@ export interface SchemaCompatibilityStatus {
|
|
|
431
431
|
*
|
|
432
432
|
* Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.
|
|
433
433
|
*
|
|
434
|
-
* For the computation of this equivalence, {@link
|
|
434
|
+
* For the computation of this equivalence, {@link SchemaStaticsBeta.staged | staged} schemas are not included.
|
|
435
435
|
* If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.
|
|
436
436
|
*/
|
|
437
437
|
readonly isEquivalent: boolean;
|
|
@@ -445,7 +445,7 @@ export interface SchemaCompatibilityStatus {
|
|
|
445
445
|
*
|
|
446
446
|
* - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.
|
|
447
447
|
*
|
|
448
|
-
* - An additional type allowed at a location in the stored schema where it is {@link
|
|
448
|
+
* - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsBeta.staged | staged} in the view schema.
|
|
449
449
|
*
|
|
450
450
|
* In these cases `canUpgrade` and `isEquivalent` will be false.
|
|
451
451
|
*
|
|
@@ -551,7 +551,7 @@ export interface TreeRecordNodeUnsafe<
|
|
|
551
551
|
* @remarks
|
|
552
552
|
* 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.
|
|
553
553
|
* @sealed
|
|
554
|
-
* @
|
|
554
|
+
* @beta
|
|
555
555
|
* @system
|
|
556
556
|
*/
|
|
557
557
|
export type UnannotateAllowedTypeUnsafe<
|
|
@@ -564,7 +564,7 @@ export type UnannotateAllowedTypeUnsafe<
|
|
|
564
564
|
* {@link Unenforced} version of {@link AnnotatedAllowedType}.
|
|
565
565
|
* @remarks
|
|
566
566
|
* 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.
|
|
567
|
-
* @system @sealed @
|
|
567
|
+
* @system @sealed @beta
|
|
568
568
|
*/
|
|
569
569
|
export interface AnnotatedAllowedTypeUnsafe<T = Unenforced<LazyItem<TreeNodeSchema>>>
|
|
570
570
|
extends AnnotatedAllowedType<T> {}
|
|
@@ -573,7 +573,7 @@ export interface AnnotatedAllowedTypeUnsafe<T = Unenforced<LazyItem<TreeNodeSche
|
|
|
573
573
|
* {@link Unenforced} version of {@link AnnotatedAllowedTypes}.
|
|
574
574
|
* @remarks
|
|
575
575
|
* 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.
|
|
576
|
-
* @system @sealed @
|
|
576
|
+
* @system @sealed @beta
|
|
577
577
|
*/
|
|
578
578
|
export interface AnnotatedAllowedTypesUnsafe
|
|
579
579
|
extends AnnotatedAllowedTypes<LazyItem<System_Unsafe.TreeNodeSchemaUnsafe>> {}
|
|
@@ -592,7 +592,7 @@ export type AllowedTypesFullUnsafe<
|
|
|
592
592
|
* {@link Unenforced} version of {@link AllowedTypesFullFromMixed}.
|
|
593
593
|
* @remarks
|
|
594
594
|
* 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.
|
|
595
|
-
* @system @sealed @
|
|
595
|
+
* @system @sealed @beta
|
|
596
596
|
*/
|
|
597
597
|
export type AllowedTypesFullFromMixedUnsafe<
|
|
598
598
|
T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],
|
|
@@ -603,7 +603,7 @@ export type AllowedTypesFullFromMixedUnsafe<
|
|
|
603
603
|
* {@link Unenforced} version of {@link UnannotateAllowedTypesList}.
|
|
604
604
|
* @remarks
|
|
605
605
|
* 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.
|
|
606
|
-
* @system @sealed @
|
|
606
|
+
* @system @sealed @beta
|
|
607
607
|
*/
|
|
608
608
|
export type UnannotateAllowedTypesListUnsafe<
|
|
609
609
|
T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],
|
|
@@ -615,7 +615,7 @@ export type UnannotateAllowedTypesListUnsafe<
|
|
|
615
615
|
* {@link Unenforced} version of {@link AnnotateAllowedTypesList}.
|
|
616
616
|
* @remarks
|
|
617
617
|
* 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.
|
|
618
|
-
* @system @sealed @
|
|
618
|
+
* @system @sealed @beta
|
|
619
619
|
*/
|
|
620
620
|
export type AnnotateAllowedTypesListUnsafe<
|
|
621
621
|
T extends readonly Unenforced<AnnotatedAllowedType | LazyItem<TreeNodeSchema>>[],
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { normalizeFieldSchema, type ImplicitFieldSchema } from "../fieldSchema.js";
|
|
8
8
|
import type {
|
|
9
|
-
SimpleAllowedTypeAttributes,
|
|
10
9
|
SimpleArrayNodeSchema,
|
|
11
10
|
SimpleFieldSchema,
|
|
12
11
|
SimpleLeafNodeSchema,
|
|
@@ -32,7 +31,6 @@ import { LeafNodeSchema } from "../leafNodeSchema.js";
|
|
|
32
31
|
*
|
|
33
32
|
* @param schema - The schema to convert
|
|
34
33
|
* @param copySchemaObjects - If true, TreeNodeSchema and FieldSchema are copied into plain JavaScript objects. Either way, custom metadata is referenced and not copied.
|
|
35
|
-
* @param isViewSchema - If true (default), properties used by view schema but not part of stored schema (for example, `isStaged` on allowed types) are preserved in the output.
|
|
36
34
|
*
|
|
37
35
|
* @remarks
|
|
38
36
|
* Given that the Schema types used in {@link ImplicitFieldSchema} already implement the {@link SimpleNodeSchema} interfaces, there are limited use-cases for this function.
|
|
@@ -47,7 +45,6 @@ import { LeafNodeSchema } from "../leafNodeSchema.js";
|
|
|
47
45
|
export function toSimpleTreeSchema(
|
|
48
46
|
schema: ImplicitFieldSchema,
|
|
49
47
|
copySchemaObjects: boolean,
|
|
50
|
-
isViewSchema: boolean = true,
|
|
51
48
|
): SimpleTreeSchema {
|
|
52
49
|
const normalizedSchema = normalizeFieldSchema(schema);
|
|
53
50
|
const definitions = new Map<string, SimpleNodeSchema>();
|
|
@@ -62,9 +59,7 @@ export function toSimpleTreeSchema(
|
|
|
62
59
|
nodeSchema instanceof RecordNodeSchema,
|
|
63
60
|
0xb60 /* Invalid schema */,
|
|
64
61
|
);
|
|
65
|
-
const outSchema = copySchemaObjects
|
|
66
|
-
? copySimpleNodeSchema(nodeSchema, isViewSchema)
|
|
67
|
-
: nodeSchema;
|
|
62
|
+
const outSchema = copySchemaObjects ? copySimpleNodeSchema(nodeSchema) : nodeSchema;
|
|
68
63
|
definitions.set(nodeSchema.identifier, outSchema);
|
|
69
64
|
},
|
|
70
65
|
});
|
|
@@ -72,10 +67,7 @@ export function toSimpleTreeSchema(
|
|
|
72
67
|
return {
|
|
73
68
|
root: copySchemaObjects
|
|
74
69
|
? ({
|
|
75
|
-
simpleAllowedTypes:
|
|
76
|
-
normalizedSchema.simpleAllowedTypes,
|
|
77
|
-
isViewSchema,
|
|
78
|
-
),
|
|
70
|
+
simpleAllowedTypes: normalizedSchema.simpleAllowedTypes,
|
|
79
71
|
kind: normalizedSchema.kind,
|
|
80
72
|
metadata: normalizedSchema.metadata,
|
|
81
73
|
persistedMetadata: normalizedSchema.persistedMetadata,
|
|
@@ -85,36 +77,12 @@ export function toSimpleTreeSchema(
|
|
|
85
77
|
};
|
|
86
78
|
}
|
|
87
79
|
|
|
88
|
-
/**
|
|
89
|
-
* Normalizes the {@link SimpleAllowedTypeAttributes} by either preserving or omitting view-specific schema properties.
|
|
90
|
-
* @param simpleAllowedTypes - The simple allowed types to normalize.
|
|
91
|
-
* @param isViewSchema - If true, properties used by view schema but not part of stored schema (for example, `isStaged` on allowed types) are preserved in the output.
|
|
92
|
-
* @returns The normalized simple allowed types.
|
|
93
|
-
*/
|
|
94
|
-
function normalizeSimpleAllowedTypes(
|
|
95
|
-
simpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>,
|
|
96
|
-
isViewSchema: boolean,
|
|
97
|
-
): ReadonlyMap<string, SimpleAllowedTypeAttributes> {
|
|
98
|
-
if (isViewSchema) {
|
|
99
|
-
return simpleAllowedTypes;
|
|
100
|
-
} else {
|
|
101
|
-
const normalized = new Map<string, SimpleAllowedTypeAttributes>();
|
|
102
|
-
for (const [identifier, attributes] of simpleAllowedTypes.entries()) {
|
|
103
|
-
normalized.set(identifier, { ...attributes, isStaged: undefined });
|
|
104
|
-
}
|
|
105
|
-
return normalized;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
80
|
/**
|
|
110
81
|
* Copies a {@link SimpleNodeSchema} into a new plain JavaScript object.
|
|
111
82
|
*
|
|
112
83
|
* @remarks Caches the result on the input schema for future calls.
|
|
113
84
|
*/
|
|
114
|
-
function copySimpleNodeSchema(
|
|
115
|
-
schema: SimpleNodeSchema,
|
|
116
|
-
isViewSchema: boolean,
|
|
117
|
-
): SimpleNodeSchema {
|
|
85
|
+
export function copySimpleNodeSchema(schema: SimpleNodeSchema): SimpleNodeSchema {
|
|
118
86
|
const kind = schema.kind;
|
|
119
87
|
switch (kind) {
|
|
120
88
|
case NodeKind.Leaf:
|
|
@@ -122,9 +90,9 @@ function copySimpleNodeSchema(
|
|
|
122
90
|
case NodeKind.Array:
|
|
123
91
|
case NodeKind.Map:
|
|
124
92
|
case NodeKind.Record:
|
|
125
|
-
return copySimpleSchemaWithAllowedTypes(schema
|
|
93
|
+
return copySimpleSchemaWithAllowedTypes(schema);
|
|
126
94
|
case NodeKind.Object:
|
|
127
|
-
return copySimpleObjectSchema(schema
|
|
95
|
+
return copySimpleObjectSchema(schema);
|
|
128
96
|
default:
|
|
129
97
|
unreachableCase(kind);
|
|
130
98
|
}
|
|
@@ -141,36 +109,101 @@ function copySimpleLeafSchema(schema: SimpleLeafNodeSchema): SimpleLeafNodeSchem
|
|
|
141
109
|
|
|
142
110
|
function copySimpleSchemaWithAllowedTypes(
|
|
143
111
|
schema: SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleRecordNodeSchema,
|
|
144
|
-
isViewSchema: boolean,
|
|
145
112
|
): SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleRecordNodeSchema {
|
|
146
113
|
return {
|
|
147
114
|
kind: schema.kind,
|
|
148
|
-
simpleAllowedTypes:
|
|
115
|
+
simpleAllowedTypes: schema.simpleAllowedTypes,
|
|
149
116
|
metadata: schema.metadata,
|
|
150
117
|
persistedMetadata: schema.persistedMetadata,
|
|
151
118
|
};
|
|
152
119
|
}
|
|
153
120
|
|
|
154
|
-
function copySimpleObjectSchema(
|
|
155
|
-
schema: SimpleObjectNodeSchema,
|
|
156
|
-
isViewSchema: boolean,
|
|
157
|
-
): SimpleObjectNodeSchema {
|
|
121
|
+
function copySimpleObjectSchema(schema: SimpleObjectNodeSchema): SimpleObjectNodeSchema {
|
|
158
122
|
const fields: Map<string, SimpleObjectFieldSchema> = new Map();
|
|
159
123
|
for (const [propertyKey, field] of schema.fields) {
|
|
160
124
|
// field already is a SimpleObjectFieldSchema, but copy the subset of the properties needed by this interface to get a clean simple object.
|
|
161
|
-
|
|
125
|
+
const simpleField = {
|
|
162
126
|
kind: field.kind,
|
|
163
|
-
simpleAllowedTypes:
|
|
127
|
+
simpleAllowedTypes: field.simpleAllowedTypes,
|
|
164
128
|
metadata: field.metadata,
|
|
165
129
|
persistedMetadata: field.persistedMetadata,
|
|
166
130
|
storedKey: field.storedKey,
|
|
167
|
-
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
fields.set(propertyKey, simpleField);
|
|
168
134
|
}
|
|
169
135
|
|
|
170
|
-
|
|
136
|
+
const simpleObject = {
|
|
171
137
|
kind: NodeKind.Object,
|
|
172
138
|
fields,
|
|
173
139
|
metadata: schema.metadata,
|
|
174
140
|
persistedMetadata: schema.persistedMetadata,
|
|
141
|
+
allowUnknownOptionalFields: schema.allowUnknownOptionalFields,
|
|
142
|
+
} satisfies SimpleObjectNodeSchema;
|
|
143
|
+
|
|
144
|
+
return simpleObject;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Creates a copy of a SimpleTreeSchema without metadata fields. This is useful for comparing deserialized view schemas with in-memory schemas.
|
|
149
|
+
* metadata and persistedMetadata are not relevant for schema compatibility checks and are not serialized by the Simple Schema serializer.
|
|
150
|
+
* @see {@link simpleSchemaSerializer.ts} for the serialization logic.
|
|
151
|
+
*
|
|
152
|
+
* @param schema - The SimpleTreeSchema to remove fields from.
|
|
153
|
+
* @param fieldsToRemove - An object specifying which fields to remove.
|
|
154
|
+
* @returns A new SimpleTreeSchema without the specified fields.
|
|
155
|
+
*/
|
|
156
|
+
export function copySimpleTreeSchemaWithoutMetadata(
|
|
157
|
+
schema: SimpleTreeSchema,
|
|
158
|
+
): SimpleTreeSchema {
|
|
159
|
+
const definitions = new Map<string, SimpleNodeSchema>();
|
|
160
|
+
|
|
161
|
+
for (const [identifier, nodeSchema] of schema.definitions.entries()) {
|
|
162
|
+
const kind = nodeSchema.kind;
|
|
163
|
+
switch (kind) {
|
|
164
|
+
case NodeKind.Array:
|
|
165
|
+
case NodeKind.Map:
|
|
166
|
+
case NodeKind.Record:
|
|
167
|
+
case NodeKind.Leaf: {
|
|
168
|
+
const outputNodeSchema = {
|
|
169
|
+
...nodeSchema,
|
|
170
|
+
metadata: {},
|
|
171
|
+
persistedMetadata: undefined,
|
|
172
|
+
};
|
|
173
|
+
definitions.set(identifier, outputNodeSchema);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case NodeKind.Object: {
|
|
177
|
+
const outputFields = new Map<string, SimpleObjectFieldSchema>();
|
|
178
|
+
for (const [propertyKey, fieldSchema] of nodeSchema.fields.entries()) {
|
|
179
|
+
const outputField: SimpleObjectFieldSchema = {
|
|
180
|
+
...fieldSchema,
|
|
181
|
+
metadata: {},
|
|
182
|
+
persistedMetadata: undefined,
|
|
183
|
+
};
|
|
184
|
+
outputFields.set(propertyKey, outputField);
|
|
185
|
+
}
|
|
186
|
+
const outputNodeSchema = {
|
|
187
|
+
...nodeSchema,
|
|
188
|
+
metadata: {},
|
|
189
|
+
persistedMetadata: undefined,
|
|
190
|
+
fields: outputFields,
|
|
191
|
+
};
|
|
192
|
+
definitions.set(identifier, outputNodeSchema);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
default:
|
|
196
|
+
unreachableCase(kind);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
root: {
|
|
202
|
+
kind: schema.root.kind,
|
|
203
|
+
simpleAllowedTypes: schema.root.simpleAllowedTypes,
|
|
204
|
+
metadata: {},
|
|
205
|
+
persistedMetadata: undefined,
|
|
206
|
+
},
|
|
207
|
+
definitions,
|
|
175
208
|
};
|
|
176
209
|
}
|
|
@@ -57,7 +57,7 @@ export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
|
|
57
57
|
/**
|
|
58
58
|
* Stores annotations for an individual allowed type.
|
|
59
59
|
* @remarks
|
|
60
|
-
* Create using APIs on {@link
|
|
60
|
+
* Create using APIs on {@link SchemaStaticsBeta}, like {@link SchemaStaticsBeta.staged}.
|
|
61
61
|
* @privateRemarks
|
|
62
62
|
* Since this is sealed, users are not supposed to create instances of it directly.
|
|
63
63
|
* Making it extend ErasedType could enforce that.
|
|
@@ -412,7 +412,7 @@ export interface AllowedTypeMetadata {
|
|
|
412
412
|
readonly custom?: unknown;
|
|
413
413
|
|
|
414
414
|
/**
|
|
415
|
-
* If defined, indicates that an allowed type is {@link
|
|
415
|
+
* If defined, indicates that an allowed type is {@link SchemaStaticsBeta.staged | staged}.
|
|
416
416
|
*/
|
|
417
417
|
readonly stagedSchemaUpgrade?: SchemaUpgrade;
|
|
418
418
|
}
|
|
@@ -425,7 +425,7 @@ export let createSchemaUpgrade: () => SchemaUpgrade;
|
|
|
425
425
|
/**
|
|
426
426
|
* Unique token used to upgrade schemas and determine if a particular upgrade has been completed.
|
|
427
427
|
* @remarks
|
|
428
|
-
* Create using {@link
|
|
428
|
+
* Create using {@link SchemaStaticsBeta.staged}.
|
|
429
429
|
* @privateRemarks
|
|
430
430
|
* TODO:#38722 implement runtime schema upgrades.
|
|
431
431
|
* Until then, the class purely behaves mostly as a placeholder.
|