# Fluid Framework v3.15.0 ## Contents - [🌳 SharedTree DDS Changes](#-sharedtree-dds-changes) - [Import trees that contain unknown optional fields (#28676)](#import-trees-that-contain-unknown-optional-fields-28676) - [SharedTree preserves the schema of an initialized empty root (#28826)](#sharedtree-preserves-the-schema-of-an-initialized-empty-root-28826) - [SharedTree applies schema upgrades needed to make a view usable (#28827)](#sharedtree-applies-schema-upgrades-needed-to-make-a-view-usable-28827) ## 🌳 SharedTree DDS Changes ### Import trees that contain unknown optional fields ([#28676](https://github.com/microsoft/FluidFramework/issues/28676)) [`TreeAlpha.importVerbose`](https://fluidframework.com/docs/api/fluid-framework/treealpha-interface#importverbose-methodsignature) now supports [`KeyEncodingOptions.allStoredKeys`](https://fluidframework.com/docs/api/fluid-framework/keyencodingoptions-enum#allstoredkeys-enummember). Before this change, you could use `allStoredKeys` only for export. Data that [`TreeAlpha.exportVerbose`](https://fluidframework.com/docs/api/fluid-framework/treealpha-interface#exportverbose-methodsignature) exports with `allStoredKeys` includes [unknown optional fields](https://fluidframework.com/docs/api/fluid-framework/objectschemaoptions-interface#allowunknownoptionalfields-propertysignature), and the import could not read them. Now you can export a tree and import it again without losing data. To import with `allStoredKeys`, use the new [`TreeImportOptions`](https://fluidframework.com/docs/api/fluid-framework/treeimportoptions-typealias). Set `keys` to `KeyEncodingOptions.allStoredKeys`. Set `view` to a view of the document. The import then uses the stored schema of the view's document. All of the data must agree with this stored schema, and you can insert the result into that document. The view must be able to view its document (see [`TreeView.compatibility`](https://fluidframework.com/docs/api/fluid-framework/treeview-interface#compatibility-propertysignature)). The import must use the same schema objects as the view. Each node schema in the schema that you give to the import must come from the `TreeViewConfiguration` of the view. If you give a different schema object that has the same identifier, the import throws an error. This occurs also if the two schema objects define the same schema. To find the unknown optional fields in the imported tree, use [`TreeContextAlpha.unknownFieldSchemas`](https://fluidframework.com/docs/api/fluid-framework/treecontextalpha-interface#unknownfieldschemas-propertysignature) of the view. #### Example Version 1 of an application defines a `Person` with a `name` field, and allows unknown optional fields: ```typescript const sf = new SchemaFactoryBeta("com.example"); class Person extends sf.object( "Person", { name: sf.string }, { allowUnknownOptionalFields: true }, ) {} ``` Version 2 of the application adds an optional `nickname` field to `Person`: ```typescript class Person extends sf.object( "Person", { name: sf.string, nickname: sf.optional(sf.string) }, { allowUnknownOptionalFields: true }, ) {} ``` After version 2 upgrades the schema of a document, the `nickname` field is unknown to version 1. Version 1 can export a `Person`, keep the data outside of the tree, and import it again without losing `nickname`: ```typescript // In version 1 of the application: // `importVerbose` needs an alpha view: use `asAlpha` to get one from a `TreeView`. const view = asAlpha( tree.viewWith(new TreeViewConfiguration({ schema: Person })), ); const person = view.root; const data = TreeAlpha.exportVerbose(person, { keys: KeyEncodingOptions.allStoredKeys, }); // { type: "com.example.Person", fields: { name: "Alice", nickname: "Al" } } // Keep `data` outside of the tree, for example in a file. // ... // Later, import `data` into the same document: const copy = TreeAlpha.importVerbose(Person, data, { keys: KeyEncodingOptions.allStoredKeys, view, }); view.root = copy; // The copy keeps `nickname`. ``` #### Change details Commit: [`1582be0`](https://github.com/microsoft/FluidFramework/commit/1582be0f2901eb3c90d852922c23d1c8ca67c107) Affected packages: - @fluidframework/tree - fluid-framework [⬆️ Table of contents](#contents) ### SharedTree preserves the schema of an initialized empty root ([#28826](https://github.com/microsoft/FluidFramework/issues/28826)) An empty tree is not necessarily a new tree. Previously, if you initialized a tree with an optional root that allowed no node types, reopening it reported `view.compatibility.canInitialize` as `true`. A second call to `view.initialize()` could then replace its schema. Now `canInitialize` is `false`, and a second initialization throws without replacing the schema. #### Change details Commit: [`e5a1480`](https://github.com/microsoft/FluidFramework/commit/e5a14807d816431c267d11ee8072e5da119314b3) Affected packages: - @fluidframework/tree - fluid-framework [⬆️ Table of contents](#contents) ### SharedTree applies schema upgrades needed to make a view usable ([#28827](https://github.com/microsoft/FluidFramework/issues/28827)) Previously, `view.upgradeSchema()` could return successfully while `view.compatibility.canView` remained `false`. It now applies the permitted schema change needed to make the view usable. #### Change details Commit: [`ddca9a5`](https://github.com/microsoft/FluidFramework/commit/ddca9a51a3944489db5544c086c729b335b6a478) Affected packages: - @fluidframework/tree - fluid-framework [⬆️ Table of contents](#contents) ### 🛠️ Start Building Today! Please continue to engage with us on GitHub [Discussion](https://github.com/microsoft/FluidFramework/discussions) and [Issue](https://github.com/microsoft/FluidFramework/issues) pages as you adopt Fluid Framework!