@fluidframework/tree 2.74.0-365691 → 2.74.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/.vscode/settings.json +4 -2
- package/CHANGELOG.md +11 -0
- package/api-report/tree.alpha.api.md +125 -87
- package/api-report/tree.beta.api.md +0 -1
- package/api-report/tree.legacy.beta.api.md +0 -1
- package/api-report/tree.legacy.public.api.md +0 -1
- package/api-report/tree.public.api.md +0 -1
- package/assertTagging.config.mjs +1 -1
- package/dist/alpha.d.ts +6 -2
- package/dist/codec/codec.d.ts +41 -13
- package/dist/codec/codec.d.ts.map +1 -1
- package/dist/codec/codec.js +46 -19
- package/dist/codec/codec.js.map +1 -1
- package/dist/codec/versioned/codec.d.ts +1 -1
- package/dist/codec/versioned/codec.d.ts.map +1 -1
- package/dist/codec/versioned/codec.js.map +1 -1
- package/dist/codec/versioned/format.d.ts +4 -1
- package/dist/codec/versioned/format.d.ts.map +1 -1
- package/dist/codec/versioned/format.js +4 -1
- package/dist/codec/versioned/format.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/rebase/index.d.ts +1 -1
- package/dist/core/rebase/index.d.ts.map +1 -1
- package/dist/core/rebase/index.js.map +1 -1
- package/dist/core/rebase/types.d.ts +20 -1
- package/dist/core/rebase/types.d.ts.map +1 -1
- package/dist/core/rebase/types.js.map +1 -1
- package/dist/core/schema-stored/schema.d.ts +4 -7
- package/dist/core/schema-stored/schema.d.ts.map +1 -1
- package/dist/core/schema-stored/schema.js +2 -2
- package/dist/core/schema-stored/schema.js.map +1 -1
- package/dist/core/tree/detachedFieldIndex.d.ts +34 -13
- package/dist/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndex.js +12 -12
- package/dist/core/tree/detachedFieldIndex.js.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts +4 -4
- package/dist/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/dist/core/tree/detachedFieldIndexFormatCommon.js +2 -2
- package/dist/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
- package/dist/core/tree/index.d.ts +3 -2
- package/dist/core/tree/index.d.ts.map +1 -1
- package/dist/core/tree/index.js +3 -0
- package/dist/core/tree/index.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/codecs.js +2 -2
- package/dist/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts +5 -5
- package/dist/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/format.js +4 -4
- package/dist/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +14 -6
- package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -1
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +7 -2
- package/dist/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts +3 -3
- package/dist/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js +22 -26
- package/dist/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts +30 -8
- package/dist/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js +41 -11
- package/dist/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts +7 -1
- package/dist/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/codec.js +13 -11
- package/dist/feature-libraries/forest-summary/codec.js.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts +10 -13
- package/dist/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/forestSummarizer.js +35 -31
- package/dist/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts +61 -0
- package/dist/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/formatCommon.js +27 -0
- package/dist/feature-libraries/forest-summary/formatCommon.js.map +1 -0
- package/dist/feature-libraries/forest-summary/formatV1.d.ts +51 -0
- package/dist/feature-libraries/forest-summary/formatV1.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/formatV1.js +11 -0
- package/dist/feature-libraries/forest-summary/formatV1.js.map +1 -0
- package/dist/feature-libraries/forest-summary/formatV2.d.ts +51 -0
- package/dist/feature-libraries/forest-summary/formatV2.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/formatV2.js +11 -0
- package/dist/feature-libraries/forest-summary/formatV2.js.map +1 -0
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +18 -24
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js +21 -43
- package/dist/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/dist/feature-libraries/forest-summary/index.d.ts +2 -2
- package/dist/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/dist/feature-libraries/forest-summary/index.js +3 -4
- package/dist/feature-libraries/forest-summary/index.js.map +1 -1
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.d.ts +35 -0
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.js +43 -0
- package/dist/feature-libraries/forest-summary/summaryFormatCommon.js.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts +11 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.js +14 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV1ToV2.js.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.d.ts +18 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.js +21 -0
- package/dist/feature-libraries/forest-summary/summaryFormatV3.js.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryTypes.d.ts +17 -0
- package/dist/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -0
- package/dist/feature-libraries/forest-summary/summaryTypes.js +35 -0
- package/dist/feature-libraries/forest-summary/summaryTypes.js.map +1 -0
- package/dist/feature-libraries/index.d.ts +1 -1
- package/dist/feature-libraries/index.d.ts.map +1 -1
- package/dist/feature-libraries/index.js +3 -2
- package/dist/feature-libraries/index.js.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.d.ts +18 -2
- package/dist/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/comparison.js +54 -3
- package/dist/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKind.d.ts +25 -13
- package/dist/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/fieldKind.js +0 -21
- package/dist/feature-libraries/modular-schema/fieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js +4 -1
- package/dist/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts +1 -1
- package/dist/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/dist/feature-libraries/modular-schema/index.js +2 -1
- package/dist/feature-libraries/modular-schema/index.js.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js +2 -3
- package/dist/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/dist/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/codec.js +4 -4
- package/dist/feature-libraries/schema-index/codec.js.map +1 -1
- package/dist/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/dist/feature-libraries/schema-index/formatV2.d.ts +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts +27 -8
- package/dist/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/dist/feature-libraries/schema-index/schemaSummarizer.js +42 -16
- package/dist/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +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 +1 -1
- package/dist/shared-tree/independentView.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts +2 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +3 -0
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/shared-tree/sharedTree.d.ts +2 -2
- package/dist/shared-tree/sharedTree.d.ts.map +1 -1
- package/dist/shared-tree/sharedTree.js +4 -4
- package/dist/shared-tree/sharedTree.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeCodecs.js +2 -2
- package/dist/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts +20 -8
- package/dist/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/dist/shared-tree/sharedTreeChangeEnricher.js +25 -11
- package/dist/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/dist/shared-tree/treeAlpha.d.ts.map +1 -1
- package/dist/shared-tree/treeAlpha.js +1 -1
- package/dist/shared-tree/treeAlpha.js.map +1 -1
- package/dist/shared-tree/treeCheckout.d.ts +10 -5
- package/dist/shared-tree/treeCheckout.d.ts.map +1 -1
- package/dist/shared-tree/treeCheckout.js +72 -17
- package/dist/shared-tree/treeCheckout.js.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerCodecs.js +10 -8
- package/dist/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/{lib/shared-tree-core/editManagerCodecsV5.d.ts → dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts} +3 -3
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -0
- package/dist/shared-tree-core/{editManagerCodecsV5.js → editManagerCodecsVSharedBranches.js} +7 -7
- package/dist/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -0
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts +8 -30
- package/dist/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerFormatCommons.js +18 -9
- package/dist/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/dist/shared-tree-core/editManagerFormatV1toV4.d.ts +1 -1
- package/dist/shared-tree-core/{editManagerFormatV5.d.ts → editManagerFormatVSharedBranches.d.ts} +3 -3
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -0
- package/dist/shared-tree-core/{editManagerFormatV5.js → editManagerFormatVSharedBranches.js} +2 -2
- package/dist/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -0
- package/dist/shared-tree-core/editManagerSummarizer.d.ts +29 -9
- package/dist/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/dist/shared-tree-core/editManagerSummarizer.js +41 -13
- package/dist/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/dist/shared-tree-core/index.d.ts +5 -2
- package/dist/shared-tree-core/index.d.ts.map +1 -1
- package/dist/shared-tree-core/index.js +7 -1
- package/dist/shared-tree-core/index.js.map +1 -1
- package/{lib/shared-tree-core/messageCodecV5.d.ts → dist/shared-tree-core/messageCodecVSharedBranches.d.ts} +2 -2
- package/dist/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -0
- package/dist/shared-tree-core/{messageCodecV5.js → messageCodecVSharedBranches.js} +6 -6
- package/dist/shared-tree-core/messageCodecVSharedBranches.js.map +1 -0
- package/dist/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/dist/shared-tree-core/messageCodecs.js +12 -10
- package/dist/shared-tree-core/messageCodecs.js.map +1 -1
- package/dist/shared-tree-core/messageFormat.d.ts +9 -36
- package/dist/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/dist/shared-tree-core/messageFormat.js +19 -9
- package/dist/shared-tree-core/messageFormat.js.map +1 -1
- package/{lib/shared-tree-core/messageFormatV5.d.ts → dist/shared-tree-core/messageFormatVSharedBranches.d.ts} +5 -7
- package/dist/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -0
- package/dist/shared-tree-core/{messageFormatV5.js → messageFormatVSharedBranches.js} +3 -2
- package/dist/shared-tree-core/messageFormatVSharedBranches.js.map +1 -0
- package/dist/shared-tree-core/sharedTreeCore.d.ts +13 -47
- package/dist/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/dist/shared-tree-core/sharedTreeCore.js +29 -17
- package/dist/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/dist/shared-tree-core/summaryTypes.d.ts +94 -0
- package/dist/shared-tree-core/summaryTypes.d.ts.map +1 -0
- package/dist/shared-tree-core/summaryTypes.js +47 -0
- package/dist/shared-tree-core/summaryTypes.js.map +1 -0
- package/dist/shared-tree-core/versionedSummarizer.d.ts +72 -0
- package/dist/shared-tree-core/versionedSummarizer.d.ts.map +1 -0
- package/dist/shared-tree-core/versionedSummarizer.js +64 -0
- package/dist/shared-tree-core/versionedSummarizer.js.map +1 -0
- package/dist/simple-tree/api/configuration.d.ts +3 -26
- package/dist/simple-tree/api/configuration.d.ts.map +1 -1
- package/dist/simple-tree/api/configuration.js +10 -21
- package/dist/simple-tree/api/configuration.js.map +1 -1
- package/dist/simple-tree/api/dirtyIndex.d.ts +11 -0
- package/dist/simple-tree/api/dirtyIndex.d.ts.map +1 -1
- package/dist/simple-tree/api/dirtyIndex.js +7 -0
- package/dist/simple-tree/api/dirtyIndex.js.map +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts +1 -1
- package/dist/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/dist/simple-tree/api/discrepancies.js.map +1 -1
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts +89 -0
- package/dist/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -0
- package/dist/simple-tree/api/eraseSchemaDetails.js +97 -0
- package/dist/simple-tree/api/eraseSchemaDetails.js.map +1 -0
- package/dist/simple-tree/api/getSimpleSchema.d.ts +3 -3
- package/dist/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/getSimpleSchema.js +9 -3
- package/dist/simple-tree/api/getSimpleSchema.js.map +1 -1
- package/dist/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
- package/dist/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/api/incrementalAllowedTypes.js +7 -0
- package/dist/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
- package/dist/simple-tree/api/index.d.ts +4 -4
- package/dist/simple-tree/api/index.d.ts.map +1 -1
- package/dist/simple-tree/api/index.js +8 -5
- package/dist/simple-tree/api/index.js.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts +5 -5
- package/dist/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js +0 -1
- package/dist/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts +6 -1
- package/dist/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/dist/simple-tree/api/schemaFromSimple.js +5 -0
- package/dist/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/dist/simple-tree/api/schemaStatics.d.ts +12 -12
- package/dist/simple-tree/api/simpleSchemaCodec.d.ts +15 -3
- package/dist/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaCodec.js +18 -6
- package/dist/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts +8 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js +13 -8
- package/dist/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts +1 -1
- package/dist/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/dist/simple-tree/api/storedSchema.js +1 -2
- package/dist/simple-tree/api/storedSchema.js.map +1 -1
- package/dist/simple-tree/api/tree.d.ts +15 -2
- 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/typesUnsafe.d.ts +3 -3
- package/dist/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/dist/simple-tree/api/typesUnsafe.js.map +1 -1
- package/dist/simple-tree/core/allowedTypes.d.ts +2 -2
- package/dist/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/dist/simple-tree/core/allowedTypes.js.map +1 -1
- package/dist/simple-tree/core/index.d.ts +1 -1
- package/dist/simple-tree/core/index.d.ts.map +1 -1
- package/dist/simple-tree/core/index.js +2 -3
- package/dist/simple-tree/core/index.js.map +1 -1
- package/dist/simple-tree/core/toStored.d.ts +17 -15
- package/dist/simple-tree/core/toStored.d.ts.map +1 -1
- package/dist/simple-tree/core/toStored.js +5 -40
- package/dist/simple-tree/core/toStored.js.map +1 -1
- package/dist/simple-tree/core/treeNode.d.ts.map +1 -1
- package/dist/simple-tree/core/treeNode.js +1 -0
- package/dist/simple-tree/core/treeNode.js.map +1 -1
- package/dist/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/dist/simple-tree/core/walkSchema.js +4 -0
- package/dist/simple-tree/core/walkSchema.js.map +1 -1
- package/dist/simple-tree/createContext.d.ts.map +1 -1
- package/dist/simple-tree/createContext.js +20 -5
- package/dist/simple-tree/createContext.js.map +1 -1
- package/dist/simple-tree/fieldSchema.d.ts +3 -3
- package/dist/simple-tree/fieldSchema.d.ts.map +1 -1
- package/dist/simple-tree/fieldSchema.js.map +1 -1
- package/dist/simple-tree/index.d.ts +6 -5
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +16 -11
- package/dist/simple-tree/index.js.map +1 -1
- package/dist/simple-tree/leafNodeSchema.d.ts +5 -5
- package/dist/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts +2 -2
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -3
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/dist/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/dist/simple-tree/simpleSchema.d.ts +55 -23
- package/dist/simple-tree/simpleSchema.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchema.js +17 -0
- package/dist/simple-tree/simpleSchema.js.map +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.d.ts +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
- package/dist/simple-tree/simpleSchemaFormatV1.js +8 -1
- package/dist/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/dist/simple-tree/toStoredSchema.d.ts +58 -11
- package/dist/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/dist/simple-tree/toStoredSchema.js +205 -30
- package/dist/simple-tree/toStoredSchema.js.map +1 -1
- package/dist/simple-tree/treeSchema.d.ts +23 -0
- package/dist/simple-tree/treeSchema.d.ts.map +1 -0
- package/dist/simple-tree/treeSchema.js +25 -0
- package/dist/simple-tree/treeSchema.js.map +1 -0
- package/dist/tableSchema.d.ts +107 -64
- package/dist/tableSchema.d.ts.map +1 -1
- package/dist/tableSchema.js +161 -60
- package/dist/tableSchema.js.map +1 -1
- package/dist/util/brand.d.ts +49 -0
- package/dist/util/brand.d.ts.map +1 -1
- package/dist/util/brand.js +47 -1
- package/dist/util/brand.js.map +1 -1
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +6 -2
- package/dist/util/index.js.map +1 -1
- package/dist/util/readSnapshotBlob.d.ts +13 -0
- package/dist/util/readSnapshotBlob.d.ts.map +1 -0
- package/dist/util/readSnapshotBlob.js +18 -0
- package/dist/util/readSnapshotBlob.js.map +1 -0
- package/eslint.config.mts +98 -0
- package/lib/alpha.d.ts +6 -2
- package/lib/codec/codec.d.ts +41 -13
- package/lib/codec/codec.d.ts.map +1 -1
- package/lib/codec/codec.js +40 -13
- package/lib/codec/codec.js.map +1 -1
- package/lib/codec/versioned/codec.d.ts +1 -1
- package/lib/codec/versioned/codec.d.ts.map +1 -1
- package/lib/codec/versioned/codec.js.map +1 -1
- package/lib/codec/versioned/format.d.ts +4 -1
- package/lib/codec/versioned/format.d.ts.map +1 -1
- package/lib/codec/versioned/format.js +4 -1
- package/lib/codec/versioned/format.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/rebase/index.d.ts +1 -1
- package/lib/core/rebase/index.d.ts.map +1 -1
- package/lib/core/rebase/index.js.map +1 -1
- package/lib/core/rebase/types.d.ts +20 -1
- package/lib/core/rebase/types.d.ts.map +1 -1
- package/lib/core/rebase/types.js.map +1 -1
- package/lib/core/schema-stored/schema.d.ts +4 -7
- package/lib/core/schema-stored/schema.d.ts.map +1 -1
- package/lib/core/schema-stored/schema.js +3 -3
- package/lib/core/schema-stored/schema.js.map +1 -1
- package/lib/core/tree/detachedFieldIndex.d.ts +34 -13
- package/lib/core/tree/detachedFieldIndex.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndex.js +12 -12
- package/lib/core/tree/detachedFieldIndex.js.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts +4 -4
- package/lib/core/tree/detachedFieldIndexFormatCommon.d.ts.map +1 -1
- package/lib/core/tree/detachedFieldIndexFormatCommon.js +3 -3
- package/lib/core/tree/detachedFieldIndexFormatCommon.js.map +1 -1
- package/lib/core/tree/index.d.ts +3 -2
- package/lib/core/tree/index.d.ts.map +1 -1
- package/lib/core/tree/index.js +2 -1
- package/lib/core/tree/index.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/codecs.js +3 -3
- package/lib/feature-libraries/chunked-forest/codec/codecs.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts +5 -5
- package/lib/feature-libraries/chunked-forest/codec/format.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/format.js +5 -5
- package/lib/feature-libraries/chunked-forest/codec/format.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts +14 -6
- package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.d.ts.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.js.map +1 -1
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js +7 -2
- package/lib/feature-libraries/chunked-forest/codec/schemaBasedEncode.js.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts +3 -3
- package/lib/feature-libraries/default-schema/defaultFieldKinds.d.ts.map +1 -1
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js +23 -27
- package/lib/feature-libraries/default-schema/defaultFieldKinds.js.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts +30 -8
- package/lib/feature-libraries/detachedFieldIndexSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js +38 -8
- package/lib/feature-libraries/detachedFieldIndexSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts +7 -1
- package/lib/feature-libraries/forest-summary/codec.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/codec.js +12 -11
- package/lib/feature-libraries/forest-summary/codec.js.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts +10 -13
- package/lib/feature-libraries/forest-summary/forestSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/forestSummarizer.js +33 -29
- package/lib/feature-libraries/forest-summary/forestSummarizer.js.map +1 -1
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts +61 -0
- package/lib/feature-libraries/forest-summary/formatCommon.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/formatCommon.js +23 -0
- package/lib/feature-libraries/forest-summary/formatCommon.js.map +1 -0
- package/lib/feature-libraries/forest-summary/formatV1.d.ts +51 -0
- package/lib/feature-libraries/forest-summary/formatV1.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/formatV1.js +8 -0
- package/lib/feature-libraries/forest-summary/formatV1.js.map +1 -0
- package/lib/feature-libraries/forest-summary/formatV2.d.ts +51 -0
- package/lib/feature-libraries/forest-summary/formatV2.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/formatV2.js +8 -0
- package/lib/feature-libraries/forest-summary/formatV2.js.map +1 -0
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts +18 -24
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js +20 -42
- package/lib/feature-libraries/forest-summary/incrementalSummaryBuilder.js.map +1 -1
- package/lib/feature-libraries/forest-summary/index.d.ts +2 -2
- package/lib/feature-libraries/forest-summary/index.d.ts.map +1 -1
- package/lib/feature-libraries/forest-summary/index.js +2 -2
- package/lib/feature-libraries/forest-summary/index.js.map +1 -1
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.d.ts +35 -0
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.js +40 -0
- package/lib/feature-libraries/forest-summary/summaryFormatCommon.js.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts +11 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.js +11 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV1ToV2.js.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.d.ts +18 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.js +18 -0
- package/lib/feature-libraries/forest-summary/summaryFormatV3.js.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryTypes.d.ts +17 -0
- package/lib/feature-libraries/forest-summary/summaryTypes.d.ts.map +1 -0
- package/lib/feature-libraries/forest-summary/summaryTypes.js +30 -0
- package/lib/feature-libraries/forest-summary/summaryTypes.js.map +1 -0
- package/lib/feature-libraries/index.d.ts +1 -1
- package/lib/feature-libraries/index.d.ts.map +1 -1
- package/lib/feature-libraries/index.js +1 -1
- package/lib/feature-libraries/index.js.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.d.ts +18 -2
- package/lib/feature-libraries/modular-schema/comparison.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/comparison.js +55 -5
- package/lib/feature-libraries/modular-schema/comparison.js.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKind.d.ts +25 -13
- package/lib/feature-libraries/modular-schema/fieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/fieldKind.js +0 -21
- package/lib/feature-libraries/modular-schema/fieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js +4 -1
- package/lib/feature-libraries/modular-schema/genericFieldKind.js.map +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts +1 -1
- package/lib/feature-libraries/modular-schema/index.d.ts.map +1 -1
- package/lib/feature-libraries/modular-schema/index.js +1 -1
- package/lib/feature-libraries/modular-schema/index.js.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.d.ts.map +1 -1
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js +2 -3
- package/lib/feature-libraries/schema-edits/schemaChangeCodecs.js.map +1 -1
- package/lib/feature-libraries/schema-index/codec.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/codec.js +5 -5
- package/lib/feature-libraries/schema-index/codec.js.map +1 -1
- package/lib/feature-libraries/schema-index/formatV1.d.ts +1 -1
- package/lib/feature-libraries/schema-index/formatV2.d.ts +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts +27 -8
- package/lib/feature-libraries/schema-index/schemaSummarizer.d.ts.map +1 -1
- package/lib/feature-libraries/schema-index/schemaSummarizer.js +38 -12
- package/lib/feature-libraries/schema-index/schemaSummarizer.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +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 +2 -2
- package/lib/shared-tree/independentView.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts +2 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +3 -0
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/shared-tree/sharedTree.d.ts +2 -2
- package/lib/shared-tree/sharedTree.d.ts.map +1 -1
- package/lib/shared-tree/sharedTree.js +4 -4
- package/lib/shared-tree/sharedTree.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeCodecs.js +2 -2
- package/lib/shared-tree/sharedTreeChangeCodecs.js.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts +20 -8
- package/lib/shared-tree/sharedTreeChangeEnricher.d.ts.map +1 -1
- package/lib/shared-tree/sharedTreeChangeEnricher.js +25 -11
- package/lib/shared-tree/sharedTreeChangeEnricher.js.map +1 -1
- package/lib/shared-tree/treeAlpha.d.ts.map +1 -1
- package/lib/shared-tree/treeAlpha.js +2 -2
- package/lib/shared-tree/treeAlpha.js.map +1 -1
- package/lib/shared-tree/treeCheckout.d.ts +10 -5
- package/lib/shared-tree/treeCheckout.d.ts.map +1 -1
- package/lib/shared-tree/treeCheckout.js +73 -18
- package/lib/shared-tree/treeCheckout.js.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerCodecs.js +11 -9
- package/lib/shared-tree-core/editManagerCodecs.js.map +1 -1
- package/{dist/shared-tree-core/editManagerCodecsV5.d.ts → lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts} +3 -3
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.d.ts.map +1 -0
- package/lib/shared-tree-core/{editManagerCodecsV5.js → editManagerCodecsVSharedBranches.js} +4 -4
- package/lib/shared-tree-core/editManagerCodecsVSharedBranches.js.map +1 -0
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts +8 -30
- package/lib/shared-tree-core/editManagerFormatCommons.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerFormatCommons.js +19 -10
- package/lib/shared-tree-core/editManagerFormatCommons.js.map +1 -1
- package/lib/shared-tree-core/editManagerFormatV1toV4.d.ts +1 -1
- package/lib/shared-tree-core/{editManagerFormatV5.d.ts → editManagerFormatVSharedBranches.d.ts} +3 -3
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.d.ts.map +1 -0
- package/lib/shared-tree-core/{editManagerFormatV5.js → editManagerFormatVSharedBranches.js} +2 -2
- package/lib/shared-tree-core/editManagerFormatVSharedBranches.js.map +1 -0
- package/lib/shared-tree-core/editManagerSummarizer.d.ts +29 -9
- package/lib/shared-tree-core/editManagerSummarizer.d.ts.map +1 -1
- package/lib/shared-tree-core/editManagerSummarizer.js +39 -11
- package/lib/shared-tree-core/editManagerSummarizer.js.map +1 -1
- package/lib/shared-tree-core/index.d.ts +5 -2
- package/lib/shared-tree-core/index.d.ts.map +1 -1
- package/lib/shared-tree-core/index.js +3 -1
- package/lib/shared-tree-core/index.js.map +1 -1
- package/{dist/shared-tree-core/messageCodecV5.d.ts → lib/shared-tree-core/messageCodecVSharedBranches.d.ts} +2 -2
- package/lib/shared-tree-core/messageCodecVSharedBranches.d.ts.map +1 -0
- package/lib/shared-tree-core/{messageCodecV5.js → messageCodecVSharedBranches.js} +3 -3
- package/lib/shared-tree-core/messageCodecVSharedBranches.js.map +1 -0
- package/lib/shared-tree-core/messageCodecs.d.ts.map +1 -1
- package/lib/shared-tree-core/messageCodecs.js +13 -11
- package/lib/shared-tree-core/messageCodecs.js.map +1 -1
- package/lib/shared-tree-core/messageFormat.d.ts +9 -36
- package/lib/shared-tree-core/messageFormat.d.ts.map +1 -1
- package/lib/shared-tree-core/messageFormat.js +19 -9
- package/lib/shared-tree-core/messageFormat.js.map +1 -1
- package/{dist/shared-tree-core/messageFormatV5.d.ts → lib/shared-tree-core/messageFormatVSharedBranches.d.ts} +5 -7
- package/lib/shared-tree-core/messageFormatVSharedBranches.d.ts.map +1 -0
- package/lib/shared-tree-core/{messageFormatV5.js → messageFormatVSharedBranches.js} +3 -2
- package/lib/shared-tree-core/messageFormatVSharedBranches.js.map +1 -0
- package/lib/shared-tree-core/sharedTreeCore.d.ts +13 -47
- package/lib/shared-tree-core/sharedTreeCore.d.ts.map +1 -1
- package/lib/shared-tree-core/sharedTreeCore.js +27 -15
- package/lib/shared-tree-core/sharedTreeCore.js.map +1 -1
- package/lib/shared-tree-core/summaryTypes.d.ts +94 -0
- package/lib/shared-tree-core/summaryTypes.d.ts.map +1 -0
- package/lib/shared-tree-core/summaryTypes.js +43 -0
- package/lib/shared-tree-core/summaryTypes.js.map +1 -0
- package/lib/shared-tree-core/versionedSummarizer.d.ts +72 -0
- package/lib/shared-tree-core/versionedSummarizer.d.ts.map +1 -0
- package/lib/shared-tree-core/versionedSummarizer.js +60 -0
- package/lib/shared-tree-core/versionedSummarizer.js.map +1 -0
- package/lib/simple-tree/api/configuration.d.ts +3 -26
- package/lib/simple-tree/api/configuration.d.ts.map +1 -1
- package/lib/simple-tree/api/configuration.js +14 -25
- package/lib/simple-tree/api/configuration.js.map +1 -1
- package/lib/simple-tree/api/dirtyIndex.d.ts +11 -0
- package/lib/simple-tree/api/dirtyIndex.d.ts.map +1 -1
- package/lib/simple-tree/api/dirtyIndex.js +7 -0
- package/lib/simple-tree/api/dirtyIndex.js.map +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts +1 -1
- package/lib/simple-tree/api/discrepancies.d.ts.map +1 -1
- package/lib/simple-tree/api/discrepancies.js.map +1 -1
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts +89 -0
- package/lib/simple-tree/api/eraseSchemaDetails.d.ts.map +1 -0
- package/lib/simple-tree/api/eraseSchemaDetails.js +92 -0
- package/lib/simple-tree/api/eraseSchemaDetails.js.map +1 -0
- package/lib/simple-tree/api/getSimpleSchema.d.ts +3 -3
- package/lib/simple-tree/api/getSimpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/getSimpleSchema.js +9 -3
- package/lib/simple-tree/api/getSimpleSchema.js.map +1 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.d.ts +1 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.js +8 -1
- package/lib/simple-tree/api/incrementalAllowedTypes.js.map +1 -1
- package/lib/simple-tree/api/index.d.ts +4 -4
- package/lib/simple-tree/api/index.d.ts.map +1 -1
- package/lib/simple-tree/api/index.js +3 -3
- package/lib/simple-tree/api/index.js.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts +5 -5
- package/lib/simple-tree/api/schemaFactoryAlpha.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryAlpha.js.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js +0 -1
- package/lib/simple-tree/api/schemaFactoryRecursive.js.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts +6 -1
- package/lib/simple-tree/api/schemaFromSimple.d.ts.map +1 -1
- package/lib/simple-tree/api/schemaFromSimple.js +5 -0
- package/lib/simple-tree/api/schemaFromSimple.js.map +1 -1
- package/lib/simple-tree/api/schemaStatics.d.ts +12 -12
- package/lib/simple-tree/api/simpleSchemaCodec.d.ts +15 -3
- package/lib/simple-tree/api/simpleSchemaCodec.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaCodec.js +15 -3
- package/lib/simple-tree/api/simpleSchemaCodec.js.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/simpleSchemaToJsonSchema.js.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts +8 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.d.ts.map +1 -1
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js +15 -10
- package/lib/simple-tree/api/snapshotCompatibilityChecker.js.map +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts +1 -1
- package/lib/simple-tree/api/storedSchema.d.ts.map +1 -1
- package/lib/simple-tree/api/storedSchema.js +1 -2
- package/lib/simple-tree/api/storedSchema.js.map +1 -1
- package/lib/simple-tree/api/tree.d.ts +15 -2
- 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/typesUnsafe.d.ts +3 -3
- package/lib/simple-tree/api/typesUnsafe.d.ts.map +1 -1
- package/lib/simple-tree/api/typesUnsafe.js.map +1 -1
- package/lib/simple-tree/core/allowedTypes.d.ts +2 -2
- package/lib/simple-tree/core/allowedTypes.d.ts.map +1 -1
- package/lib/simple-tree/core/allowedTypes.js.map +1 -1
- package/lib/simple-tree/core/index.d.ts +1 -1
- package/lib/simple-tree/core/index.d.ts.map +1 -1
- package/lib/simple-tree/core/index.js +1 -1
- package/lib/simple-tree/core/index.js.map +1 -1
- package/lib/simple-tree/core/toStored.d.ts +17 -15
- package/lib/simple-tree/core/toStored.d.ts.map +1 -1
- package/lib/simple-tree/core/toStored.js +4 -37
- package/lib/simple-tree/core/toStored.js.map +1 -1
- package/lib/simple-tree/core/treeNode.d.ts.map +1 -1
- package/lib/simple-tree/core/treeNode.js +1 -0
- package/lib/simple-tree/core/treeNode.js.map +1 -1
- package/lib/simple-tree/core/walkSchema.d.ts.map +1 -1
- package/lib/simple-tree/core/walkSchema.js +5 -1
- package/lib/simple-tree/core/walkSchema.js.map +1 -1
- package/lib/simple-tree/createContext.d.ts.map +1 -1
- package/lib/simple-tree/createContext.js +20 -5
- package/lib/simple-tree/createContext.js.map +1 -1
- package/lib/simple-tree/fieldSchema.d.ts +3 -3
- package/lib/simple-tree/fieldSchema.d.ts.map +1 -1
- package/lib/simple-tree/fieldSchema.js.map +1 -1
- package/lib/simple-tree/index.d.ts +6 -5
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +5 -4
- package/lib/simple-tree/index.js.map +1 -1
- package/lib/simple-tree/leafNodeSchema.d.ts +5 -5
- package/lib/simple-tree/leafNodeSchema.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts +3 -3
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/array/arrayNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts +3 -3
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/map/mapNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts +2 -2
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/object/objectNodeTypes.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNode.js.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts +3 -3
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.d.ts.map +1 -1
- package/lib/simple-tree/node-kinds/record/recordNodeTypes.js.map +1 -1
- package/lib/simple-tree/simpleSchema.d.ts +55 -23
- package/lib/simple-tree/simpleSchema.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchema.js +16 -1
- package/lib/simple-tree/simpleSchema.js.map +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.d.ts +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.d.ts.map +1 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js +8 -1
- package/lib/simple-tree/simpleSchemaFormatV1.js.map +1 -1
- package/lib/simple-tree/toStoredSchema.d.ts +58 -11
- package/lib/simple-tree/toStoredSchema.d.ts.map +1 -1
- package/lib/simple-tree/toStoredSchema.js +204 -31
- package/lib/simple-tree/toStoredSchema.js.map +1 -1
- package/lib/simple-tree/treeSchema.d.ts +23 -0
- package/lib/simple-tree/treeSchema.d.ts.map +1 -0
- package/lib/simple-tree/treeSchema.js +21 -0
- package/lib/simple-tree/treeSchema.js.map +1 -0
- package/lib/tableSchema.d.ts +107 -64
- package/lib/tableSchema.d.ts.map +1 -1
- package/lib/tableSchema.js +162 -61
- package/lib/tableSchema.js.map +1 -1
- package/lib/util/brand.d.ts +49 -0
- package/lib/util/brand.d.ts.map +1 -1
- package/lib/util/brand.js +44 -0
- package/lib/util/brand.js.map +1 -1
- package/lib/util/index.d.ts +2 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/readSnapshotBlob.d.ts +13 -0
- package/lib/util/readSnapshotBlob.d.ts.map +1 -0
- package/lib/util/readSnapshotBlob.js +14 -0
- package/lib/util/readSnapshotBlob.js.map +1 -0
- package/package.json +24 -23
- package/src/codec/codec.ts +44 -14
- package/src/codec/versioned/codec.ts +1 -1
- package/src/codec/versioned/format.ts +4 -1
- package/src/core/index.ts +4 -1
- package/src/core/rebase/index.ts +1 -0
- package/src/core/rebase/types.ts +25 -0
- package/src/core/schema-stored/schema.ts +5 -7
- package/src/core/tree/detachedFieldIndex.ts +54 -13
- package/src/core/tree/detachedFieldIndexFormatCommon.ts +4 -7
- package/src/core/tree/index.ts +7 -2
- package/src/feature-libraries/chunked-forest/codec/codecs.ts +3 -2
- package/src/feature-libraries/chunked-forest/codec/format.ts +6 -9
- package/src/feature-libraries/chunked-forest/codec/incrementalEncodingPolicy.ts +15 -7
- package/src/feature-libraries/chunked-forest/codec/schemaBasedEncode.ts +9 -9
- package/src/feature-libraries/default-schema/defaultFieldKinds.ts +22 -33
- package/src/feature-libraries/detachedFieldIndexSummarizer.ts +62 -15
- package/src/feature-libraries/forest-summary/codec.ts +22 -10
- package/src/feature-libraries/forest-summary/forestSummarizer.ts +77 -44
- package/src/feature-libraries/forest-summary/{format.ts → formatCommon.ts} +12 -13
- package/src/feature-libraries/forest-summary/formatV1.ts +12 -0
- package/src/feature-libraries/forest-summary/formatV2.ts +12 -0
- package/src/feature-libraries/forest-summary/incrementalSummaryBuilder.ts +37 -56
- package/src/feature-libraries/forest-summary/index.ts +2 -2
- package/src/feature-libraries/forest-summary/summaryFormatCommon.ts +41 -0
- package/src/feature-libraries/forest-summary/summaryFormatV1ToV2.ts +11 -0
- package/src/feature-libraries/forest-summary/summaryFormatV3.ts +18 -0
- package/src/feature-libraries/forest-summary/summaryTypes.ts +41 -0
- package/src/feature-libraries/index.ts +1 -1
- package/src/feature-libraries/modular-schema/comparison.ts +64 -5
- package/src/feature-libraries/modular-schema/fieldKind.ts +24 -40
- package/src/feature-libraries/modular-schema/genericFieldKind.ts +4 -1
- package/src/feature-libraries/modular-schema/index.ts +1 -0
- package/src/feature-libraries/schema-edits/schemaChangeCodecs.ts +2 -3
- package/src/feature-libraries/schema-index/codec.ts +7 -9
- package/src/feature-libraries/schema-index/schemaSummarizer.ts +59 -18
- package/src/index.ts +6 -2
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/independentView.ts +2 -3
- package/src/shared-tree/schematizingTreeView.ts +5 -0
- package/src/shared-tree/sharedTree.ts +20 -9
- package/src/shared-tree/sharedTreeChangeCodecs.ts +2 -2
- package/src/shared-tree/sharedTreeChangeEnricher.ts +31 -11
- package/src/shared-tree/treeAlpha.ts +2 -3
- package/src/shared-tree/treeCheckout.ts +103 -20
- package/src/shared-tree-core/editManagerCodecs.ts +11 -9
- package/src/shared-tree-core/{editManagerCodecsV5.ts → editManagerCodecsVSharedBranches.ts} +3 -3
- package/src/shared-tree-core/editManagerFormatCommons.ts +22 -16
- package/src/shared-tree-core/{editManagerFormatV5.ts → editManagerFormatVSharedBranches.ts} +2 -2
- package/src/shared-tree-core/editManagerSummarizer.ts +58 -16
- package/src/shared-tree-core/index.ts +12 -3
- package/src/shared-tree-core/{messageCodecV5.ts → messageCodecVSharedBranches.ts} +3 -3
- package/src/shared-tree-core/messageCodecs.ts +13 -11
- package/src/shared-tree-core/messageFormat.ts +23 -16
- package/src/shared-tree-core/{messageFormatV5.ts → messageFormatVSharedBranches.ts} +4 -6
- package/src/shared-tree-core/sharedTreeCore.ts +63 -75
- package/src/shared-tree-core/summaryTypes.ts +122 -0
- package/src/shared-tree-core/versionedSummarizer.ts +114 -0
- package/src/simple-tree/api/configuration.ts +21 -68
- package/src/simple-tree/api/dirtyIndex.ts +11 -0
- package/src/simple-tree/api/discrepancies.ts +1 -1
- package/src/simple-tree/api/eraseSchemaDetails.ts +123 -0
- package/src/simple-tree/api/getSimpleSchema.ts +13 -6
- package/src/simple-tree/api/incrementalAllowedTypes.ts +15 -3
- package/src/simple-tree/api/index.ts +7 -4
- package/src/simple-tree/api/schemaCompatibilityTester.ts +1 -1
- package/src/simple-tree/api/schemaFactoryAlpha.ts +2 -2
- package/src/simple-tree/api/schemaFactoryRecursive.ts +0 -2
- package/src/simple-tree/api/schemaFromSimple.ts +11 -5
- package/src/simple-tree/api/simpleSchemaCodec.ts +17 -3
- package/src/simple-tree/api/simpleSchemaToJsonSchema.ts +1 -1
- package/src/simple-tree/api/snapshotCompatibilityChecker.ts +18 -10
- package/src/simple-tree/api/storedSchema.ts +2 -2
- package/src/simple-tree/api/tree.ts +16 -1
- package/src/simple-tree/api/typesUnsafe.ts +7 -3
- package/src/simple-tree/core/allowedTypes.ts +3 -3
- package/src/simple-tree/core/index.ts +2 -2
- package/src/simple-tree/core/toStored.ts +22 -55
- package/src/simple-tree/core/treeNode.ts +1 -0
- package/src/simple-tree/core/walkSchema.ts +6 -0
- package/src/simple-tree/createContext.ts +29 -11
- package/src/simple-tree/fieldSchema.ts +10 -3
- package/src/simple-tree/index.ts +12 -10
- package/src/simple-tree/node-kinds/array/arrayNode.ts +5 -2
- package/src/simple-tree/node-kinds/array/arrayNodeTypes.ts +3 -3
- package/src/simple-tree/node-kinds/map/mapNode.ts +5 -2
- package/src/simple-tree/node-kinds/map/mapNodeTypes.ts +3 -3
- package/src/simple-tree/node-kinds/object/objectNodeTypes.ts +6 -2
- package/src/simple-tree/node-kinds/record/recordNode.ts +5 -2
- package/src/simple-tree/node-kinds/record/recordNodeTypes.ts +3 -3
- package/src/simple-tree/simpleSchema.ts +79 -32
- package/src/simple-tree/simpleSchemaFormatV1.ts +9 -1
- package/src/simple-tree/toStoredSchema.ts +319 -61
- package/src/simple-tree/treeSchema.ts +54 -0
- package/src/tableSchema.ts +487 -173
- package/src/util/brand.ts +61 -0
- package/src/util/index.ts +5 -0
- package/src/util/readSnapshotBlob.ts +23 -0
- package/dist/feature-libraries/forest-summary/format.d.ts +0 -23
- package/dist/feature-libraries/forest-summary/format.d.ts.map +0 -1
- package/dist/feature-libraries/forest-summary/format.js +0 -24
- package/dist/feature-libraries/forest-summary/format.js.map +0 -1
- package/dist/shared-tree-core/editManagerCodecsV5.d.ts.map +0 -1
- package/dist/shared-tree-core/editManagerCodecsV5.js.map +0 -1
- package/dist/shared-tree-core/editManagerFormatV5.d.ts.map +0 -1
- package/dist/shared-tree-core/editManagerFormatV5.js.map +0 -1
- package/dist/shared-tree-core/messageCodecV5.d.ts.map +0 -1
- package/dist/shared-tree-core/messageCodecV5.js.map +0 -1
- package/dist/shared-tree-core/messageFormatV5.d.ts.map +0 -1
- package/dist/shared-tree-core/messageFormatV5.js.map +0 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts +0 -40
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +0 -1
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js +0 -177
- package/dist/simple-tree/api/viewSchemaToSimpleSchema.js.map +0 -1
- package/lib/feature-libraries/forest-summary/format.d.ts +0 -23
- package/lib/feature-libraries/forest-summary/format.d.ts.map +0 -1
- package/lib/feature-libraries/forest-summary/format.js +0 -21
- package/lib/feature-libraries/forest-summary/format.js.map +0 -1
- package/lib/shared-tree-core/editManagerCodecsV5.d.ts.map +0 -1
- package/lib/shared-tree-core/editManagerCodecsV5.js.map +0 -1
- package/lib/shared-tree-core/editManagerFormatV5.d.ts.map +0 -1
- package/lib/shared-tree-core/editManagerFormatV5.js.map +0 -1
- package/lib/shared-tree-core/messageCodecV5.d.ts.map +0 -1
- package/lib/shared-tree-core/messageCodecV5.js.map +0 -1
- package/lib/shared-tree-core/messageFormatV5.d.ts.map +0 -1
- package/lib/shared-tree-core/messageFormatV5.js.map +0 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts +0 -40
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.d.ts.map +0 -1
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js +0 -171
- package/lib/simple-tree/api/viewSchemaToSimpleSchema.js.map +0 -1
- package/src/simple-tree/api/viewSchemaToSimpleSchema.ts +0 -209
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleSchemaFormatV1.d.ts","sourceRoot":"","sources":["../../src/simple-tree/simpleSchemaFormatV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"simpleSchemaFormatV1.d.ts","sourceRoot":"","sources":["../../src/simple-tree/simpleSchemaFormatV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI1E;;GAEG;AACH,eAAO,MAAM,yBAAyB;;CAE5B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,iCAAiC;;EAK7C,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,MAAM,CACrD,OAAO,iCAAiC,CACxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBA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M,2BAA2B,GAAG,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGzC,CAAC;AACF,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOlC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
/*
|
|
6
|
+
* This file contains a format for serializing the compatibility impacting subset of simple schema.
|
|
7
|
+
|
|
8
|
+
* This format can be used for both view and stored simple schema.
|
|
9
|
+
* This only includes all parts of the schema that impact compatibility according to SchemaCompatibilityTester.
|
|
10
|
+
* It may not include some details which impact maintenance of application enforced invariants (like persisted metadata or logic in view schema).
|
|
11
|
+
*/
|
|
5
12
|
import { Type } from "@sinclair/typebox";
|
|
6
13
|
const noAdditionalProps = { additionalProperties: false };
|
|
7
14
|
/**
|
|
@@ -101,7 +108,7 @@ export const SimpleNodeSchemaUnionFormat = Type.Object({
|
|
|
101
108
|
*/
|
|
102
109
|
export const SimpleSchemaDefinitionsFormat = Type.Record(Type.String(), SimpleNodeSchemaUnionFormat);
|
|
103
110
|
/**
|
|
104
|
-
* Persisted format for the
|
|
111
|
+
* Persisted format for the compatibility impacting subset of simple schema.
|
|
105
112
|
* @see {@link SimpleTreeSchema}.
|
|
106
113
|
*/
|
|
107
114
|
export const SimpleTreeSchemaFormat = Type.Object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleSchemaFormatV1.js","sourceRoot":"","sources":["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;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC,MAAM,CACvD,IAAI,CAAC,MAAM,EAAE,EACb,2BAA2B,CAC3B,CAAC;AAGF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAChD;IACC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE,CAAC;IACnD,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,6BAA6B;CAC1C,EACD,iBAAiB,CACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Type, type ObjectOptions, type Static } from \"@sinclair/typebox\";\n\nconst noAdditionalProps: ObjectOptions = { additionalProperties: false };\n\n/**\n * The format version for the schema.\n */\nexport const SimpleSchemaFormatVersion = {\n\tv1: 1,\n} as const;\n\n/**\n * The allowed types and their attributes in the simple schema format.\n * @see {@link SimpleAllowedTypes}.\n */\nexport const SimpleAllowedTypeAttributesFormat = Type.Object(\n\t{\n\t\tisStaged: Type.Optional(Type.Boolean()),\n\t},\n\tnoAdditionalProps,\n);\n\nexport type SimpleAllowedTypeAttributesFormat = Static<\n\ttypeof SimpleAllowedTypeAttributesFormat\n>;\n\n/**\n * A set of allowed types in the simple schema format.\n * The keys are the type identifiers, and the values are their attributes.\n */\nexport const SimpleAllowedTypesFormat = Type.Record(\n\tType.String(),\n\tSimpleAllowedTypeAttributesFormat,\n);\nexport type SimpleAllowedTypesFormat = Static<typeof SimpleAllowedTypesFormat>;\n\n/**\n * Persisted format for a field schema in the simple schema format.\n * @see {@link SimpleFieldSchema}.\n */\nexport const SimpleFieldSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleFieldSchemaFormat = Static<typeof SimpleFieldSchemaFormat>;\n\n/**\n * Persisted format for an object field schema in the simple schema format.\n * @see {@link SimpleObjectFieldSchema}.\n */\nexport const SimpleObjectFieldSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t\tstoredKey: Type.String(),\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleObjectFieldSchemaFormat = Static<typeof SimpleObjectFieldSchemaFormat>;\n\n/**\n * Persisted format for an array node schema in the simple schema format.\n * @see {@link SimpleArrayNodeSchema}.\n */\nexport const SimpleArrayNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleArrayNodeSchemaFormat = Static<typeof SimpleArrayNodeSchemaFormat>;\n\n/**\n * Persisted format for a map node schema in the simple schema format.\n * @see {@link SimpleMapNodeSchema}.\n */\nexport const SimpleMapNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleMapNodeSchemaFormat = Static<typeof SimpleMapNodeSchemaFormat>;\n\n/**\n * Persisted format for a record node schema in the simple schema format.\n * @see {@link SimpleRecordNodeSchema}.\n */\nexport const SimpleRecordNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleRecordNodeSchemaFormat = Static<typeof SimpleRecordNodeSchemaFormat>;\n\n/**\n * Persisted format for a leaf node schema in the simple schema format.\n * @see {@link SimpleLeafNodeSchema}.\n */\nexport const SimpleLeafNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tleafKind: Type.Integer(),\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleLeafNodeSchemaFormat = Static<typeof SimpleLeafNodeSchemaFormat>;\n\n/**\n * Persisted format for the field schemas of an object node in the simple schema format.\n */\nexport const SimpleObjectFieldSchemasFormat = Type.Record(\n\tType.String(),\n\tSimpleObjectFieldSchemaFormat,\n);\nexport type SimpleObjectFieldSchemasFormat = Static<typeof SimpleObjectFieldSchemasFormat>;\n\n/**\n * Persisted format for an object node schema in the simple schema format.\n * @see {@link SimpleObjectNodeSchema}.\n */\nexport const SimpleObjectNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tfields: SimpleObjectFieldSchemasFormat,\n\t\tallowUnknownOptionalFields: Type.Optional(Type.Boolean()),\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleObjectNodeSchemaFormat = Static<typeof SimpleObjectNodeSchemaFormat>;\n\n/**\n * Discriminated union of all possible node schemas.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const SimpleNodeSchemaUnionFormat = Type.Object({\n\tarray: Type.Optional(SimpleArrayNodeSchemaFormat),\n\tmap: Type.Optional(SimpleMapNodeSchemaFormat),\n\trecord: Type.Optional(SimpleRecordNodeSchemaFormat),\n\tleaf: Type.Optional(SimpleLeafNodeSchemaFormat),\n\tobject: Type.Optional(SimpleObjectNodeSchemaFormat),\n});\nexport type SimpleNodeSchemaUnionFormat = Static<typeof SimpleNodeSchemaUnionFormat>;\n\n/**\n * Helper type for the schema definitions map in the persisted format.\n */\nexport const SimpleSchemaDefinitionsFormat = Type.Record(\n\tType.String(),\n\tSimpleNodeSchemaUnionFormat,\n);\nexport type SimpleSchemaDefinitionsFormat = Static<typeof SimpleSchemaDefinitionsFormat>;\n\n/**\n * Persisted format for the
|
|
1
|
+
{"version":3,"file":"simpleSchemaFormatV1.js","sourceRoot":"","sources":["../../src/simple-tree/simpleSchemaFormatV1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAmC,MAAM,mBAAmB,CAAC;AAE1E,MAAM,i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;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAChD;IACC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE,CAAC;IACnD,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,6BAA6B;CAC1C,EACD,iBAAiB,CACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/*\n * This file contains a format for serializing the compatibility impacting subset of simple schema.\n\n * This format can be used for both view and stored simple schema.\n * This only includes all parts of the schema that impact compatibility according to SchemaCompatibilityTester.\n * It may not include some details which impact maintenance of application enforced invariants (like persisted metadata or logic in view schema).\n */\n\nimport { Type, type ObjectOptions, type Static } from \"@sinclair/typebox\";\n\nconst noAdditionalProps: ObjectOptions = { additionalProperties: false };\n\n/**\n * The format version for the schema.\n */\nexport const SimpleSchemaFormatVersion = {\n\tv1: 1,\n} as const;\n\n/**\n * The allowed types and their attributes in the simple schema format.\n * @see {@link SimpleAllowedTypes}.\n */\nexport const SimpleAllowedTypeAttributesFormat = Type.Object(\n\t{\n\t\tisStaged: Type.Optional(Type.Boolean()),\n\t},\n\tnoAdditionalProps,\n);\n\nexport type SimpleAllowedTypeAttributesFormat = Static<\n\ttypeof SimpleAllowedTypeAttributesFormat\n>;\n\n/**\n * A set of allowed types in the simple schema format.\n * The keys are the type identifiers, and the values are their attributes.\n */\nexport const SimpleAllowedTypesFormat = Type.Record(\n\tType.String(),\n\tSimpleAllowedTypeAttributesFormat,\n);\nexport type SimpleAllowedTypesFormat = Static<typeof SimpleAllowedTypesFormat>;\n\n/**\n * Persisted format for a field schema in the simple schema format.\n * @see {@link SimpleFieldSchema}.\n */\nexport const SimpleFieldSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleFieldSchemaFormat = Static<typeof SimpleFieldSchemaFormat>;\n\n/**\n * Persisted format for an object field schema in the simple schema format.\n * @see {@link SimpleObjectFieldSchema}.\n */\nexport const SimpleObjectFieldSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t\tstoredKey: Type.String(),\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleObjectFieldSchemaFormat = Static<typeof SimpleObjectFieldSchemaFormat>;\n\n/**\n * Persisted format for an array node schema in the simple schema format.\n * @see {@link SimpleArrayNodeSchema}.\n */\nexport const SimpleArrayNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleArrayNodeSchemaFormat = Static<typeof SimpleArrayNodeSchemaFormat>;\n\n/**\n * Persisted format for a map node schema in the simple schema format.\n * @see {@link SimpleMapNodeSchema}.\n */\nexport const SimpleMapNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleMapNodeSchemaFormat = Static<typeof SimpleMapNodeSchemaFormat>;\n\n/**\n * Persisted format for a record node schema in the simple schema format.\n * @see {@link SimpleRecordNodeSchema}.\n */\nexport const SimpleRecordNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tsimpleAllowedTypes: SimpleAllowedTypesFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleRecordNodeSchemaFormat = Static<typeof SimpleRecordNodeSchemaFormat>;\n\n/**\n * Persisted format for a leaf node schema in the simple schema format.\n * @see {@link SimpleLeafNodeSchema}.\n */\nexport const SimpleLeafNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tleafKind: Type.Integer(),\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleLeafNodeSchemaFormat = Static<typeof SimpleLeafNodeSchemaFormat>;\n\n/**\n * Persisted format for the field schemas of an object node in the simple schema format.\n */\nexport const SimpleObjectFieldSchemasFormat = Type.Record(\n\tType.String(),\n\tSimpleObjectFieldSchemaFormat,\n);\nexport type SimpleObjectFieldSchemasFormat = Static<typeof SimpleObjectFieldSchemasFormat>;\n\n/**\n * Persisted format for an object node schema in the simple schema format.\n * @see {@link SimpleObjectNodeSchema}.\n */\nexport const SimpleObjectNodeSchemaFormat = Type.Object(\n\t{\n\t\tkind: Type.Integer(),\n\t\tfields: SimpleObjectFieldSchemasFormat,\n\t\tallowUnknownOptionalFields: Type.Optional(Type.Boolean()),\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleObjectNodeSchemaFormat = Static<typeof SimpleObjectNodeSchemaFormat>;\n\n/**\n * Discriminated union of all possible node schemas.\n *\n * See {@link DiscriminatedUnionDispatcher} for more information on this pattern.\n */\nexport const SimpleNodeSchemaUnionFormat = Type.Object({\n\tarray: Type.Optional(SimpleArrayNodeSchemaFormat),\n\tmap: Type.Optional(SimpleMapNodeSchemaFormat),\n\trecord: Type.Optional(SimpleRecordNodeSchemaFormat),\n\tleaf: Type.Optional(SimpleLeafNodeSchemaFormat),\n\tobject: Type.Optional(SimpleObjectNodeSchemaFormat),\n});\nexport type SimpleNodeSchemaUnionFormat = Static<typeof SimpleNodeSchemaUnionFormat>;\n\n/**\n * Helper type for the schema definitions map in the persisted format.\n */\nexport const SimpleSchemaDefinitionsFormat = Type.Record(\n\tType.String(),\n\tSimpleNodeSchemaUnionFormat,\n);\nexport type SimpleSchemaDefinitionsFormat = Static<typeof SimpleSchemaDefinitionsFormat>;\n\n/**\n * Persisted format for the compatibility impacting subset of simple schema.\n * @see {@link SimpleTreeSchema}.\n */\nexport const SimpleTreeSchemaFormat = Type.Object(\n\t{\n\t\tversion: Type.Literal(SimpleSchemaFormatVersion.v1),\n\t\troot: SimpleFieldSchemaFormat,\n\t\tdefinitions: SimpleSchemaDefinitionsFormat,\n\t},\n\tnoAdditionalProps,\n);\nexport type SimpleTreeSchemaFormat = Static<typeof SimpleTreeSchemaFormat>;\n"]}
|
|
@@ -2,14 +2,31 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { type TreeFieldStoredSchema, type TreeNodeStoredSchema, type TreeStoredSchema } from "../core/index.js";
|
|
6
6
|
import { type FlexFieldKind } from "../feature-libraries/index.js";
|
|
7
|
-
import { type
|
|
8
|
-
import { type StoredFromViewSchemaGenerationOptions, type StoredSchemaGenerationOptions } from "./core/index.js";
|
|
7
|
+
import { ExpectStored, Unchanged, type SimpleSchemaTransformationOptions, type StoredFromViewSchemaGenerationOptions } from "./core/index.js";
|
|
9
8
|
import { FieldKind, type ImplicitFieldSchema } from "./fieldSchema.js";
|
|
10
|
-
import type { SimpleAllowedTypes, SimpleFieldSchema, SimpleNodeSchema, SimpleTreeSchema } from "./simpleSchema.js";
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import type { SchemaType, SimpleAllowedTypes, SimpleFieldSchema, SimpleNodeSchema, SimpleTreeSchema } from "./simpleSchema.js";
|
|
10
|
+
/**
|
|
11
|
+
* Maximally restrictive transformation of a view to stored schema.
|
|
12
|
+
* @remarks
|
|
13
|
+
* This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.
|
|
14
|
+
* This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.
|
|
15
|
+
*/
|
|
16
|
+
export declare const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Maximally permissive transformation of a view to stored schema.
|
|
19
|
+
* @remarks
|
|
20
|
+
* This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.
|
|
21
|
+
* This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.
|
|
22
|
+
*
|
|
23
|
+
* This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.
|
|
24
|
+
*
|
|
25
|
+
* TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.
|
|
26
|
+
* If done, then this could take in an existing stored schema, and attempt to generate a valid superset.
|
|
27
|
+
* This could be useful to use as the schema for unhydrated content cloned from hydrated content.
|
|
28
|
+
*/
|
|
29
|
+
export declare const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions;
|
|
13
30
|
/**
|
|
14
31
|
* Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.
|
|
15
32
|
*
|
|
@@ -41,7 +58,23 @@ export declare const toUnhydratedSchema: StoredFromViewSchemaGenerationOptions;
|
|
|
41
58
|
* @throws
|
|
42
59
|
* Throws a `UsageError` if multiple schemas are encountered with the same identifier.
|
|
43
60
|
*/
|
|
44
|
-
export declare function toStoredSchema(root: ImplicitFieldSchema, options:
|
|
61
|
+
export declare function toStoredSchema(root: ImplicitFieldSchema, options: StoredFromViewSchemaGenerationOptions): TreeStoredSchema;
|
|
62
|
+
/**
|
|
63
|
+
* Converts a {@link SimpleTreeSchema} from `SchemaType.View` to `SchemaType.Stored`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function transformSimpleSchema(schema: SimpleTreeSchema<SchemaType.View>, options: StoredFromViewSchemaGenerationOptions): SimpleTreeSchema<SchemaType.Stored>;
|
|
66
|
+
/**
|
|
67
|
+
* Copies a `SchemaType.Stored` {@link SimpleTreeSchema}.
|
|
68
|
+
*/
|
|
69
|
+
export declare function transformSimpleSchema(schema: SimpleTreeSchema<SchemaType.Stored>, options: ExpectStored): SimpleTreeSchema<SchemaType.Stored>;
|
|
70
|
+
/**
|
|
71
|
+
* Copies a {@link SimpleTreeSchema}.
|
|
72
|
+
*/
|
|
73
|
+
export declare function transformSimpleSchema<T extends SchemaType>(schema: SimpleTreeSchema<T>, options: Unchanged): SimpleTreeSchema<T>;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a {@link SimpleTreeSchema}.
|
|
76
|
+
*/
|
|
77
|
+
export declare function transformSimpleSchema(schema: SimpleTreeSchema, options: SimpleSchemaTransformationOptions): SimpleTreeSchema;
|
|
45
78
|
/**
|
|
46
79
|
* Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.
|
|
47
80
|
* @remarks
|
|
@@ -50,11 +83,11 @@ export declare function toStoredSchema(root: ImplicitFieldSchema, options: Store
|
|
|
50
83
|
* To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.
|
|
51
84
|
* @see {@link ExpectStored}.
|
|
52
85
|
*/
|
|
53
|
-
export declare function simpleStoredSchemaToStoredSchema(treeSchema: SimpleTreeSchema): TreeStoredSchema;
|
|
86
|
+
export declare function simpleStoredSchemaToStoredSchema(treeSchema: SimpleTreeSchema<SchemaType.Stored>): TreeStoredSchema;
|
|
54
87
|
/**
|
|
55
88
|
* Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.
|
|
56
89
|
*/
|
|
57
|
-
export declare function convertField(schema: SimpleFieldSchema
|
|
90
|
+
export declare function convertField(schema: SimpleFieldSchema<SchemaType.Stored>): TreeFieldStoredSchema;
|
|
58
91
|
/**
|
|
59
92
|
* A map that converts {@link FieldKind} to {@link FlexFieldKind}.
|
|
60
93
|
*/
|
|
@@ -64,6 +97,20 @@ export declare const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind>;
|
|
|
64
97
|
* @privateRemarks
|
|
65
98
|
* TODO: Persist node metadata once schema FormatV2 is supported.
|
|
66
99
|
*/
|
|
67
|
-
export declare function getStoredSchema(schema: SimpleNodeSchema
|
|
68
|
-
|
|
100
|
+
export declare function getStoredSchema(schema: SimpleNodeSchema<SchemaType.Stored>): TreeNodeStoredSchema;
|
|
101
|
+
/**
|
|
102
|
+
* Converts a {@link SimpleNodeSchema} from view to stored.
|
|
103
|
+
*/
|
|
104
|
+
export declare function transformSimpleNodeSchema(schema: SimpleNodeSchema<SchemaType.View>, options: StoredFromViewSchemaGenerationOptions): SimpleNodeSchema<SchemaType.Stored>;
|
|
105
|
+
/**
|
|
106
|
+
* Converts a {@link SimpleNodeSchema}.
|
|
107
|
+
*/
|
|
108
|
+
export declare function transformSimpleNodeSchema(schema: SimpleNodeSchema, options: SimpleSchemaTransformationOptions): SimpleNodeSchema;
|
|
109
|
+
/**
|
|
110
|
+
* Converts a {@link SimpleAllowedTypes} to a stored schema.
|
|
111
|
+
* @param schema - The schema to convert.
|
|
112
|
+
* @param options - The options to use for filtering.
|
|
113
|
+
* @returns The converted stored schema.
|
|
114
|
+
*/
|
|
115
|
+
export declare function filterAllowedTypes(schema: SimpleAllowedTypes, options: SimpleSchemaTransformationOptions): SimpleAllowedTypes;
|
|
69
116
|
//# sourceMappingURL=toStoredSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"toStoredSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAON,KAAK,qBAAqB,EAE1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAS/E,OAAO,EACN,YAAY,EAEZ,SAAS,EACT,KAAK,iCAAiC,EACtC,KAAK,qCAAqC,EAE1C,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAwB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,KAAK,EACX,UAAU,EAEV,kBAAkB,EAElB,iBAAiB,EAGjB,gB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CAAC,GAC7C,gBAAgB,CAQlB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,iBAAiB,CAAC,UAAU,CAAC,MAAM,CAAC,GAC1C,qBAAqB,CAKvB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,SAAS,EAAE,aAAa,CAOjE,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,GACzC,oBAAoB,CAiCtB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,EACzC,OAAO,EAAE,qCAAqC,GAC5C,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAEvC;;GAEG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,iCAAiC,GACxC,gBAAgB,CAAC;AAoEpB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,iCAAiC,GACxC,kBAAkB,CAUpB"}
|
|
@@ -2,18 +2,40 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { unreachableCase, fail, transformMapValues, } from "@fluidframework/core-utils/internal";
|
|
5
|
+
import { unreachableCase, fail, transformMapValues, assert, } from "@fluidframework/core-utils/internal";
|
|
6
6
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
7
|
import { EmptyKey, LeafNodeStoredSchema, MapNodeStoredSchema, ObjectNodeStoredSchema, } from "../core/index.js";
|
|
8
8
|
import { FieldKinds } from "../feature-libraries/index.js";
|
|
9
|
-
import { brand, getOrCreate } from "../util/index.js";
|
|
10
|
-
import {
|
|
9
|
+
import { brand, filterIterable, getOrCreate, mapIterable, } from "../util/index.js";
|
|
10
|
+
import { ExpectStored, NodeKind, Unchanged, } from "./core/index.js";
|
|
11
11
|
import { FieldKind, normalizeFieldSchema } from "./fieldSchema.js";
|
|
12
|
-
import {
|
|
12
|
+
import { createTreeSchema } from "./treeSchema.js";
|
|
13
|
+
// TODO: this file, src/simple-tree/api/storedSchema.ts and src/simple-tree/core/toStored.ts should be refactored to group the logic more logically.
|
|
14
|
+
// The content of src/simple-tree/api/storedSchema.ts should probably removed from the API surface, replaced by simple schema snapshotting APIs.
|
|
15
|
+
// The logic from this file for converting stored-simple-schema to the persisted format can be moved to its own file.
|
|
16
|
+
// The simple-schema related logic from this file and src/simple-tree/core/toStored.ts can be unified and `toStoredSchema` and its other ImplicitFieldSchema consuming variants should probably be removed in favor of acting on TreeSchema and SimpleTreeSchema directly.
|
|
13
17
|
const viewToStoredCache = new WeakMap();
|
|
18
|
+
/**
|
|
19
|
+
* Maximally restrictive transformation of a view to stored schema.
|
|
20
|
+
* @remarks
|
|
21
|
+
* This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.
|
|
22
|
+
* This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.
|
|
23
|
+
*/
|
|
14
24
|
export const restrictiveStoredSchemaGenerationOptions = {
|
|
15
25
|
includeStaged: () => false,
|
|
16
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Maximally permissive transformation of a view to stored schema.
|
|
29
|
+
* @remarks
|
|
30
|
+
* This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.
|
|
31
|
+
* This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.
|
|
32
|
+
*
|
|
33
|
+
* This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.
|
|
34
|
+
*
|
|
35
|
+
* TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.
|
|
36
|
+
* If done, then this could take in an existing stored schema, and attempt to generate a valid superset.
|
|
37
|
+
* This could be useful to use as the schema for unhydrated content cloned from hydrated content.
|
|
38
|
+
*/
|
|
17
39
|
export const permissiveStoredSchemaGenerationOptions = {
|
|
18
40
|
includeStaged: () => true,
|
|
19
41
|
};
|
|
@@ -55,25 +77,49 @@ export const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;
|
|
|
55
77
|
export function toStoredSchema(root, options) {
|
|
56
78
|
const cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());
|
|
57
79
|
return getOrCreate(cache, root, () => {
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
node(schema) {
|
|
62
|
-
if (nodeSchema.has(brand(schema.identifier))) {
|
|
63
|
-
// Use JSON.stringify to quote and escape identifier string.
|
|
64
|
-
throw new UsageError(`Multiple schema encountered with the identifier ${JSON.stringify(schema.identifier)}. Remove or rename them to avoid the collision.`);
|
|
65
|
-
}
|
|
66
|
-
nodeSchema.set(brand(schema.identifier), getStoredSchema(schema, options));
|
|
67
|
-
},
|
|
68
|
-
allowedTypeFilter: (allowedType) => allowedTypeFilter({ isStaged: allowedType.metadata.stagedSchemaUpgrade ?? false }, options),
|
|
69
|
-
});
|
|
70
|
-
const result = {
|
|
71
|
-
nodeSchema,
|
|
72
|
-
rootFieldSchema: convertField(normalized, options),
|
|
73
|
-
};
|
|
74
|
-
return result;
|
|
80
|
+
const treeSchema = createTreeSchema(normalizeFieldSchema(root));
|
|
81
|
+
const simpleSchema = transformSimpleSchema(treeSchema, options);
|
|
82
|
+
return simpleStoredSchemaToStoredSchema(simpleSchema);
|
|
75
83
|
});
|
|
76
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if
|
|
87
|
+
* a staged allowed type has been upgraded and if so, include it in the conversion.
|
|
88
|
+
*/
|
|
89
|
+
export function transformSimpleSchema(schema, options) {
|
|
90
|
+
const simpleNodeSchema = new Map();
|
|
91
|
+
const root = filterFieldAllowedTypes(schema.root, options);
|
|
92
|
+
const queue = Array.from(root.simpleAllowedTypes.keys());
|
|
93
|
+
for (const identifier of queue) {
|
|
94
|
+
getOrCreate(simpleNodeSchema, identifier, (id) => {
|
|
95
|
+
const nodeSchema = schema.definitions.get(id) ?? fail(0xca8 /* missing schema */);
|
|
96
|
+
const transformed = transformSimpleNodeSchema(nodeSchema, options);
|
|
97
|
+
const kind = transformed.kind;
|
|
98
|
+
switch (kind) {
|
|
99
|
+
case NodeKind.Leaf:
|
|
100
|
+
break;
|
|
101
|
+
case NodeKind.Array:
|
|
102
|
+
case NodeKind.Map:
|
|
103
|
+
case NodeKind.Record:
|
|
104
|
+
queue.push(...transformed.simpleAllowedTypes.keys());
|
|
105
|
+
break;
|
|
106
|
+
case NodeKind.Object:
|
|
107
|
+
for (const fieldSchema of transformed.fields.values()) {
|
|
108
|
+
queue.push(...fieldSchema.simpleAllowedTypes.keys());
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
unreachableCase(kind);
|
|
113
|
+
}
|
|
114
|
+
return transformed;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// Copy simpleNodeSchema, but in the order from the original schema.definitions
|
|
118
|
+
// Currently we do not specify anything about the order of definitions, but it is nicer to have a stable order and some tests rely on it.
|
|
119
|
+
const definitions = new Map(mapIterable(filterIterable(schema.definitions.keys(), (id) => simpleNodeSchema.has(id)), (id) => [id, simpleNodeSchema.get(id) ?? fail(0xca9 /* missing schema */)]));
|
|
120
|
+
assert(definitions.size === simpleNodeSchema.size, 0xcaa /* Reachable schema missing from input TreeSchema */);
|
|
121
|
+
return { root, definitions };
|
|
122
|
+
}
|
|
77
123
|
/**
|
|
78
124
|
* Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.
|
|
79
125
|
* @remarks
|
|
@@ -84,17 +130,17 @@ export function toStoredSchema(root, options) {
|
|
|
84
130
|
*/
|
|
85
131
|
export function simpleStoredSchemaToStoredSchema(treeSchema) {
|
|
86
132
|
const result = {
|
|
87
|
-
nodeSchema: transformMapValues(treeSchema.definitions, (schema) => getStoredSchema(schema
|
|
88
|
-
rootFieldSchema: convertField(treeSchema.root
|
|
133
|
+
nodeSchema: transformMapValues(treeSchema.definitions, (schema) => getStoredSchema(schema)),
|
|
134
|
+
rootFieldSchema: convertField(treeSchema.root),
|
|
89
135
|
};
|
|
90
136
|
return result;
|
|
91
137
|
}
|
|
92
138
|
/**
|
|
93
139
|
* Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.
|
|
94
140
|
*/
|
|
95
|
-
export function convertField(schema
|
|
141
|
+
export function convertField(schema) {
|
|
96
142
|
const kind = convertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);
|
|
97
|
-
const types = convertAllowedTypes(schema.simpleAllowedTypes
|
|
143
|
+
const types = convertAllowedTypes(schema.simpleAllowedTypes);
|
|
98
144
|
return { kind, types, persistedMetadata: schema.persistedMetadata };
|
|
99
145
|
}
|
|
100
146
|
/**
|
|
@@ -110,7 +156,7 @@ export const convertFieldKind = new Map([
|
|
|
110
156
|
* @privateRemarks
|
|
111
157
|
* TODO: Persist node metadata once schema FormatV2 is supported.
|
|
112
158
|
*/
|
|
113
|
-
export function getStoredSchema(schema
|
|
159
|
+
export function getStoredSchema(schema) {
|
|
114
160
|
const kind = schema.kind;
|
|
115
161
|
switch (kind) {
|
|
116
162
|
case NodeKind.Leaf: {
|
|
@@ -118,7 +164,7 @@ export function getStoredSchema(schema, options) {
|
|
|
118
164
|
}
|
|
119
165
|
case NodeKind.Map:
|
|
120
166
|
case NodeKind.Record: {
|
|
121
|
-
const types = convertAllowedTypes(schema.simpleAllowedTypes
|
|
167
|
+
const types = convertAllowedTypes(schema.simpleAllowedTypes);
|
|
122
168
|
return new MapNodeStoredSchema({
|
|
123
169
|
kind: FieldKinds.optional.identifier,
|
|
124
170
|
types,
|
|
@@ -128,12 +174,12 @@ export function getStoredSchema(schema, options) {
|
|
|
128
174
|
schema.persistedMetadata);
|
|
129
175
|
}
|
|
130
176
|
case NodeKind.Array: {
|
|
131
|
-
return arrayNodeStoredSchema(schema.simpleAllowedTypes,
|
|
177
|
+
return arrayNodeStoredSchema(schema.simpleAllowedTypes, schema.persistedMetadata);
|
|
132
178
|
}
|
|
133
179
|
case NodeKind.Object: {
|
|
134
180
|
const fields = new Map();
|
|
135
181
|
for (const fieldSchema of schema.fields.values()) {
|
|
136
|
-
fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema
|
|
182
|
+
fields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));
|
|
137
183
|
}
|
|
138
184
|
return new ObjectNodeStoredSchema(fields, schema.persistedMetadata);
|
|
139
185
|
}
|
|
@@ -142,13 +188,140 @@ export function getStoredSchema(schema, options) {
|
|
|
142
188
|
}
|
|
143
189
|
}
|
|
144
190
|
}
|
|
145
|
-
|
|
191
|
+
/**
|
|
192
|
+
* TODO: Persist node metadata once schema FormatV2 is supported.
|
|
193
|
+
*
|
|
194
|
+
* This is only exported for use by tests: if other users need them more overloads could be provided, but this is currently sufficient.
|
|
195
|
+
*/
|
|
196
|
+
export function transformSimpleNodeSchema(schema, options) {
|
|
197
|
+
const metadata = {
|
|
198
|
+
persistedMetadata: schema.persistedMetadata,
|
|
199
|
+
metadata: preservesViewData(options)
|
|
200
|
+
? {
|
|
201
|
+
custom: schema.metadata.custom,
|
|
202
|
+
description: schema.metadata.description,
|
|
203
|
+
}
|
|
204
|
+
: {},
|
|
205
|
+
};
|
|
206
|
+
const kind = schema.kind;
|
|
207
|
+
switch (kind) {
|
|
208
|
+
case NodeKind.Leaf: {
|
|
209
|
+
return {
|
|
210
|
+
kind,
|
|
211
|
+
leafKind: schema.leafKind,
|
|
212
|
+
...metadata,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
case NodeKind.Array:
|
|
216
|
+
case NodeKind.Map:
|
|
217
|
+
case NodeKind.Record: {
|
|
218
|
+
return {
|
|
219
|
+
kind,
|
|
220
|
+
...metadata,
|
|
221
|
+
simpleAllowedTypes: filterAllowedTypes(schema.simpleAllowedTypes, options),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
case NodeKind.Object: {
|
|
225
|
+
return {
|
|
226
|
+
kind,
|
|
227
|
+
...metadata,
|
|
228
|
+
fields: transformMapValues(schema.fields, (f) => ({
|
|
229
|
+
...filterFieldAllowedTypes(f, options),
|
|
230
|
+
storedKey: f.storedKey,
|
|
231
|
+
})),
|
|
232
|
+
allowUnknownOptionalFields: filterViewData(options, schema.allowUnknownOptionalFields),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
default: {
|
|
236
|
+
unreachableCase(kind);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function arrayNodeStoredSchema(schema, persistedMetadata) {
|
|
146
241
|
const field = {
|
|
147
242
|
kind: FieldKinds.sequence.identifier,
|
|
148
|
-
types: convertAllowedTypes(schema
|
|
243
|
+
types: convertAllowedTypes(schema),
|
|
149
244
|
persistedMetadata,
|
|
150
245
|
};
|
|
151
246
|
const fields = new Map([[EmptyKey, field]]);
|
|
152
247
|
return new ObjectNodeStoredSchema(fields, persistedMetadata);
|
|
153
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Converts a {@link SimpleAllowedTypes} to a stored schema.
|
|
251
|
+
* @param schema - The schema to convert.
|
|
252
|
+
* @param options - The options to use for filtering.
|
|
253
|
+
* @returns The converted stored schema.
|
|
254
|
+
*/
|
|
255
|
+
export function filterAllowedTypes(schema, options) {
|
|
256
|
+
const filtered = new Map();
|
|
257
|
+
for (const [type, data] of schema) {
|
|
258
|
+
if (options === Unchanged) {
|
|
259
|
+
filtered.set(type, { isStaged: data.isStaged });
|
|
260
|
+
}
|
|
261
|
+
else if (allowedTypeFilter(data, options)) {
|
|
262
|
+
filtered.set(type, { isStaged: undefined });
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return filtered;
|
|
266
|
+
}
|
|
267
|
+
function filterFieldAllowedTypes(f, options) {
|
|
268
|
+
return {
|
|
269
|
+
kind: f.kind,
|
|
270
|
+
persistedMetadata: f.persistedMetadata,
|
|
271
|
+
metadata: preservesViewData(options)
|
|
272
|
+
? {
|
|
273
|
+
custom: f.metadata.custom,
|
|
274
|
+
description: f.metadata.description,
|
|
275
|
+
}
|
|
276
|
+
: {},
|
|
277
|
+
simpleAllowedTypes: filterAllowedTypes(f.simpleAllowedTypes, options),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Converts a stored {@link SimpleAllowedTypes} to a {@link TreeTypeSet}.
|
|
282
|
+
*/
|
|
283
|
+
function convertAllowedTypes(schema) {
|
|
284
|
+
return new Set(schema.keys());
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Filters an allowed type based on the provided options.
|
|
288
|
+
* @param allowedType - The allowed type to filter.
|
|
289
|
+
* @param options - The options to use for filtering.
|
|
290
|
+
* @returns Whether the allowed type passes the filter.
|
|
291
|
+
*/
|
|
292
|
+
function allowedTypeFilter(data, options) {
|
|
293
|
+
if (options === ExpectStored) {
|
|
294
|
+
if (data.isStaged !== undefined) {
|
|
295
|
+
throw new UsageError("Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StoredFromViewSchemaGenerationOptions` to process.");
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
if (data.isStaged === undefined) {
|
|
300
|
+
throw new UsageError("Failed to covert view schema to stored schema. The simple schema provided as the view schema was actually a stored schema. If this was intended, use `ExpectStored` for the `StoredSchemaGenerationOptions` to indicate the input is already a stored schema and only a format conversion is required.");
|
|
301
|
+
}
|
|
302
|
+
// If the allowed type is staged, only include it if the options allow it.
|
|
303
|
+
if (data.isStaged === false) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
return options.includeStaged(data.isStaged);
|
|
307
|
+
}
|
|
308
|
+
function isStoredFromView(options) {
|
|
309
|
+
return typeof options === "object" && "includeStaged" in options;
|
|
310
|
+
}
|
|
311
|
+
function filterViewData(options, data) {
|
|
312
|
+
return preservesViewData(options) ? data : undefined;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Determines if the provided options indicate that view specific data should be preserved.
|
|
316
|
+
* @remarks
|
|
317
|
+
* This assumes that stored simple schema should not contain view specific data.
|
|
318
|
+
* Therefore the only case where what this returns should matter is when the input schema is view schema
|
|
319
|
+
* (and thus there might be view specific data).
|
|
320
|
+
*/
|
|
321
|
+
function preservesViewData(options) {
|
|
322
|
+
// As noted above in the doc comment, the only case we care about the return value is when the input is a view schema.
|
|
323
|
+
// There are two such cases: isStoredFromView where we return false, and Unchanged when applied to a view schema, where we return true.
|
|
324
|
+
// It does not matter what we return in other cases, so for simplicity they just end up as "true".
|
|
325
|
+
return isStoredFromView(options) ? false : true;
|
|
326
|
+
}
|
|
154
327
|
//# sourceMappingURL=toStoredSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,IAAI,EACJ,kBAAkB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EACN,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GAOtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAsB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqC,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,QAAQ,GAIR,MAAM,iBAAiB,CAAC;AACzB,OAA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MAAM,EAAE,EAAE,CAAC;gBAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAC9E,CAAC;YACD,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACT,eAAe,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,MAA0B,EAC1B,OAAsC,EACtC,iBAA2D;IAE3D,MAAM,KAAK,GAAG;QACb,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU;QACpC,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC;QAC3C,iBAAiB;KACjB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,IAAI,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tunreachableCase,\n\tfail,\n\ttransformMapValues,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport { brand, getOrCreate, type JsonCompatibleReadOnlyObject } from \"../util/index.js\";\n\nimport {\n\tallowedTypeFilter,\n\tconvertAllowedTypes,\n\tExpectStored,\n\tNodeKind,\n\ttype SimpleNodeSchemaBase,\n\ttype StoredFromViewSchemaGenerationOptions,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport type {\n\tSimpleAllowedTypes,\n\tSimpleFieldSchema,\n\tSimpleNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { walkFieldSchema } from \"./walkFieldSchema.js\";\n\nconst viewToStoredCache = new WeakMap<\n\tStoredFromViewSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\nexport const restrictiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => false,\n};\n\nexport const permissiveStoredSchemaGenerationOptions: StoredSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * Even if this took in a SimpleTreeSchema,\n * it would still need to walk the schema to avoid including schema that become unreachable due to filtered out staged schema.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitFieldSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst normalized = normalizeFieldSchema(root);\n\t\tconst nodeSchema: Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema> = new Map();\n\t\twalkFieldSchema(normalized, {\n\t\t\tnode(schema) {\n\t\t\t\tif (nodeSchema.has(brand(schema.identifier))) {\n\t\t\t\t\t// Use JSON.stringify to quote and escape identifier string.\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t`Multiple schema encountered with the identifier ${JSON.stringify(\n\t\t\t\t\t\t\tschema.identifier,\n\t\t\t\t\t\t)}. Remove or rename them to avoid the collision.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tnodeSchema.set(\n\t\t\t\t\tbrand(schema.identifier),\n\t\t\t\t\tgetStoredSchema(\n\t\t\t\t\t\tschema as SimpleNodeSchemaBase<NodeKind> as SimpleNodeSchema,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t\tallowedTypeFilter: (allowedType) =>\n\t\t\t\tallowedTypeFilter(\n\t\t\t\t\t{ isStaged: allowedType.metadata.stagedSchemaUpgrade ?? false },\n\t\t\t\t\toptions,\n\t\t\t\t),\n\t\t});\n\n\t\tconst result: TreeStoredSchema = {\n\t\t\tnodeSchema,\n\t\t\trootFieldSchema: convertField(normalized, options),\n\t\t};\n\t\treturn result;\n\t});\n}\n\n/**\n * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.\n * @remarks\n * This only supports simple schemas that are already logically stored schemas.\n * @privateRemarks\n * To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.\n * @see {@link ExpectStored}.\n */\nexport function simpleStoredSchemaToStoredSchema(\n\ttreeSchema: SimpleTreeSchema,\n): TreeStoredSchema {\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema: transformMapValues(treeSchema.definitions, (schema) =>\n\t\t\tgetStoredSchema(schema, ExpectStored),\n\t\t) as Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t\trootFieldSchema: convertField(treeSchema.root, ExpectStored),\n\t};\n\treturn result;\n}\n\n/**\n * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types = convertAllowedTypes(schema.simpleAllowedTypes, options);\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema,\n\toptions: StoredSchemaGenerationOptions,\n): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = convertAllowedTypes(schema.simpleAllowedTypes, options);\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn arrayNodeStoredSchema(\n\t\t\t\tschema.simpleAllowedTypes,\n\t\t\t\toptions,\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema, options));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nexport function arrayNodeStoredSchema(\n\tschema: SimpleAllowedTypes,\n\toptions: StoredSchemaGenerationOptions,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes: convertAllowedTypes(schema, options),\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"toStoredSchema.js","sourceRoot":"","sources":["../../src/simple-tree/toStoredSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,IAAI,EACJ,kBAAkB,EAClB,MAAM,GACN,MAAM,q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,CACnQ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,IAAI,UAAU,CACnB,wSAAwS,CACxS,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,gBAAgB,CACxB,OAA0C;IAE1C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,eAAe,IAAI,OAAO,CAAC;AAClE,CAAC;AAED,SAAS,cAAc,CACtB,OAA0C,EAC1C,IAAO;IAEP,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,OAA0C;IACpE,sHAAsH;IACtH,uIAAuI;IACvI,kGAAkG;IAClG,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tunreachableCase,\n\tfail,\n\ttransformMapValues,\n\tassert,\n} from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tEmptyKey,\n\tLeafNodeStoredSchema,\n\tMapNodeStoredSchema,\n\tObjectNodeStoredSchema,\n\ttype FieldKey,\n\ttype FieldKindIdentifier,\n\ttype TreeFieldStoredSchema,\n\ttype TreeNodeSchemaIdentifier,\n\ttype TreeNodeStoredSchema,\n\ttype TreeStoredSchema,\n\ttype TreeTypeSet,\n} from \"../core/index.js\";\nimport { FieldKinds, type FlexFieldKind } from \"../feature-libraries/index.js\";\nimport {\n\tbrand,\n\tfilterIterable,\n\tgetOrCreate,\n\tmapIterable,\n\ttype JsonCompatibleReadOnlyObject,\n} from \"../util/index.js\";\n\nimport {\n\tExpectStored,\n\tNodeKind,\n\tUnchanged,\n\ttype SimpleSchemaTransformationOptions,\n\ttype StoredFromViewSchemaGenerationOptions,\n\ttype StoredSchemaGenerationOptions,\n} from \"./core/index.js\";\nimport { FieldKind, normalizeFieldSchema, type ImplicitFieldSchema } from \"./fieldSchema.js\";\nimport type {\n\tSchemaType,\n\tSimpleAllowedTypeAttributes,\n\tSimpleAllowedTypes,\n\tSimpleArrayNodeSchema,\n\tSimpleFieldSchema,\n\tSimpleLeafNodeSchema,\n\tSimpleMapNodeSchema,\n\tSimpleNodeSchema,\n\tSimpleObjectNodeSchema,\n\tSimpleRecordNodeSchema,\n\tSimpleTreeSchema,\n} from \"./simpleSchema.js\";\nimport { createTreeSchema } from \"./treeSchema.js\";\n\n// TODO: this file, src/simple-tree/api/storedSchema.ts and src/simple-tree/core/toStored.ts should be refactored to group the logic more logically.\n// The content of src/simple-tree/api/storedSchema.ts should probably removed from the API surface, replaced by simple schema snapshotting APIs.\n// The logic from this file for converting stored-simple-schema to the persisted format can be moved to its own file.\n// The simple-schema related logic from this file and src/simple-tree/core/toStored.ts can be unified and `toStoredSchema` and its other ImplicitFieldSchema consuming variants should probably be removed in favor of acting on TreeSchema and SimpleTreeSchema directly.\n\nconst viewToStoredCache = new WeakMap<\n\tStoredFromViewSchemaGenerationOptions,\n\tWeakMap<ImplicitFieldSchema, TreeStoredSchema>\n>();\n\n/**\n * Maximally restrictive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema is as restrictive as possible while still being compatible with the input view schema.\n * This is typically used for cases where backwards compatibility with past versions of an application is required, like {@link toUpgradeSchema} or {@link toInitialSchema}.\n */\nexport const restrictiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions =\n\t{\n\t\tincludeStaged: () => false,\n\t};\n\n/**\n * Maximally permissive transformation of a view to stored schema.\n * @remarks\n * This should only be used when the intent is to produce a stored schema which allows as much as possible while still being compatible with the input view schema.\n * This is typically used for cases where forwards compatibility with future versions of an application is required, like {@link toUnhydratedSchema}.\n *\n * This is unable to include unknown optional fields in the output, which makes it not truly maximally permissive.\n *\n * TODO: {@link StoredFromViewSchemaGenerationOptions} could be updated to allow a way to inject extra optional fields.\n * If done, then this could take in an existing stored schema, and attempt to generate a valid superset.\n * This could be useful to use as the schema for unhydrated content cloned from hydrated content.\n */\nexport const permissiveStoredSchemaGenerationOptions: StoredFromViewSchemaGenerationOptions = {\n\tincludeStaged: () => true,\n};\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use in schema upgrades.\n *\n * TODO: once upgrades are more flexible, this should take in more options, including the old schema and specific upgrades to enable.\n */\nexport function toUpgradeSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} for use as initial document schema.\n */\nexport function toInitialSchema(root: ImplicitFieldSchema): TreeStoredSchema {\n\treturn toStoredSchema(root, restrictiveStoredSchemaGenerationOptions);\n}\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema} to used for unhydrated nodes.\n * @remarks\n * This allows as much as possible, relying on further validation when inserting the content.\n *\n * TODO: this should get additional options to enable support for unknown optional fields.\n */\nexport const toUnhydratedSchema = permissiveStoredSchemaGenerationOptions;\n\n/**\n * Converts a {@link ImplicitFieldSchema} into a {@link TreeStoredSchema}.\n *\n * @privateRemarks\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n *\n * Even if this took in a SimpleTreeSchema,\n * it would still need to walk the schema to avoid including schema that become unreachable due to filtered out staged schema.\n *\n * @throws\n * Throws a `UsageError` if multiple schemas are encountered with the same identifier.\n */\nexport function toStoredSchema(\n\troot: ImplicitFieldSchema,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): TreeStoredSchema {\n\tconst cache = getOrCreate(viewToStoredCache, options, () => new WeakMap());\n\treturn getOrCreate(cache, root, () => {\n\t\tconst treeSchema = createTreeSchema(normalizeFieldSchema(root));\n\t\tconst simpleSchema = transformSimpleSchema(treeSchema, options);\n\t\treturn simpleStoredSchemaToStoredSchema(simpleSchema);\n\t});\n}\n\n/**\n * Converts a {@link SimpleTreeSchema} from `SchemaType.View` to `SchemaType.Stored`.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a `SchemaType.Stored` {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema<SchemaType.Stored>,\n\toptions: ExpectStored,\n): SimpleTreeSchema<SchemaType.Stored>;\n\n/**\n * Copies a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema<T extends SchemaType>(\n\tschema: SimpleTreeSchema<T>,\n\toptions: Unchanged,\n): SimpleTreeSchema<T>;\n\n/**\n * Converts a {@link SimpleTreeSchema}.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema;\n\n/**\n * TODO:#38722 When runtime schema upgrades are implemented, this will need to be updated to check if\n * a staged allowed type has been upgraded and if so, include it in the conversion.\n */\nexport function transformSimpleSchema(\n\tschema: SimpleTreeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleTreeSchema {\n\tconst simpleNodeSchema = new Map<string, SimpleNodeSchema>();\n\tconst root = filterFieldAllowedTypes(schema.root, options);\n\tconst queue = Array.from(root.simpleAllowedTypes.keys());\n\tfor (const identifier of queue) {\n\t\tgetOrCreate(simpleNodeSchema, identifier, (id) => {\n\t\t\tconst nodeSchema = schema.definitions.get(id) ?? fail(0xca8 /* missing schema */);\n\t\t\tconst transformed = transformSimpleNodeSchema(nodeSchema, options);\n\t\t\tconst kind = transformed.kind;\n\t\t\tswitch (kind) {\n\t\t\t\tcase NodeKind.Leaf:\n\t\t\t\t\tbreak;\n\t\t\t\tcase NodeKind.Array:\n\t\t\t\tcase NodeKind.Map:\n\t\t\t\tcase NodeKind.Record:\n\t\t\t\t\tqueue.push(...transformed.simpleAllowedTypes.keys());\n\t\t\t\t\tbreak;\n\t\t\t\tcase NodeKind.Object:\n\t\t\t\t\tfor (const fieldSchema of transformed.fields.values()) {\n\t\t\t\t\t\tqueue.push(...fieldSchema.simpleAllowedTypes.keys());\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tunreachableCase(kind);\n\t\t\t}\n\t\t\treturn transformed;\n\t\t});\n\t}\n\t// Copy simpleNodeSchema, but in the order from the original schema.definitions\n\t// Currently we do not specify anything about the order of definitions, but it is nicer to have a stable order and some tests rely on it.\n\tconst definitions = new Map<string, SimpleNodeSchema>(\n\t\tmapIterable(\n\t\t\tfilterIterable(schema.definitions.keys(), (id) => simpleNodeSchema.has(id)),\n\t\t\t(id) => [id, simpleNodeSchema.get(id) ?? fail(0xca9 /* missing schema */)],\n\t\t),\n\t);\n\tassert(\n\t\tdefinitions.size === simpleNodeSchema.size,\n\t\t0xcaa /* Reachable schema missing from input TreeSchema */,\n\t);\n\treturn { root, definitions };\n}\n\n/**\n * Convert a {@link SimpleTreeSchema} for a stored schema into a {@link TreeStoredSchema}.\n * @remarks\n * This only supports simple schemas that are already logically stored schemas.\n * @privateRemarks\n * To correctly support view schema here, this would need to filter out unreferenced schema after excluding staged schema.\n * @see {@link ExpectStored}.\n */\nexport function simpleStoredSchemaToStoredSchema(\n\ttreeSchema: SimpleTreeSchema<SchemaType.Stored>,\n): TreeStoredSchema {\n\tconst result: TreeStoredSchema = {\n\t\tnodeSchema: transformMapValues(treeSchema.definitions, (schema) =>\n\t\t\tgetStoredSchema(schema),\n\t\t) as Map<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>,\n\t\trootFieldSchema: convertField(treeSchema.root),\n\t};\n\treturn result;\n}\n\n/**\n * Convert a {@link SimpleFieldSchema} into a {@link TreeFieldStoredSchema}.\n */\nexport function convertField(\n\tschema: SimpleFieldSchema<SchemaType.Stored>,\n): TreeFieldStoredSchema {\n\tconst kind: FieldKindIdentifier =\n\t\tconvertFieldKind.get(schema.kind)?.identifier ?? fail(0xae3 /* Invalid field kind */);\n\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\treturn { kind, types, persistedMetadata: schema.persistedMetadata };\n}\n\n/**\n * A map that converts {@link FieldKind} to {@link FlexFieldKind}.\n */\nexport const convertFieldKind: ReadonlyMap<FieldKind, FlexFieldKind> = new Map<\n\tFieldKind,\n\tFlexFieldKind\n>([\n\t[FieldKind.Optional, FieldKinds.optional],\n\t[FieldKind.Required, FieldKinds.required],\n\t[FieldKind.Identifier, FieldKinds.identifier],\n]);\n\n/**\n * Converts a {@link TreeNodeSchema} into a {@link TreeNodeStoredSchema}.\n * @privateRemarks\n * TODO: Persist node metadata once schema FormatV2 is supported.\n */\nexport function getStoredSchema(\n\tschema: SimpleNodeSchema<SchemaType.Stored>,\n): TreeNodeStoredSchema {\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn new LeafNodeStoredSchema(schema.leafKind);\n\t\t}\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\tconst types = convertAllowedTypes(schema.simpleAllowedTypes);\n\t\t\treturn new MapNodeStoredSchema(\n\t\t\t\t{\n\t\t\t\t\tkind: FieldKinds.optional.identifier,\n\t\t\t\t\ttypes,\n\t\t\t\t\tpersistedMetadata: schema.persistedMetadata,\n\t\t\t\t},\n\t\t\t\t// TODO: Find a way to avoid injecting persistedMetadata twice in these constructor calls.\n\t\t\t\tschema.persistedMetadata,\n\t\t\t);\n\t\t}\n\t\tcase NodeKind.Array: {\n\t\t\treturn arrayNodeStoredSchema(schema.simpleAllowedTypes, schema.persistedMetadata);\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\tconst fields: Map<FieldKey, TreeFieldStoredSchema> = new Map();\n\t\t\tfor (const fieldSchema of schema.fields.values()) {\n\t\t\t\tfields.set(brand(fieldSchema.storedKey), convertField(fieldSchema));\n\t\t\t}\n\t\t\treturn new ObjectNodeStoredSchema(fields, schema.persistedMetadata);\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\n/**\n * Converts a {@link SimpleNodeSchema} from view to stored.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema<SchemaType.View>,\n\toptions: StoredFromViewSchemaGenerationOptions,\n): SimpleNodeSchema<SchemaType.Stored>;\n\n/**\n * Converts a {@link SimpleNodeSchema}.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema;\n\n/**\n * TODO: Persist node metadata once schema FormatV2 is supported.\n *\n * This is only exported for use by tests: if other users need them more overloads could be provided, but this is currently sufficient.\n */\nexport function transformSimpleNodeSchema(\n\tschema: SimpleNodeSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleNodeSchema {\n\tconst metadata = {\n\t\tpersistedMetadata: schema.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: schema.metadata.custom,\n\t\t\t\t\tdescription: schema.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t};\n\tconst kind = schema.kind;\n\tswitch (kind) {\n\t\tcase NodeKind.Leaf: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\tleafKind: schema.leafKind,\n\t\t\t\t...metadata,\n\t\t\t} satisfies SimpleLeafNodeSchema;\n\t\t}\n\t\tcase NodeKind.Array:\n\t\tcase NodeKind.Map:\n\t\tcase NodeKind.Record: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tsimpleAllowedTypes: filterAllowedTypes(schema.simpleAllowedTypes, options),\n\t\t\t} satisfies SimpleMapNodeSchema | SimpleRecordNodeSchema | SimpleArrayNodeSchema;\n\t\t}\n\t\tcase NodeKind.Object: {\n\t\t\treturn {\n\t\t\t\tkind,\n\t\t\t\t...metadata,\n\t\t\t\tfields: transformMapValues(schema.fields, (f) => ({\n\t\t\t\t\t...filterFieldAllowedTypes(f, options),\n\t\t\t\t\tstoredKey: f.storedKey,\n\t\t\t\t})),\n\t\t\t\tallowUnknownOptionalFields: filterViewData(options, schema.allowUnknownOptionalFields),\n\t\t\t} satisfies SimpleObjectNodeSchema;\n\t\t}\n\t\tdefault: {\n\t\t\tunreachableCase(kind);\n\t\t}\n\t}\n}\n\nfunction arrayNodeStoredSchema(\n\tschema: SimpleAllowedTypes<SchemaType.Stored>,\n\tpersistedMetadata: JsonCompatibleReadOnlyObject | undefined,\n): ObjectNodeStoredSchema {\n\tconst field = {\n\t\tkind: FieldKinds.sequence.identifier,\n\t\ttypes: convertAllowedTypes(schema),\n\t\tpersistedMetadata,\n\t};\n\tconst fields = new Map([[EmptyKey, field]]);\n\treturn new ObjectNodeStoredSchema(fields, persistedMetadata);\n}\n\n/**\n * Converts a {@link SimpleAllowedTypes} to a stored schema.\n * @param schema - The schema to convert.\n * @param options - The options to use for filtering.\n * @returns The converted stored schema.\n */\nexport function filterAllowedTypes(\n\tschema: SimpleAllowedTypes,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleAllowedTypes {\n\tconst filtered: Map<string, SimpleAllowedTypeAttributes> = new Map();\n\tfor (const [type, data] of schema) {\n\t\tif (options === Unchanged) {\n\t\t\tfiltered.set(type, { isStaged: data.isStaged });\n\t\t} else if (allowedTypeFilter(data, options)) {\n\t\t\tfiltered.set(type, { isStaged: undefined });\n\t\t}\n\t}\n\treturn filtered;\n}\n\nfunction filterFieldAllowedTypes(\n\tf: SimpleFieldSchema,\n\toptions: SimpleSchemaTransformationOptions,\n): SimpleFieldSchema {\n\treturn {\n\t\tkind: f.kind,\n\t\tpersistedMetadata: f.persistedMetadata,\n\t\tmetadata: preservesViewData(options)\n\t\t\t? {\n\t\t\t\t\tcustom: f.metadata.custom,\n\t\t\t\t\tdescription: f.metadata.description,\n\t\t\t\t}\n\t\t\t: {},\n\t\tsimpleAllowedTypes: filterAllowedTypes(f.simpleAllowedTypes, options),\n\t};\n}\n\n/**\n * Converts a stored {@link SimpleAllowedTypes} to a {@link TreeTypeSet}.\n */\nfunction convertAllowedTypes(schema: SimpleAllowedTypes<SchemaType.Stored>): TreeTypeSet {\n\treturn new Set(schema.keys() as Iterable<TreeNodeSchemaIdentifier>);\n}\n\n/**\n * Filters an allowed type based on the provided options.\n * @param allowedType - The allowed type to filter.\n * @param options - The options to use for filtering.\n * @returns Whether the allowed type passes the filter.\n */\nfunction allowedTypeFilter(\n\tdata: SimpleAllowedTypeAttributes,\n\toptions: StoredSchemaGenerationOptions,\n): boolean {\n\tif (options === ExpectStored) {\n\t\tif (data.isStaged !== undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided was indicated to be a stored schema by the use of `ExpectStored`, but view schema specific content was encountered which requires a `StoredFromViewSchemaGenerationOptions` to process.\",\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (data.isStaged === undefined) {\n\t\tthrow new UsageError(\n\t\t\t\"Failed to covert view schema to stored schema. The simple schema provided as the view schema was actually a stored schema. If this was intended, use `ExpectStored` for the `StoredSchemaGenerationOptions` to indicate the input is already a stored schema and only a format conversion is required.\",\n\t\t);\n\t}\n\n\t// If the allowed type is staged, only include it if the options allow it.\n\tif (data.isStaged === false) {\n\t\treturn true;\n\t}\n\n\treturn options.includeStaged(data.isStaged);\n}\n\nfunction isStoredFromView(\n\toptions: SimpleSchemaTransformationOptions,\n): options is StoredFromViewSchemaGenerationOptions {\n\treturn typeof options === \"object\" && \"includeStaged\" in options;\n}\n\nfunction filterViewData<T>(\n\toptions: SimpleSchemaTransformationOptions,\n\tdata: T,\n): T | undefined {\n\treturn preservesViewData(options) ? data : undefined;\n}\n\n/**\n * Determines if the provided options indicate that view specific data should be preserved.\n * @remarks\n * This assumes that stored simple schema should not contain view specific data.\n * Therefore the only case where what this returns should matter is when the input schema is view schema\n * (and thus there might be view specific data).\n */\nfunction preservesViewData(options: SimpleSchemaTransformationOptions): boolean {\n\t// As noted above in the doc comment, the only case we care about the return value is when the input is a view schema.\n\t// There are two such cases: isStoredFromView where we return false, and Unchanged when applied to a view schema, where we return true.\n\t// It does not matter what we return in other cases, so for simplicity they just end up as \"true\".\n\treturn isStoredFromView(options) ? false : true;\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { TreeNodeSchema } from "./core/index.js";
|
|
6
|
+
import { type FieldSchemaAlpha, type ImplicitFieldSchema } from "./fieldSchema.js";
|
|
7
|
+
import type { SchemaType, SimpleNodeSchema, SimpleTreeSchema } from "./simpleSchema.js";
|
|
8
|
+
export declare function createTreeSchema(rootSchema: ImplicitFieldSchema): TreeSchema;
|
|
9
|
+
/**
|
|
10
|
+
* {@link TreeViewConfigurationAlpha}
|
|
11
|
+
* @sealed @alpha
|
|
12
|
+
*/
|
|
13
|
+
export interface TreeSchema extends SimpleTreeSchema<SchemaType.View> {
|
|
14
|
+
/**
|
|
15
|
+
* {@inheritDoc SimpleTreeSchema.root}
|
|
16
|
+
*/
|
|
17
|
+
readonly root: FieldSchemaAlpha;
|
|
18
|
+
/**
|
|
19
|
+
* {@inheritDoc SimpleTreeSchema.definitions}
|
|
20
|
+
*/
|
|
21
|
+
readonly definitions: ReadonlyMap<string, SimpleNodeSchema<SchemaType.View> & TreeNodeSchema>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=treeSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeSchema.d.ts","sourceRoot":"","sources":["../../src/simple-tree/treeSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGxF,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,CAmB5E;AAED;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC;IACpE;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAChC,MAAM,EACN,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAClD,CAAC;CACF"}
|