@fluidframework/tree 2.118.0 → 2.118.1

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.
Files changed (32) hide show
  1. package/dist/packageVersion.d.ts +1 -1
  2. package/dist/packageVersion.js +1 -1
  3. package/dist/packageVersion.js.map +1 -1
  4. package/dist/shared-tree/schematizingTreeView.js +1 -1
  5. package/dist/shared-tree/schematizingTreeView.js.map +1 -1
  6. package/dist/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  7. package/dist/simple-tree/api/schemaCompatibilityTester.js +1 -1
  8. package/dist/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  9. package/dist/simple-tree/api/tree.d.ts +2 -3
  10. package/dist/simple-tree/api/tree.d.ts.map +1 -1
  11. package/dist/simple-tree/api/tree.js.map +1 -1
  12. package/dist/simple-tree/core/toStored.d.ts +1 -1
  13. package/dist/simple-tree/core/toStored.js.map +1 -1
  14. package/lib/packageVersion.d.ts +1 -1
  15. package/lib/packageVersion.js +1 -1
  16. package/lib/packageVersion.js.map +1 -1
  17. package/lib/shared-tree/schematizingTreeView.js +1 -1
  18. package/lib/shared-tree/schematizingTreeView.js.map +1 -1
  19. package/lib/simple-tree/api/schemaCompatibilityTester.d.ts.map +1 -1
  20. package/lib/simple-tree/api/schemaCompatibilityTester.js +1 -1
  21. package/lib/simple-tree/api/schemaCompatibilityTester.js.map +1 -1
  22. package/lib/simple-tree/api/tree.d.ts +2 -3
  23. package/lib/simple-tree/api/tree.d.ts.map +1 -1
  24. package/lib/simple-tree/api/tree.js.map +1 -1
  25. package/lib/simple-tree/core/toStored.d.ts +1 -1
  26. package/lib/simple-tree/core/toStored.js.map +1 -1
  27. package/package.json +22 -22
  28. package/src/packageVersion.ts +1 -1
  29. package/src/shared-tree/schematizingTreeView.ts +1 -1
  30. package/src/simple-tree/api/schemaCompatibilityTester.ts +2 -1
  31. package/src/simple-tree/api/tree.ts +2 -3
  32. package/src/simple-tree/core/toStored.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgmCH;;;;;GAKG;AACH,SAAgB,eAAe,CAC9B,IAAuB;IAEvB,OAAO,IAA8B,CAAC;AACvC,CAAC;AAJD,0CAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\n\nimport type {\n\tChangeMetadata,\n\tCommitMetadata,\n\tCustomMetadataTree,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\n\tRevertible,\n\tRevertibleAlphaFactory,\n\tRevertibleFactory,\n\tRevertToOptionsAlpha,\n} from \"../../core/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { TreeStatus } from \"../../feature-libraries/index.js\";\nimport type {\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports -- This is referenced by doc comments.\n\tTreeAlpha,\n} from \"../../shared-tree/index.js\";\nimport type {\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../util/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { SchemaUpgrade, Unhydrated } from \"../core/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableField,\n\tInsertableTreeFieldFromImplicitField,\n\tReadableField,\n\tReadSchema,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport type { UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\nimport type { TreeViewConfiguration } from \"./configuration.js\";\nimport type { StagedUpgradeStatus } from \"./schemaCompatibilityTester.js\";\nimport type {\n\tRunTransactionParamsAlpha,\n\tRunTransactionParamsBeta,\n\tTransactionCallbackStatusAlpha,\n\tTransactionCallbackStatusBeta,\n\tTransactionVoidResult,\n\tTransactionValueResult,\n\tVoidTransactionCallbackStatusAlpha,\n\tVoidTransactionCallbackStatusBeta,\n\tWithValue,\n} from \"./transactionTypes.js\";\nimport type { VerboseTree } from \"./verboseTree.js\";\n\n/**\n * A tree from which a {@link TreeView} can be created.\n *\n * @privateRemarks\n * TODO:\n * Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.\n * Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).\n * Maybe rename \"exportJsonSchema\" to align on \"concise\" terminology.\n * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).\n * Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).\n * @system @sealed @public\n */\nexport interface ViewableTree {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Support adapters for handling out-of-schema data.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends ViewableTree, IFluidLoadable {}\n\n/**\n * {@link ITree} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport interface ITreeAlpha extends ITree {\n\t/**\n\t * Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.\n\t * @remarks\n\t * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).\n\t */\n\texportVerbose(): VerboseTree | undefined;\n\n\t/**\n\t * Exports the SimpleTreeSchema that is stored in the tree, using stored keys for object fields.\n\t * @remarks\n\t * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.\n\t */\n\texportSimpleSchema(): SimpleTreeSchema;\n\n\t/**\n\t * Creates a fork of the current state of the main branch.\n\t * This new branch will be shared with and editable by all clients.\n\t * @param name - Optional name for the new branch.\n\t * This name is not guaranteed to be unique.\n\t * (Maximum {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length | length}: 1024)\n\t * @returns The ID of the new branch, which can be used to {@link ITreeAlpha.viewSharedBranchWith | view} the branch.\n\t */\n\tcreateSharedBranch(name?: string): string;\n\n\t/**\n\t * Retrieves the name, if any, of the shared branch with the given ID.\n\t * @param branchId - The ID of the shared branch to retrieve the name of.\n\t * @returns The name of the shared branch, or `undefined` if the branch has no assigned name.\n\t * @throws if the branch with the given ID does not exist.\n\t */\n\tgetSharedBranchName(branchId: string): string | undefined;\n\n\t/**\n\t * Returns a list of all shared branches that currently exist on this tree.\n\t * Any one of them can be checked out using {@link ITreeAlpha.viewSharedBranchWith}.\n\t */\n\tgetSharedBranchIds(): string[];\n\n\t/**\n\t * Returns a view of the tree on the specified shared branch, using the provided schema.\n\t * See {@link ViewableTree.viewWith}.\n\t */\n\tviewSharedBranchWith<TRoot extends ImplicitFieldSchema>(\n\t\tbranchId: string,\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * An untyped view of a (version-control-style) branch of a SharedTree.\n * @remarks An `UntypedTreeView` allows for the {@link UntypedTreeView.fork | creation of branches} and for those branches to later be {@link UntypedTreeView.merge | merged}.\n *\n * The branch associated directly with the {@link ITree | SharedTree} is the \"main\" branch, and all other branches fork (directly or transitively) from that main branch.\n *\n * See {@link UntypedTreeViewAlpha} for additional APIs that are in an earlier stage of development.\n * @sealed @beta\n */\nexport interface UntypedTreeView extends IDisposable {\n\t/**\n\t * Fork a new branch off of this branch which is based off of this branch's current state.\n\t * @remarks Any changes to the tree on the new view will not apply to this view until the new view is e.g. {@link UntypedTreeView.merge | merged} back into this view.\n\t * The view should be disposed when no longer needed, either {@link UntypedTreeView.dispose | explicitly} or {@link UntypedTreeView.merge | implicitly when merging} into another view.\n\t */\n\tfork(): UntypedTreeView;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - A view created by {@link UntypedTreeView.fork}.\n\t * @param disposeMerged - Whether or not to dispose `view` after the merge completes.\n\t * Defaults to true.\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: UntypedTreeView, disposeMerged?: boolean): void;\n\n\t/**\n\t * Advance this view forward such that all new changes on the target view become part of this view.\n\t * @param view - The view to rebase onto.\n\t * @remarks After rebasing, this view will be \"ahead\" of the target view, that is, its unique changes will have been recreated as if they happened after all changes on the target view.\n\t * This method may only be called on views produced via {@link UntypedTreeView.fork | fork} - attempting to rebase the main view will throw.\n\t *\n\t * Rebasing long-lived branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last rebased.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be rebased onto another view - attempting to do so will throw an error.\n\t */\n\trebaseOnto(view: UntypedTreeView): void;\n\n\t/**\n\t * Dispose of this view, cleaning up any resources associated with it.\n\t * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.\n\t * @remarks Views can also be automatically disposed when {@link UntypedTreeView.merge | they are merged} into another view.\n\t *\n\t * Disposing branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" view was created or last {@link UntypedTreeView.rebaseOnto | rebased}.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t */\n\tdispose(error?: Error): void;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeView}.\n *\n * @deprecated Use {@link UntypedTreeView} instead.\n * @beta\n */\nexport type TreeBranch = UntypedTreeView;\n\n/**\n * Provides additional APIs that may be used to interact with a tree node or a tree node's SharedTree.\n * @alpha\n */\nexport interface TreeContextAlpha {\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t * @param transaction - A callback run during the transaction to perform user-supplied operations.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t * @param params - Optional {@link RunTransactionParamsAlpha | parameters} for the transaction.\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * `runTransaction` may be invoked on the context of a {@link TreeStatus.InDocument | hydrated } or {@link Unhydrated | unhydrated } node.\n\t * Use {@link TreeContextAlpha.isView | isView() } to check whether this context is associated with a view and gain {@link UntypedTreeViewAlpha.(runTransaction:1) | access to more transaction capabilities} if so.\n\t */\n\trunTransaction<TValue>(\n\t\ttransaction: () => WithValue<TValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TValue, TValue>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeContextAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this context.\n\t */\n\trunTransactionAsync<TValue>(\n\t\ttransaction: () => Promise<WithValue<TValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TValue, TValue>>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * True if this context is associated with an {@link UntypedTreeViewAlpha | untyped view} and false if it is associated with an {@link Unhydrated | unhydrated } node.\n\t * @remarks If this returns true, the context can be safely inferred or cast to {@link UntypedTreeViewAlpha} to access additional view-specific APIs.\n\t * @example\n\t * ```typescript\n\t * const context = tree.context(someNode);\n\t * if (context.isView()) {\n\t * assert(context.hasRootSchema(MySchema)) // `hasRootSchema` is a method on UntypedTreeViewAlpha, so this is only accessible if `context` is a view context.\n\t * context.root.foo = \"bar\"; // Edit the root of the SharedTree that `someNode` belongs to.\n\t * }\n\t * ```\n\t * @returns Whether this context is associated with an untyped view.\n\t */\n\tisView(): this is UntypedTreeViewAlpha;\n\n\t/**\n\t * {@inheritDoc TreeContextAlpha.isView}\n\t * @deprecated Use {@link TreeContextAlpha.isView | isView()} instead.\n\t */\n\tisBranch(): this is UntypedTreeViewAlpha;\n}\n\n/**\n * An identifier for a commit in a {@link UntypedTreeViewAlpha}'s {@link UntypedTreeViewAlpha.branchHistory | history}.\n * @alpha\n */\nexport type CommitRevision = string;\n\n/**\n * Metadata describing a single commit in a {@link UntypedTreeViewAlpha}'s history.\n * @sealed @alpha\n */\nexport interface TreeBranchCommitMetadata {\n\t/**\n\t * The revision UUID that uniquely identifies this commit within the branch's history.\n\t */\n\treadonly revision: CommitRevision;\n\n\t/**\n\t * Arbitrary, application-defined metadata that was {@link RunTransactionParamsAlpha.customMetadata | attached}\n\t * to this commit when it was created, flattened into a single object.\n\t *\n\t * @remarks\n\t * This is `undefined` for commits that were not annotated.\n\t *\n\t * A commit may be produced by nested transactions, each of which may supply metadata. This property combines\n\t * them: where two of them used the same property, the outermost transaction wins, and between siblings the\n\t * later one wins. Use {@link TreeBranchCommitMetadata.customTree} to recover which transaction supplied what.\n\t */\n\treadonly custom: JsonCompatibleReadOnlyObject | undefined;\n\n\t/**\n\t * The {@link CustomMetadataTree | tree} of metadata attached to this commit, reflecting the nesting of\n\t * the transactions that produced it.\n\t *\n\t * @remarks\n\t * The structural counterpart to {@link TreeBranchCommitMetadata.custom}, and `undefined` whenever it is.\n\t * Prefer `custom` unless you need to know which transaction supplied a particular property.\n\t */\n\treadonly customTree: CustomMetadataTree | undefined;\n\n\t/**\n\t * The metadata for the commit that this commit was based on, or `undefined` if this commit has no parent\n\t * (i.e. it is the oldest commit in the branch's history).\n\t *\n\t * @remarks\n\t * This method may return a different value over time if the parent commit is trimmed from the branch's history.\n\t */\n\tgetParent(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * Provides APIs for querying information about the history of a {@link UntypedTreeViewAlpha}.\n * @remarks\n * The history of a branch is the sequence of commits leading up to its current state.\n * @sealed @alpha\n */\nexport interface TreeBranchHistory {\n\t/**\n\t * The number of commits in this branch's history.\n\t * @remarks\n\t * This number grows when any of the following occurs:\n\t * - A new edit is made on this branch (either through editing or by reverting an existing commit on this branch).\n\t * - A branch that contains commits not already on this branch is merged into this branch.\n\t * - The branch is rebased onto another branch that contains commits not already on this branch.\n\t * This number shrinks when past commits are trimmed from the history.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * Returns metadata for the current head commit of this branch.\n\t * @returns The metadata for the head commit, or `undefined` if the branch has no commits.\n\t */\n\tgetHead(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * An untyped view of a {@link UntypedTreeView} with alpha-level APIs.\n * @remarks\n * The untyped view for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.context` and checking {@link TreeContextAlpha.isView | isView()}.\n *\n * An untyped view does not necessarily know the schema of its SharedTree. To convert it to a {@link TreeViewAlpha | view with a schema}, use {@link UntypedTreeViewAlpha.hasRootSchema | hasRootSchema()}.\n * @sealed @alpha\n */\nexport interface UntypedTreeViewAlpha extends UntypedTreeView, TreeContextAlpha {\n\t/**\n\t * Events for the view's underlying branch.\n\t */\n\treadonly events: Listenable<TreeBranchEvents>;\n\n\t/**\n\t * APIs for querying the history of the branch being viewed.\n\t */\n\treadonly branchHistory: TreeBranchHistory;\n\n\t/**\n\t * Returns true if this view has the given schema as its root schema.\n\t * @remarks This is a type guard which allows this view to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.\n\t *\n\t * To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.\n\t * For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.\n\t * @example\n\t * ```typescript\n\t * if (view.hasRootSchema(MySchema)) {\n\t * const { root } = view; // `view` is now a TreeViewAlpha<MySchema>\n\t * // ...\n\t * }\n\t * ```\n\t */\n\thasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema>;\n\n\t// Override the base fork method to return the alpha variant.\n\tfork(): UntypedTreeViewAlpha;\n\n\t/**\n\t * Switches this view to a new underlying branch with the given commit as the head, updating the view state accordingly.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to rewind to.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t *\n\t * @remarks\n\t * Unlike {@link UntypedTreeViewAlpha.revertTo | revertTo}, this does not apply a change to the underlying branch.\n\t * The original underlying branch will be disposed.\n\t * Consider {@link UntypedTreeViewAlpha.fork | forking} before rewinding.\n\t * Not valid to invoke on the main branch or a {@link (ITreeAlpha:interface).createSharedBranch | shared branch}.\n\t */\n\trewindTo(revision: CommitRevision): void;\n\n\t/**\n\t * Applies a new change which reverts all changes made since the given `revision`.\n\t * This is a no-op if the given revision is the head commit of the underlying branch being viewed.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to restore the state of.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t * @param options - Optional {@link RevertToOptionsAlpha | options} for the revert.\n\t *\n\t * @remarks\n\t * The generated change is subject to the same merge semantics as the {@link Revertible.(revert:1) | reverts of individual commits}:\n\t * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.\n\t *\n\t * Unlike {@link UntypedTreeViewAlpha.rewindTo | rewindTo}, this does not switch to a new branch.\n\t */\n\trevertTo(revision: CommitRevision, options?: RevertToOptionsAlpha): void;\n\n\t/**\n\t * {@link TreeContextAlpha.(runTransaction:1) | Run a transaction} on this view of the SharedTree.\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusAlpha | value or rollback signal}.\n\t * @remarks\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatusAlpha | void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks See {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync} for additional information about asynchronous transactions.\n\t */\n\n\trunTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * Apply a serialized change to this branch.\n\t * @param change - the change to apply.\n\t * Changes are acquired via `getChange` in a branch's {@link TreeBranchEvents.changed | \"changed\"} event.\n\t * @remarks Changes may only be applied to a SharedTree with the same IdCompressor instance and branch state from which they were generated.\n\t * They may be created by one branch and applied to another, but only if both branches share the same history at the time of creation and application.\n\t *\n\t * @privateRemarks\n\t * TODO: This method will support applying changes from different IdCompressor instances as long as they have the same local session ID.\n\t * Update the tests and docs to match when that is done.\n\t */\n\tapplyChange(change: JsonCompatibleReadOnly): void;\n\n\t/**\n\t * Determines if there are changes on the given view that are not present on this view.\n\t * @param view - The view to compare to.\n\t *\n\t * The new edits, if any, can be applied to this view by {@link UntypedTreeView.rebaseOnto | rebasing this view onto the given view}\n\t * or by {@link UntypedTreeView.merge | merging the given view into this view}.\n\t *\n\t * @throws UsageError if the branches are unrelated.\n\t */\n\tisMissingEditsFrom(view: UntypedTreeView): boolean;\n\n\t/**\n\t * Computes the net change that would result if this view were {@link UntypedTreeView.rebaseOnto | rebased onto} the given view.\n\t * Note that this method does not actually perform the rebase and therefore has no effect on this view.\n\t *\n\t * @param view - The view that would be rebased onto.\n\t * @returns The net change that would result if this view were rebased onto the given view,\n\t * or `undefined` if rebasing would have no impact.\n\t */\n\tcomputeNetChangeIfRebasedOnto(view: UntypedTreeView): JsonCompatibleReadOnly | undefined;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeViewAlpha}.\n *\n * @deprecated Use {@link UntypedTreeViewAlpha} instead.\n * @alpha\n */\nexport type TreeBranchAlpha = UntypedTreeViewAlpha;\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * @remarks\n * This schema (known as the view schema) may or may not align with the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/docs/user-facing/schema-evolution.md | schema-evolution.md}\n * and choose a schema compatibility policy that aligns with their application's needs.\n *\n * See also {@link TreeViewAlpha}, {@link TreeViewBeta} and {@link UntypedTreeView} for additional APIs that are in earlier stages of development.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n *\n * @see {@link TreeViewAlpha}\n * @see {@link asTreeViewAlpha}\n *\n * @sealed @public\n */\nexport interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t * @remarks\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status of the document's stored schema changes.\n\t * See {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution} for more guidance on how to change schema while maintaining compatibility.\n\t * Use {@link snapshotSchemaCompatibility} to write tests to validate that this compatibility behaves as desired across schema changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * @remarks\n\t * This will update the {@link TreeView.compatibility}, allowing access to `root`.\n\t * Beware that this may impact other clients' ability to view the document: see {@link SchemaCompatibilityStatus.canView} for more information.\n\t *\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.\n\t * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the target stored schema.\n\t * Staged upgrades that are already enabled in the document are also included by default. Set\n\t * {@link (StagedSchemaUpgradePolicy:interface).includeAlreadyEnabledUpgrades} to `false` when\n\t * creating the policy to only include staged upgrades selected explicitly by the policy.\n\t *\n\t * @example Enabling a staged allowed type for documents, selected by a feature flag\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactoryBeta(\"my-app\");\n\t *\n\t * class TaskItem extends sf.object(\"TaskItem\", { title: sf.string }) {}\n\t * class ChecklistItem extends sf.object(\"ChecklistItem\", { text: sf.string }) {}\n\t *\n\t * // `staged` wraps ChecklistItem so it can be enabled at runtime.\n\t * const stagedChecklist = SchemaFactoryBeta.staged(ChecklistItem);\n\t * const checklistUpgrade = stagedChecklist.metadata.stagedSchemaUpgrade;\n\t *\n\t * class AppSchema extends sf.object(\"AppSchema\", {\n\t * items: sf.array([TaskItem, stagedChecklist]),\n\t * }) {}\n\t *\n\t * // Feature flag controls whether the upgrade is enabled for this session.\n\t * const policy = featureFlags.enableChecklist\n\t * ? StagedSchemaUpgradePolicy.enabledStagedUpgrades(checklistUpgrade)\n\t * : undefined;\n\t *\n\t * const view = tree.viewWith(\n\t * new TreeViewConfigurationAlpha({ schema: AppSchema, stagedUpgradePolicy: policy }),\n\t * );\n\t *\n\t * if (view.compatibility.canUpgrade) {\n\t * // Writes the staged type into the document's stored schema.\n\t * view.upgradeSchema();\n\t * }\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t * - update only a specific change (add an optional field, or apply a staged upgrade)\n\t * - update persistedMetadata or not\n\t *\n\t * As persisted metadata becomes more supported, how it interacts with isEquivalent and upgradeSchema should be clarified:\n\t * for now the docs are being left somewhat vague to allow flexibility in this area.\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the initial stored schema.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n\n\t/**\n\t * The view schema used by this TreeView.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * A discrepancy between a view schema and a document's stored schema.\n *\n * @remarks\n * The `mismatch` property discriminates the different discrepancy shapes.\n *\n * @sealed @beta\n */\nexport type SchemaDiscrepancy =\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a field allows different node types in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"allowedTypes\";\n\t\t\t/**\n\t\t\t * The field with the discrepancy.\n\t\t\t *\n\t\t\t * `\"root\"` identifies the root field. Otherwise, `nodeType` identifies the containing\n\t\t\t * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map\n\t\t\t * node's implicit field.\n\t\t\t */\n\t\t\treadonly location:\n\t\t\t\t| \"root\"\n\t\t\t\t| {\n\t\t\t\t\t\treadonly nodeType: string;\n\t\t\t\t\t\treadonly fieldKey: string | undefined;\n\t\t\t\t };\n\t\t\t/**\n\t\t\t * Non-staged node type identifiers allowed by the view schema but not the stored schema.\n\t\t\t */\n\t\t\treadonly view: readonly string[];\n\t\t\t/**\n\t\t\t * Staged node type identifiers allowed by the view schema but not the stored schema.\n\t\t\t *\n\t\t\t * @remarks These types provide rollout context but do not cause the discrepancy.\n\t\t\t */\n\t\t\treadonly stagedView?: readonly string[];\n\t\t\t/**\n\t\t\t * Node type identifiers allowed by the stored schema but not the view schema.\n\t\t\t */\n\t\t\treadonly stored: readonly string[];\n\t\t\t/**\n\t\t\t * Whether the view field is a staged optional field.\n\t\t\t *\n\t\t\t * @remarks Omitted when false.\n\t\t\t */\n\t\t\treadonly viewIsStagedOptional?: true;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a field has different field kinds in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"fieldKind\";\n\t\t\t/**\n\t\t\t * The field with the discrepancy.\n\t\t\t *\n\t\t\t * `\"root\"` identifies the root field. Otherwise, `nodeType` identifies the containing\n\t\t\t * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map\n\t\t\t * node's implicit field.\n\t\t\t */\n\t\t\treadonly location:\n\t\t\t\t| \"root\"\n\t\t\t\t| {\n\t\t\t\t\t\treadonly nodeType: string;\n\t\t\t\t\t\treadonly fieldKey: string | undefined;\n\t\t\t\t };\n\t\t\t/**\n\t\t\t * The field kind required by the view schema.\n\t\t\t */\n\t\t\treadonly view: string;\n\t\t\t/**\n\t\t\t * The field kind recorded in the stored schema.\n\t\t\t */\n\t\t\treadonly stored: string;\n\t\t\t/**\n\t\t\t * Whether the view field is a staged optional field.\n\t\t\t *\n\t\t\t * @remarks Omitted when false.\n\t\t\t */\n\t\t\treadonly viewIsStagedOptional?: true;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a leaf node accepts different value types in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"valueSchema\";\n\t\t\t/**\n\t\t\t * The identifier of the leaf node schema with the discrepancy.\n\t\t\t */\n\t\t\treadonly nodeType: string;\n\t\t\t/**\n\t\t\t * The value schema required by the view, or undefined when it does not constrain values.\n\t\t\t */\n\t\t\treadonly view: string | undefined;\n\t\t\t/**\n\t\t\t * The value schema recorded in the stored schema, or undefined when it does not constrain values.\n\t\t\t */\n\t\t\treadonly stored: string | undefined;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a node is represented by different node kinds in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"nodeKind\";\n\t\t\t/**\n\t\t\t * The identifier of the node schema with the discrepancy.\n\t\t\t */\n\t\t\treadonly nodeType: string;\n\t\t\t/**\n\t\t\t * The node kind required by the view schema.\n\t\t\t */\n\t\t\treadonly view: string;\n\t\t\t/**\n\t\t\t * The node kind recorded in the stored schema.\n\t\t\t */\n\t\t\treadonly stored: string;\n\t };\n\n/**\n * {@link SchemaCompatibilityStatus} with additional beta APIs.\n *\n * @sealed @beta\n */\nexport interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {\n\t/**\n\t * Details about the schema discrepancies that prevent this view from accessing the tree.\n\t *\n\t * @remarks\n\t * This property is undefined when {@link SchemaCompatibilityStatus.canView} is true and present\n\t * when `canView` is false.\n\t * It can include application-defined schema identifiers and field keys.\n\t *\n\t * @example Interpreting an allowed-types discrepancy\n\t *\n\t * If a document's stored schema allows `string` for `Todo.title`, but the view schema expects\n\t * `number`, the discrepancy identifies the field and the type permitted by each schema:\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactory(\"com.example\");\n\t * class Todo extends sf.object(\"Todo\", {\n\t * \ttitle: sf.number,\n\t * }) {}\n\t *\n\t * const view = asBeta(tree.viewWith(new TreeViewConfiguration({ schema: Todo })));\n\t * if (!view.compatibility.canView) {\n\t * \t// [{\n\t * \t// mismatch: \"allowedTypes\",\n\t * \t// location: { nodeType: \"com.example.Todo\", fieldKey: \"title\" },\n\t * \t// view: [\"com.fluidframework.leaf.number\"],\n\t * \t// stored: [\"com.fluidframework.leaf.string\"],\n\t * \t// }]\n\t * \tconsole.error(view.compatibility.discrepancies);\n\t * }\n\t * ```\n\t */\n\treadonly discrepancies: readonly SchemaDiscrepancy[] | undefined;\n}\n\n/**\n * {@link TreeView} with additional beta APIs.\n * @sealed @beta\n */\nexport interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema>\n\textends TreeView<TSchema>,\n\t\tUntypedTreeView {\n\t/**\n\t * {@inheritDoc TreeView.compatibility}\n\t */\n\treadonly compatibility: SchemaCompatibilityStatusBeta;\n\n\t// Override the base branch method to return a typed view rather than merely a branch.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewBeta<TSchema>;\n\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t *\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusBeta | value or rollback signal}.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t *\n\t * @param params - Optional {@link RunTransactionParamsBeta | parameters} for the transaction.\n\t *\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t *\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => TOut,\n\t\tparams?: RunTransactionParamsBeta,\n\t): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t: TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeViewBeta.runTransaction | runTransaction}.\n\t *\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this view.\n\t */\n\trunTransactionAsync<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => Promise<TOut>,\n\t\tparams?: RunTransactionParamsBeta,\n\t): Promise<\n\t\tTOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t\t: TransactionVoidResult\n\t>;\n}\n\n/**\n * {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.\n * @sealed @alpha\n */\nexport interface TreeViewAlpha<\n\tin out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> extends Omit<\n\t\t\tTreeViewBeta<ReadSchema<TSchema>>,\n\t\t\t\"root\" | \"initialize\" | \"fork\" | \"runTransaction\" | \"runTransactionAsync\"\n\t\t>,\n\t\tUntypedTreeViewAlpha {\n\tget root(): ReadableField<TSchema>;\n\n\tset root(newRoot: InsertableField<TSchema>);\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableField<TSchema>): void;\n\n\t/**\n\t * Checks whether a staged schema upgrade has been applied to the document's stored schema.\n\t *\n\t * @param upgrade - The upgrade token to check.\n\t *\n\t * @returns The {@link StagedUpgradeStatus} of the upgrade.\n\t *\n\t * @remarks\n\t * Use this to determine whether a document has already been upgraded, for example when deciding\n\t * whether to include an upgrade token in the view configuration after a feature flag rollback.\n\t *\n\t * Results are derived from this view's schema and the current stored schema.\n\t * The full schema is checked even when the view is incompatible with the stored schema, so the\n\t * result includes all locations declared by the view schema.\n\t */\n\tisStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus;\n\n\treadonly events: Listenable<TreeViewEvents & TreeBranchEvents>;\n\n\t// Override the base fork method to return a TreeViewAlpha.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewAlpha<TSchema>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * @see\n * See SharedTree's README for more information about choosing a compatibility policy.\n *\n * @privateRemarks\n * See {@link checkSchemaCompatibility} for the implementation of this compatibility checking.\n *\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t *\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t *\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (for example: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t *\n\t * Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.\n\t *\n\t * For the computation of this equivalence, {@link SchemaStaticsBeta.staged | staged} schemas are not included.\n\t * If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t * @remarks\n\t * If the view schema does not opt into supporting any additional cases, then `canView` is only true when `isEquivalent` is also true.\n\t * The view schema can however opt into supporting additional cases, and thus can also view documents with stored schema which would be equivalent, except for the following discrepancies:\n\t *\n\t * - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.\n\t *\n\t * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsBeta.staged | staged} in the view schema.\n\t *\n\t * In these cases `canUpgrade` and `isEquivalent` will be false.\n\t *\n\t * When the set of documents allowed by the view schema is a strict superset of those allowed by the stored schema,\n\t * `canView` is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future versions of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs only tolerate very specific cases beyond their schema (unknown optional fields).\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True when {@link TreeView.upgradeSchema} can add support for all content required to be supported by the view schema.\n\t * @remarks\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t *\n\t * When adding optional fields to schema which previously were marked with {@link ObjectSchemaOptions.allowUnknownOptionalFields}\n\t * the schema upgrade (assuming no other changes are included) will allow the previous version to view.\n\t * Even this case must still must be done with caution however as only clients with the newly added field will be able to do future upgrades.\n\t * Thus if a version of an application is shipped that adds an unknown optional field, all future versions should include it, even if its no longer used,\n\t * to ensure that documents containing it can still be upgraded.\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * branch that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link UntypedTreeView}.\n * @sealed @alpha\n */\nexport interface TreeBranchEvents {\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about (e.g. local vs. remote changes).\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;\n}\n\n/**\n * Events for {@link TreeView}.\n * @remarks\n * See {@link TreeBranchEvents} for more events related to the underlying branch of the SharedTree.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.\n * @alpha\n * @deprecated Use {@link (asAlpha:1)} instead.\n * @privateRemarks Despite being deprecated, this function should be used within the tree package (outside of tests) rather than `asAlpha` in order to avoid circular import dependencies.\n */\nexport function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeViewAlpha<TSchema> {\n\treturn view as TreeViewAlpha<TSchema>;\n}\n"]}
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/simple-tree/api/tree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+lCH;;;;;GAKG;AACH,SAAgB,eAAe,CAC9B,IAAuB;IAEvB,OAAO,IAA8B,CAAC;AACvC,CAAC;AAJD,0CAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, IDisposable, Listenable } from \"@fluidframework/core-interfaces\";\n\nimport type {\n\tChangeMetadata,\n\tCommitMetadata,\n\tCustomMetadataTree,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\n\tRevertible,\n\tRevertibleAlphaFactory,\n\tRevertibleFactory,\n\tRevertToOptionsAlpha,\n} from \"../../core/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { TreeStatus } from \"../../feature-libraries/index.js\";\nimport type {\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-imports -- This is referenced by doc comments.\n\tTreeAlpha,\n} from \"../../shared-tree/index.js\";\nimport type {\n\tJsonCompatibleReadOnly,\n\tJsonCompatibleReadOnlyObject,\n} from \"../../util/index.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is referenced by doc comments.\nimport type { SchemaUpgrade, Unhydrated } from \"../core/index.js\";\nimport type {\n\tImplicitFieldSchema,\n\tInsertableField,\n\tInsertableTreeFieldFromImplicitField,\n\tReadableField,\n\tReadSchema,\n\tTreeFieldFromImplicitField,\n} from \"../fieldSchema.js\";\nimport type { SimpleTreeSchema } from \"../simpleSchema.js\";\nimport type { UnsafeUnknownSchema } from \"../unsafeUnknownSchema.js\";\n\nimport type { TreeViewConfiguration } from \"./configuration.js\";\nimport type { StagedUpgradeStatus } from \"./schemaCompatibilityTester.js\";\nimport type {\n\tRunTransactionParamsAlpha,\n\tRunTransactionParamsBeta,\n\tTransactionCallbackStatusAlpha,\n\tTransactionCallbackStatusBeta,\n\tTransactionVoidResult,\n\tTransactionValueResult,\n\tVoidTransactionCallbackStatusAlpha,\n\tVoidTransactionCallbackStatusBeta,\n\tWithValue,\n} from \"./transactionTypes.js\";\nimport type { VerboseTree } from \"./verboseTree.js\";\n\n/**\n * A tree from which a {@link TreeView} can be created.\n *\n * @privateRemarks\n * TODO:\n * Add stored key versions of {@link (TreeAlpha:interface).(exportVerbose:2)}, {@link (TreeAlpha:interface).(exportConcise:2)} and {@link (TreeAlpha:interface).exportCompressed} here so tree content can be accessed without a view schema.\n * Add exportSimpleSchema and exportJsonSchema methods (which should exactly match the concise format, and match the free functions for exporting view schema).\n * Maybe rename \"exportJsonSchema\" to align on \"concise\" terminology.\n * Ensure schema exporting APIs here align and reference APIs for exporting view schema to the same formats (which should include stored vs property key choice).\n * Make sure users of independentView can use these export APIs (maybe provide a reference back to the ViewableTree from the TreeView to accomplish that).\n * @system @sealed @public\n */\nexport interface ViewableTree {\n\t/**\n\t * Returns a {@link TreeView} using the provided schema.\n\t * If the stored schema is compatible with the view schema specified by `config`,\n\t * the returned {@link TreeView} will expose the root with a schema-aware API based on the provided view schema.\n\t * If the provided schema is incompatible with the stored schema, the view will instead expose a status indicating the incompatibility.\n\t *\n\t * @remarks\n\t * If the tree is uninitialized (has no schema and no content), use {@link TreeView.initialize} on the returned view to set the schema and content together.\n\t * Using `viewWith` followed by {@link TreeView.upgradeSchema} to initialize only the schema for a document is technically valid when the schema\n\t * permits trees with no content.\n\t *\n\t * Note that other clients can modify the document at any time, causing the view to change its compatibility status: see {@link TreeView.events} for how to handle invalidation in these cases.\n\t *\n\t * Only one schematized view may exist for a given ITree at a time.\n\t * If creating a second, the first must be disposed before calling `viewWith` again.\n\t *\n\t * @privateRemarks\n\t * TODO: Support adapters for handling out-of-schema data.\n\t */\n\tviewWith<TRoot extends ImplicitFieldSchema>(\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * Channel for a Fluid Tree DDS.\n * @remarks\n * Allows storing and collaboratively editing schema-aware hierarchial data.\n * @sealed @public\n */\nexport interface ITree extends ViewableTree, IFluidLoadable {}\n\n/**\n * {@link ITree} extended with some alpha APIs.\n * @sealed @alpha\n */\nexport interface ITreeAlpha extends ITree {\n\t/**\n\t * Exports root in the same format as {@link (TreeAlpha:interface).(exportVerbose:1)} using stored keys.\n\t * @remarks\n\t * This is `undefined` if and only if the root field is empty (this can only happen if the root field is optional).\n\t */\n\texportVerbose(): VerboseTree | undefined;\n\n\t/**\n\t * Exports the SimpleTreeSchema that is stored in the tree, using stored keys for object fields.\n\t * @remarks\n\t * To get the schema using property keys, use {@link getSimpleSchema} on the view schema.\n\t */\n\texportSimpleSchema(): SimpleTreeSchema;\n\n\t/**\n\t * Creates a fork of the current state of the main branch.\n\t * This new branch will be shared with and editable by all clients.\n\t * @param name - Optional name for the new branch.\n\t * This name is not guaranteed to be unique.\n\t * (Maximum {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length | length}: 1024)\n\t * @returns The ID of the new branch, which can be used to {@link ITreeAlpha.viewSharedBranchWith | view} the branch.\n\t */\n\tcreateSharedBranch(name?: string): string;\n\n\t/**\n\t * Retrieves the name, if any, of the shared branch with the given ID.\n\t * @param branchId - The ID of the shared branch to retrieve the name of.\n\t * @returns The name of the shared branch, or `undefined` if the branch has no assigned name.\n\t * @throws if the branch with the given ID does not exist.\n\t */\n\tgetSharedBranchName(branchId: string): string | undefined;\n\n\t/**\n\t * Returns a list of all shared branches that currently exist on this tree.\n\t * Any one of them can be checked out using {@link ITreeAlpha.viewSharedBranchWith}.\n\t */\n\tgetSharedBranchIds(): string[];\n\n\t/**\n\t * Returns a view of the tree on the specified shared branch, using the provided schema.\n\t * See {@link ViewableTree.viewWith}.\n\t */\n\tviewSharedBranchWith<TRoot extends ImplicitFieldSchema>(\n\t\tbranchId: string,\n\t\tconfig: TreeViewConfiguration<TRoot>,\n\t): TreeView<TRoot>;\n}\n\n/**\n * An untyped view of a (version-control-style) branch of a SharedTree.\n * @remarks An `UntypedTreeView` allows for the {@link UntypedTreeView.fork | creation of branches} and for those branches to later be {@link UntypedTreeView.merge | merged}.\n *\n * The branch associated directly with the {@link ITree | SharedTree} is the \"main\" branch, and all other branches fork (directly or transitively) from that main branch.\n *\n * See {@link UntypedTreeViewAlpha} for additional APIs that are in an earlier stage of development.\n * @sealed @beta\n */\nexport interface UntypedTreeView extends IDisposable {\n\t/**\n\t * Fork a new branch off of this branch which is based off of this branch's current state.\n\t * @remarks Any changes to the tree on the new view will not apply to this view until the new view is e.g. {@link UntypedTreeView.merge | merged} back into this view.\n\t * The view should be disposed when no longer needed, either {@link UntypedTreeView.dispose | explicitly} or {@link UntypedTreeView.merge | implicitly when merging} into another view.\n\t */\n\tfork(): UntypedTreeView;\n\n\t/**\n\t * Apply all the new changes on the given view to this view.\n\t * @param view - A view created by {@link UntypedTreeView.fork}.\n\t * @param disposeMerged - Whether or not to dispose `view` after the merge completes.\n\t * Defaults to true.\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t * @remarks All ongoing transactions (if any) in `view` will be committed before the merge.\n\t */\n\tmerge(view: UntypedTreeView, disposeMerged?: boolean): void;\n\n\t/**\n\t * Advance this view forward such that all new changes on the target view become part of this view.\n\t * @param view - The view to rebase onto.\n\t * @remarks After rebasing, this view will be \"ahead\" of the target view, that is, its unique changes will have been recreated as if they happened after all changes on the target view.\n\t * This method may only be called on views produced via {@link UntypedTreeView.fork | fork} - attempting to rebase the main view will throw.\n\t *\n\t * Rebasing long-lived branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" branch was created or last rebased.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be rebased onto another view - attempting to do so will throw an error.\n\t */\n\trebaseOnto(view: UntypedTreeView): void;\n\n\t/**\n\t * Dispose of this view, cleaning up any resources associated with it.\n\t * @param error - Optional error indicating the reason for the disposal, if the object was disposed as the result of an error.\n\t * @remarks Views can also be automatically disposed when {@link UntypedTreeView.merge | they are merged} into another view.\n\t *\n\t * Disposing branches is important to avoid consuming memory unnecessarily.\n\t * In particular, the SharedTree retains all sequenced changes made to the tree since the \"most-behind\" view was created or last {@link UntypedTreeView.rebaseOnto | rebased}.\n\t *\n\t * The {@link UntypedTreeView | main view} cannot be disposed - attempting to do so will have no effect.\n\t */\n\tdispose(error?: Error): void;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeView}.\n *\n * @deprecated Use {@link UntypedTreeView} instead.\n * @beta\n */\nexport type TreeBranch = UntypedTreeView;\n\n/**\n * Provides additional APIs that may be used to interact with a tree node or a tree node's SharedTree.\n * @alpha\n */\nexport interface TreeContextAlpha {\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t * @param transaction - A callback run during the transaction to perform user-supplied operations.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t * @param params - Optional {@link RunTransactionParamsAlpha | parameters} for the transaction.\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * `runTransaction` may be invoked on the context of a {@link TreeStatus.InDocument | hydrated } or {@link Unhydrated | unhydrated } node.\n\t * Use {@link TreeContextAlpha.isView | isView() } to check whether this context is associated with a view and gain {@link UntypedTreeViewAlpha.(runTransaction:1) | access to more transaction capabilities} if so.\n\t */\n\trunTransaction<TValue>(\n\t\ttransaction: () => WithValue<TValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TValue, TValue>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeContextAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this context.\n\t */\n\trunTransactionAsync<TValue>(\n\t\ttransaction: () => Promise<WithValue<TValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TValue, TValue>>;\n\n\t/**\n\t * An overload of {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * True if this context is associated with an {@link UntypedTreeViewAlpha | untyped view} and false if it is associated with an {@link Unhydrated | unhydrated } node.\n\t * @remarks If this returns true, the context can be safely inferred or cast to {@link UntypedTreeViewAlpha} to access additional view-specific APIs.\n\t * @example\n\t * ```typescript\n\t * const context = tree.context(someNode);\n\t * if (context.isView()) {\n\t * assert(context.hasRootSchema(MySchema)) // `hasRootSchema` is a method on UntypedTreeViewAlpha, so this is only accessible if `context` is a view context.\n\t * context.root.foo = \"bar\"; // Edit the root of the SharedTree that `someNode` belongs to.\n\t * }\n\t * ```\n\t * @returns Whether this context is associated with an untyped view.\n\t */\n\tisView(): this is UntypedTreeViewAlpha;\n\n\t/**\n\t * {@inheritDoc TreeContextAlpha.isView}\n\t * @deprecated Use {@link TreeContextAlpha.isView | isView()} instead.\n\t */\n\tisBranch(): this is UntypedTreeViewAlpha;\n}\n\n/**\n * An identifier for a commit in a {@link UntypedTreeViewAlpha}'s {@link UntypedTreeViewAlpha.branchHistory | history}.\n * @alpha\n */\nexport type CommitRevision = string;\n\n/**\n * Metadata describing a single commit in a {@link UntypedTreeViewAlpha}'s history.\n * @sealed @alpha\n */\nexport interface TreeBranchCommitMetadata {\n\t/**\n\t * The revision UUID that uniquely identifies this commit within the branch's history.\n\t */\n\treadonly revision: CommitRevision;\n\n\t/**\n\t * Arbitrary, application-defined metadata that was {@link RunTransactionParamsAlpha.customMetadata | attached}\n\t * to this commit when it was created, flattened into a single object.\n\t *\n\t * @remarks\n\t * This is `undefined` for commits that were not annotated.\n\t *\n\t * A commit may be produced by nested transactions, each of which may supply metadata. This property combines\n\t * them: where two of them used the same property, the outermost transaction wins, and between siblings the\n\t * later one wins. Use {@link TreeBranchCommitMetadata.customTree} to recover which transaction supplied what.\n\t */\n\treadonly custom: JsonCompatibleReadOnlyObject | undefined;\n\n\t/**\n\t * The {@link CustomMetadataTree | tree} of metadata attached to this commit, reflecting the nesting of\n\t * the transactions that produced it.\n\t *\n\t * @remarks\n\t * The structural counterpart to {@link TreeBranchCommitMetadata.custom}, and `undefined` whenever it is.\n\t * Prefer `custom` unless you need to know which transaction supplied a particular property.\n\t */\n\treadonly customTree: CustomMetadataTree | undefined;\n\n\t/**\n\t * The metadata for the commit that this commit was based on, or `undefined` if this commit has no parent\n\t * (i.e. it is the oldest commit in the branch's history).\n\t *\n\t * @remarks\n\t * This method may return a different value over time if the parent commit is trimmed from the branch's history.\n\t */\n\tgetParent(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * Provides APIs for querying information about the history of a {@link UntypedTreeViewAlpha}.\n * @remarks\n * The history of a branch is the sequence of commits leading up to its current state.\n * @sealed @alpha\n */\nexport interface TreeBranchHistory {\n\t/**\n\t * The number of commits in this branch's history.\n\t * @remarks\n\t * This number grows when any of the following occurs:\n\t * - A new edit is made on this branch (either through editing or by reverting an existing commit on this branch).\n\t * - A branch that contains commits not already on this branch is merged into this branch.\n\t * - The branch is rebased onto another branch that contains commits not already on this branch.\n\t * This number shrinks when past commits are trimmed from the history.\n\t */\n\treadonly length: number;\n\n\t/**\n\t * Returns metadata for the current head commit of this branch.\n\t * @returns The metadata for the head commit, or `undefined` if the branch has no commits.\n\t */\n\tgetHead(): TreeBranchCommitMetadata | undefined;\n}\n\n/**\n * An untyped view of a {@link UntypedTreeView} with alpha-level APIs.\n * @remarks\n * The untyped view for a specific {@link TreeNode} may be acquired by calling `TreeAlpha.context` and checking {@link TreeContextAlpha.isView | isView()}.\n *\n * An untyped view does not necessarily know the schema of its SharedTree. To convert it to a {@link TreeViewAlpha | view with a schema}, use {@link UntypedTreeViewAlpha.hasRootSchema | hasRootSchema()}.\n * @sealed @alpha\n */\nexport interface UntypedTreeViewAlpha extends UntypedTreeView, TreeContextAlpha {\n\t/**\n\t * Events for the view's underlying branch.\n\t */\n\treadonly events: Listenable<TreeBranchEvents>;\n\n\t/**\n\t * APIs for querying the history of the branch being viewed.\n\t */\n\treadonly branchHistory: TreeBranchHistory;\n\n\t/**\n\t * Returns true if this view has the given schema as its root schema.\n\t * @remarks This is a type guard which allows this view to become strongly typed as a {@link TreeViewAlpha | view} of the given schema.\n\t *\n\t * To succeed, the given schema must be invariant to the schema of the view - it must include exactly the same allowed types.\n\t * For example, a schema of `Foo | Bar` will not match a view schema of `Foo`, and likewise a schema of `Foo` will not match a view schema of `Foo | Bar`.\n\t * @example\n\t * ```typescript\n\t * if (view.hasRootSchema(MySchema)) {\n\t * const { root } = view; // `view` is now a TreeViewAlpha<MySchema>\n\t * // ...\n\t * }\n\t * ```\n\t */\n\thasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema>;\n\n\t// Override the base fork method to return the alpha variant.\n\tfork(): UntypedTreeViewAlpha;\n\n\t/**\n\t * Switches this view to a new underlying branch with the given commit as the head, updating the view state accordingly.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to rewind to.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t *\n\t * @remarks\n\t * Unlike {@link UntypedTreeViewAlpha.revertTo | revertTo}, this does not apply a change to the underlying branch.\n\t * The original underlying branch will be disposed.\n\t * Consider {@link UntypedTreeViewAlpha.fork | forking} before rewinding.\n\t * Not valid to invoke on the main branch or a {@link (ITreeAlpha:interface).createSharedBranch | shared branch}.\n\t */\n\trewindTo(revision: CommitRevision): void;\n\n\t/**\n\t * Applies a new change which reverts all changes made since the given `revision`.\n\t * This is a no-op if the given revision is the head commit of the underlying branch being viewed.\n\t *\n\t * @param revision - The {@link TreeBranchCommitMetadata.revision | revision} to restore the state of.\n\t * Can be obtained by navigating the commits on the {@link UntypedTreeViewAlpha.branchHistory | branch history}.\n\t * @param options - Optional {@link RevertToOptionsAlpha | options} for the revert.\n\t *\n\t * @remarks\n\t * The generated change is subject to the same merge semantics as the {@link Revertible.(revert:1) | reverts of individual commits}:\n\t * Concurrent changes that are sequenced before the revert will not be overwritten by the revert if they affect different parts of the document.\n\t *\n\t * Unlike {@link UntypedTreeViewAlpha.rewindTo | rewindTo}, this does not switch to a new branch.\n\t */\n\trevertTo(revision: CommitRevision, options?: RevertToOptionsAlpha): void;\n\n\t/**\n\t * {@link TreeContextAlpha.(runTransaction:1) | Run a transaction} on this view of the SharedTree.\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusAlpha | value or rollback signal}.\n\t * @remarks\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransaction} for an example of how to do this.\n\t */\n\trunTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatusAlpha | void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link UntypedTreeViewAlpha.(runTransaction:1) | runTransaction}.\n\t * @remarks See {@link TreeContextAlpha.(runTransactionAsync:1) | runTransactionAsync} for additional information about asynchronous transactions.\n\t */\n\n\trunTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;\n\n\t/**\n\t * An overload of {@link UntypedTreeViewAlpha.(runTransactionAsync:1) | runTransactionAsync } which does not return a value.\n\t *\n\t * @privateRemarks\n\t * TODO: Consider updating these methods to avoid the need for overloads.\n\t * See {@link TreeViewBeta.runTransactionAsync} for an example of how to do this.\n\t */\n\trunTransactionAsync(\n\t\ttransaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\n\t/**\n\t * Apply a serialized change to this branch.\n\t * @param change - the change to apply.\n\t * Changes are acquired via `getChange` in a branch's {@link TreeBranchEvents.changed | \"changed\"} event.\n\t * @remarks Changes may only be applied to a SharedTree with the same IdCompressor instance and branch state from which they were generated.\n\t * They may be created by one branch and applied to another, but only if both branches share the same history at the time of creation and application.\n\t *\n\t * @privateRemarks\n\t * TODO: This method will support applying changes from different IdCompressor instances as long as they have the same local session ID.\n\t * Update the tests and docs to match when that is done.\n\t */\n\tapplyChange(change: JsonCompatibleReadOnly): void;\n\n\t/**\n\t * Determines if there are changes on the given view that are not present on this view.\n\t * @param view - The view to compare to.\n\t *\n\t * The new edits, if any, can be applied to this view by {@link UntypedTreeView.rebaseOnto | rebasing this view onto the given view}\n\t * or by {@link UntypedTreeView.merge | merging the given view into this view}.\n\t *\n\t * @throws UsageError if the branches are unrelated.\n\t */\n\tisMissingEditsFrom(view: UntypedTreeView): boolean;\n\n\t/**\n\t * Computes the net change that would result if this view were {@link UntypedTreeView.rebaseOnto | rebased onto} the given view.\n\t * Note that this method does not actually perform the rebase and therefore has no effect on this view.\n\t *\n\t * @param view - The view that would be rebased onto.\n\t * @returns The net change that would result if this view were rebased onto the given view,\n\t * or `undefined` if rebasing would have no impact.\n\t */\n\tcomputeNetChangeIfRebasedOnto(view: UntypedTreeView): JsonCompatibleReadOnly | undefined;\n}\n\n/**\n * Compatibility alias for {@link UntypedTreeViewAlpha}.\n *\n * @deprecated Use {@link UntypedTreeViewAlpha} instead.\n * @alpha\n */\nexport type TreeBranchAlpha = UntypedTreeViewAlpha;\n\n/**\n * An editable view of a (version control style) branch of a shared tree based on some schema.\n *\n * @remarks\n * This schema (known as the view schema) may or may not align with the stored schema of the document.\n * Information about discrepancies between the two schemas is available via {@link TreeView.compatibility | compatibility}.\n *\n * Application authors are encouraged to read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/dds/tree/docs/user-facing/schema-evolution.md | schema-evolution.md}\n * and choose a schema compatibility policy that aligns with their application's needs.\n *\n * See also {@link TreeViewAlpha}, {@link TreeViewBeta} and {@link UntypedTreeView} for additional APIs that are in earlier stages of development.\n *\n * @privateRemarks\n * From an API design perspective, `upgradeSchema` could be merged into `viewWith` and/or `viewWith` could return errors explicitly on incompatible documents.\n * Such approaches would make it discoverable that out of schema handling may need to be done.\n * Doing that would however complicate trivial \"hello world\" style example slightly, as well as be a breaking API change.\n * It also seems more complex to handle invalidation with that pattern.\n * Thus this design was chosen at the risk of apps blindly accessing `root` then breaking unexpectedly when the document is incompatible.\n *\n * @see {@link TreeViewAlpha}\n * @see {@link asTreeViewAlpha}\n *\n * @sealed @public\n */\nexport interface TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable {\n\t/**\n\t * The current root of the tree.\n\t *\n\t * If the view schema not sufficiently compatible with the stored schema, accessing this will throw.\n\t * To handle this case, check {@link TreeView.compatibility | compatibility}'s {@link SchemaCompatibilityStatus.canView | canView} before using.\n\t *\n\t * To get notified about changes to this field,\n\t * use {@link TreeViewEvents.rootChanged} via `view.events.on(\"rootChanged\", callback)`.\n\t *\n\t * To get notified about changes to stored schema (which may affect compatibility between this view's schema and\n\t * the stored schema), use {@link TreeViewEvents.schemaChanged} via `view.events.on(\"schemaChanged\", callback)`.\n\t */\n\tget root(): TreeFieldFromImplicitField<TSchema>;\n\n\tset root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);\n\n\t/**\n\t * Description of the current compatibility status between the view schema and stored schema.\n\t * @remarks\n\t * {@link TreeViewEvents.schemaChanged} is fired when the compatibility status of the document's stored schema changes.\n\t * See {@link https://fluidframework.com/docs/data-structures/tree/schema-evolution/ | schema-evolution} for more guidance on how to change schema while maintaining compatibility.\n\t * Use {@link snapshotSchemaCompatibility} to write tests to validate that this compatibility behaves as desired across schema changes.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\n\t/**\n\t * When {@link SchemaCompatibilityStatus.canUpgrade} is true,\n\t * this can be used to modify the stored schema to make it match the view schema.\n\t * @remarks\n\t * This will update the {@link TreeView.compatibility}, allowing access to `root`.\n\t * Beware that this may impact other clients' ability to view the document: see {@link SchemaCompatibilityStatus.canView} for more information.\n\t *\n\t * It is an error to call this when {@link SchemaCompatibilityStatus.canUpgrade} is false.\n\t * {@link SchemaCompatibilityStatus.canUpgrade} being true does not mean that an upgrade is required, nor that an upgrade will have any effect.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the target stored schema.\n\t * Set {@link (StagedSchemaUpgradePolicy:interface).includeAlreadyEnabledUpgrades} to `true` to\n\t * also include staged upgrades that are already enabled in the document.\n\t *\n\t * @example Enabling a staged allowed type for documents, selected by a feature flag\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactoryBeta(\"my-app\");\n\t *\n\t * class TaskItem extends sf.object(\"TaskItem\", { title: sf.string }) {}\n\t * class ChecklistItem extends sf.object(\"ChecklistItem\", { text: sf.string }) {}\n\t *\n\t * // `staged` wraps ChecklistItem so it can be enabled at runtime.\n\t * const stagedChecklist = SchemaFactoryBeta.staged(ChecklistItem);\n\t * const checklistUpgrade = stagedChecklist.metadata.stagedSchemaUpgrade;\n\t *\n\t * class AppSchema extends sf.object(\"AppSchema\", {\n\t * items: sf.array([TaskItem, stagedChecklist]),\n\t * }) {}\n\t *\n\t * // Feature flag controls whether the upgrade is enabled for this session.\n\t * const policy = featureFlags.enableChecklist\n\t * ? StagedSchemaUpgradePolicy.enabledStagedUpgrades(checklistUpgrade)\n\t * : undefined;\n\t *\n\t * const view = tree.viewWith(\n\t * new TreeViewConfigurationAlpha({ schema: AppSchema, stagedUpgradePolicy: policy }),\n\t * );\n\t *\n\t * if (view.compatibility.canUpgrade) {\n\t * // Writes the staged type into the document's stored schema.\n\t * view.upgradeSchema();\n\t * }\n\t * ```\n\t *\n\t * @privateRemarks\n\t * In the future, more upgrade options could be provided here.\n\t * Some options that could be added:\n\t * - check the actual document contents (not just the schema) and attempt an atomic document update if the data is compatible.\n\t * - apply converters and upgrade the document.\n\t * - apply converters to lazily to adapt the document to the requested view schema (with optional lazy schema updates or transparent conversions on write).\n\t * - update only a specific change (add an optional field, or apply a staged upgrade)\n\t * - update persistedMetadata or not\n\t *\n\t * As persisted metadata becomes more supported, how it interacts with isEquivalent and upgradeSchema should be clarified:\n\t * for now the docs are being left somewhat vague to allow flexibility in this area.\n\t */\n\tupgradeSchema(): void;\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * When using {@link TreeViewConfigurationAlpha} with a {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy},\n\t * staged schema upgrades matching the configured policy are included in the initial stored schema.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;\n\n\t/**\n\t * Events for the tree.\n\t */\n\treadonly events: Listenable<TreeViewEvents>;\n\n\t/**\n\t * The view schema used by this TreeView.\n\t */\n\treadonly schema: TSchema;\n}\n\n/**\n * A discrepancy between a view schema and a document's stored schema.\n *\n * @remarks\n * The `mismatch` property discriminates the different discrepancy shapes.\n *\n * @sealed @beta\n */\nexport type SchemaDiscrepancy =\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a field allows different node types in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"allowedTypes\";\n\t\t\t/**\n\t\t\t * The field with the discrepancy.\n\t\t\t *\n\t\t\t * `\"root\"` identifies the root field. Otherwise, `nodeType` identifies the containing\n\t\t\t * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map\n\t\t\t * node's implicit field.\n\t\t\t */\n\t\t\treadonly location:\n\t\t\t\t| \"root\"\n\t\t\t\t| {\n\t\t\t\t\t\treadonly nodeType: string;\n\t\t\t\t\t\treadonly fieldKey: string | undefined;\n\t\t\t\t };\n\t\t\t/**\n\t\t\t * Non-staged node type identifiers allowed by the view schema but not the stored schema.\n\t\t\t */\n\t\t\treadonly view: readonly string[];\n\t\t\t/**\n\t\t\t * Staged node type identifiers allowed by the view schema but not the stored schema.\n\t\t\t *\n\t\t\t * @remarks These types provide rollout context but do not cause the discrepancy.\n\t\t\t */\n\t\t\treadonly stagedView?: readonly string[];\n\t\t\t/**\n\t\t\t * Node type identifiers allowed by the stored schema but not the view schema.\n\t\t\t */\n\t\t\treadonly stored: readonly string[];\n\t\t\t/**\n\t\t\t * Whether the view field is a staged optional field.\n\t\t\t *\n\t\t\t * @remarks Omitted when false.\n\t\t\t */\n\t\t\treadonly viewIsStagedOptional?: true;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a field has different field kinds in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"fieldKind\";\n\t\t\t/**\n\t\t\t * The field with the discrepancy.\n\t\t\t *\n\t\t\t * `\"root\"` identifies the root field. Otherwise, `nodeType` identifies the containing\n\t\t\t * node schema and `fieldKey` identifies its field. `fieldKey` is undefined for a map\n\t\t\t * node's implicit field.\n\t\t\t */\n\t\t\treadonly location:\n\t\t\t\t| \"root\"\n\t\t\t\t| {\n\t\t\t\t\t\treadonly nodeType: string;\n\t\t\t\t\t\treadonly fieldKey: string | undefined;\n\t\t\t\t };\n\t\t\t/**\n\t\t\t * The field kind required by the view schema.\n\t\t\t */\n\t\t\treadonly view: string;\n\t\t\t/**\n\t\t\t * The field kind recorded in the stored schema.\n\t\t\t */\n\t\t\treadonly stored: string;\n\t\t\t/**\n\t\t\t * Whether the view field is a staged optional field.\n\t\t\t *\n\t\t\t * @remarks Omitted when false.\n\t\t\t */\n\t\t\treadonly viewIsStagedOptional?: true;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a leaf node accepts different value types in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"valueSchema\";\n\t\t\t/**\n\t\t\t * The identifier of the leaf node schema with the discrepancy.\n\t\t\t */\n\t\t\treadonly nodeType: string;\n\t\t\t/**\n\t\t\t * The value schema required by the view, or undefined when it does not constrain values.\n\t\t\t */\n\t\t\treadonly view: string | undefined;\n\t\t\t/**\n\t\t\t * The value schema recorded in the stored schema, or undefined when it does not constrain values.\n\t\t\t */\n\t\t\treadonly stored: string | undefined;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Indicates that a node is represented by different node kinds in the view and stored schemas.\n\t\t\t */\n\t\t\treadonly mismatch: \"nodeKind\";\n\t\t\t/**\n\t\t\t * The identifier of the node schema with the discrepancy.\n\t\t\t */\n\t\t\treadonly nodeType: string;\n\t\t\t/**\n\t\t\t * The node kind required by the view schema.\n\t\t\t */\n\t\t\treadonly view: string;\n\t\t\t/**\n\t\t\t * The node kind recorded in the stored schema.\n\t\t\t */\n\t\t\treadonly stored: string;\n\t };\n\n/**\n * {@link SchemaCompatibilityStatus} with additional beta APIs.\n *\n * @sealed @beta\n */\nexport interface SchemaCompatibilityStatusBeta extends SchemaCompatibilityStatus {\n\t/**\n\t * Details about the schema discrepancies that prevent this view from accessing the tree.\n\t *\n\t * @remarks\n\t * This property is undefined when {@link SchemaCompatibilityStatus.canView} is true and present\n\t * when `canView` is false.\n\t * It can include application-defined schema identifiers and field keys.\n\t *\n\t * @example Interpreting an allowed-types discrepancy\n\t *\n\t * If a document's stored schema allows `string` for `Todo.title`, but the view schema expects\n\t * `number`, the discrepancy identifies the field and the type permitted by each schema:\n\t *\n\t * ```typescript\n\t * const sf = new SchemaFactory(\"com.example\");\n\t * class Todo extends sf.object(\"Todo\", {\n\t * \ttitle: sf.number,\n\t * }) {}\n\t *\n\t * const view = asBeta(tree.viewWith(new TreeViewConfiguration({ schema: Todo })));\n\t * if (!view.compatibility.canView) {\n\t * \t// [{\n\t * \t// mismatch: \"allowedTypes\",\n\t * \t// location: { nodeType: \"com.example.Todo\", fieldKey: \"title\" },\n\t * \t// view: [\"com.fluidframework.leaf.number\"],\n\t * \t// stored: [\"com.fluidframework.leaf.string\"],\n\t * \t// }]\n\t * \tconsole.error(view.compatibility.discrepancies);\n\t * }\n\t * ```\n\t */\n\treadonly discrepancies: readonly SchemaDiscrepancy[] | undefined;\n}\n\n/**\n * {@link TreeView} with additional beta APIs.\n * @sealed @beta\n */\nexport interface TreeViewBeta<in out TSchema extends ImplicitFieldSchema>\n\textends TreeView<TSchema>,\n\t\tUntypedTreeView {\n\t/**\n\t * {@inheritDoc TreeView.compatibility}\n\t */\n\treadonly compatibility: SchemaCompatibilityStatusBeta;\n\n\t// Override the base branch method to return a typed view rather than merely a branch.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewBeta<TSchema>;\n\n\t/**\n\t * Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.\n\t *\n\t * @param transaction - The function to run as the body of the transaction, which may optionally return a {@link TransactionCallbackStatusBeta | value or rollback signal}.\n\t * It may optionally return a {@link WithValue | value }, which will be returned by the `runTransaction` call.\n\t *\n\t * @param params - Optional {@link RunTransactionParamsBeta | parameters} for the transaction.\n\t *\n\t * @returns A {@link TransactionValueResult | value } indicating whether or not the transaction succeeded, and containing the value returned by `transaction`.\n\t *\n\t * @remarks\n\t * All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes.\n\t * Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.\n\t *\n\t * {@link (TreeBeta:interface).on | Change events } will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction.\n\t * Any other/future clients or contexts will process the transaction \"squashed\", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction).\n\t * Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.\n\t *\n\t * Using a transaction has the following additional consequences:\n\t *\n\t * - If {@link Revertible | reverted } (e.g. via an \"undo\" operation), all the changes in the transaction are reverted together.\n\t * Only the \"outermost\" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted.\n\t * If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction.\n\t * - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.\n\t *\n\t * If the transaction is rolled back, a corresponding {@link TreeBranchEvents.changed | `changed`} event will also be emitted for the rollback.\n\t */\n\trunTransaction<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => TOut,\n\t\tparams?: RunTransactionParamsBeta,\n\t): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t: TransactionVoidResult;\n\n\t/**\n\t * An asynchronous version of {@link TreeViewBeta.runTransaction | runTransaction}.\n\t *\n\t * @remarks\n\t * As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit.\n\t * Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.\n\t *\n\t * Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress.\n\t * Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.\n\t *\n\t * An asynchronous transaction may not be started while any other transaction is in progress in this view.\n\t */\n\trunTransactionAsync<\n\t\tTOut extends\n\t\t\t| TransactionCallbackStatusBeta<unknown, unknown>\n\t\t\t| VoidTransactionCallbackStatusBeta\n\t\t\t| void,\n\t>(\n\t\ttransaction: () => Promise<TOut>,\n\t\tparams?: RunTransactionParamsBeta,\n\t): Promise<\n\t\tTOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue>\n\t\t\t? TransactionValueResult<TSuccessValue, TFailureValue>\n\t\t\t: TransactionVoidResult\n\t>;\n}\n\n/**\n * {@link TreeView} with proposed changes to the schema aware typing to allow use with `UnsafeUnknownSchema`.\n * @sealed @alpha\n */\nexport interface TreeViewAlpha<\n\tin out TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> extends Omit<\n\t\t\tTreeViewBeta<ReadSchema<TSchema>>,\n\t\t\t\"root\" | \"initialize\" | \"fork\" | \"runTransaction\" | \"runTransactionAsync\"\n\t\t>,\n\t\tUntypedTreeViewAlpha {\n\tget root(): ReadableField<TSchema>;\n\n\tset root(newRoot: InsertableField<TSchema>);\n\n\t/**\n\t * Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.\n\t *\n\t * @remarks\n\t * Only valid to call when this view's {@link SchemaCompatibilityStatus.canInitialize} is true.\n\t *\n\t * Enables staged schema upgrades declared by {@link ITreeViewConfigurationAlpha.stagedUpgradePolicy} when generating the initial stored schema.\n\t *\n\t * Applications should typically call this function before attaching a `SharedTree`.\n\t * @param content - The content to initialize the tree with.\n\t */\n\tinitialize(content: InsertableField<TSchema>): void;\n\n\t/**\n\t * Checks whether a staged schema upgrade has been applied to the document's stored schema.\n\t *\n\t * @param upgrade - The upgrade token to check.\n\t *\n\t * @returns The {@link StagedUpgradeStatus} of the upgrade.\n\t *\n\t * @remarks\n\t * Use this to determine whether a document has already been upgraded, for example when deciding\n\t * whether to include an upgrade token in the view configuration after a feature flag rollback.\n\t *\n\t * Results are derived from this view's schema and the current stored schema.\n\t * The full schema is checked even when the view is incompatible with the stored schema, so the\n\t * result includes all locations declared by the view schema.\n\t */\n\tisStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus;\n\n\treadonly events: Listenable<TreeViewEvents & TreeBranchEvents>;\n\n\t// Override the base fork method to return a TreeViewAlpha.\n\tfork(): ReturnType<UntypedTreeView[\"fork\"]> & TreeViewAlpha<TSchema>;\n}\n\n/**\n * Information about a view schema's compatibility with the document's stored schema.\n *\n * @see\n * See SharedTree's README for more information about choosing a compatibility policy.\n *\n * @privateRemarks\n * See {@link checkSchemaCompatibility} for the implementation of this compatibility checking.\n *\n * @sealed @public\n */\nexport interface SchemaCompatibilityStatus {\n\t/**\n\t * Whether the view schema allows exactly the same set of documents as the stored schema.\n\t *\n\t * @remarks\n\t * Equivalence here is defined in terms of allowed documents because there are some degenerate cases where schemas are not\n\t * exact matches in a strict (schema-based) sense but still allow the same documents, and the document notion is more useful to applications.\n\t *\n\t * Examples which are expressible where this may occur include:\n\t *\n\t * - schema repository `A` has extra schema which schema `B` doesn't have, but they are unused (i.e. not reachable from the root schema)\n\t *\n\t * - field in schema `A` has allowed field members which the corresponding field in schema `B` does not have, but those types are not constructible (for example: an object node type containing a required field with no allowed types)\n\t *\n\t * These cases are typically not interesting to applications.\n\t *\n\t * Note that other content in the stored schema that does not impact document compatibility, like {@link NodeSchemaOptionsAlpha.persistedMetadata}, does not affect this field.\n\t *\n\t * For the computation of this equivalence, {@link SchemaStaticsBeta.staged | staged} schemas are not included.\n\t * If there are any unknown optional fields, even if allowed by {@link ObjectSchemaOptions.allowUnknownOptionalFields}, `isEquivalent` will be false.\n\t */\n\treadonly isEquivalent: boolean;\n\n\t/**\n\t * Whether the current view schema is sufficiently compatible with the stored schema to allow viewing tree data.\n\t * If false, {@link TreeView.root} will throw upon access.\n\t * @remarks\n\t * If the view schema does not opt into supporting any additional cases, then `canView` is only true when `isEquivalent` is also true.\n\t * The view schema can however opt into supporting additional cases, and thus can also view documents with stored schema which would be equivalent, except for the following discrepancies:\n\t *\n\t * - An object node with {@link ObjectSchemaOptions.allowUnknownOptionalFields} to set to true that has additional optional fields in the stored schema beyond those mentioned in its view schema.\n\t *\n\t * - An additional type allowed at a location in the stored schema where it is {@link SchemaStaticsBeta.staged | staged} in the view schema.\n\t *\n\t * In these cases `canUpgrade` and `isEquivalent` will be false.\n\t *\n\t * When the set of documents allowed by the view schema is a strict superset of those allowed by the stored schema,\n\t * `canView` is false because writes to the document using the view schema could make the document violate its stored schema.\n\t * In this case, the stored schema could be updated to match the provided view schema, allowing read-write access to the tree.\n\t * See {@link SchemaCompatibilityStatus.canUpgrade}.\n\t *\n\t * Future versions of SharedTree may provide readonly access to the document in this case because that would be safe,\n\t * but this is not currently supported.\n\t *\n\t * @privateRemarks\n\t * A necessary condition for this to be true is that the documents allowed by the view schema are a subset of those allowed by the stored schema.\n\t * This is not sufficient: the simple-tree layer's read APIs only tolerate very specific cases beyond their schema (unknown optional fields).\n\t * For example, if the view schema for a node has a required `Point` field but the stored schema has an optional `Point` field,\n\t * read APIs on the view schema do not work correctly when the document has a node with a missing `Point` field.\n\t * Similar issues happen when the view schema has a field with less allowed types than the stored schema and the document actually leverages those types.\n\t */\n\treadonly canView: boolean;\n\n\t/**\n\t * True when {@link TreeView.upgradeSchema} can add support for all content required to be supported by the view schema.\n\t * @remarks\n\t * When true, it is valid to call {@link TreeView.upgradeSchema} (though if the stored schema is already an exact match, this is a no-op).\n\t *\n\t * When adding optional fields to schema which previously were marked with {@link ObjectSchemaOptions.allowUnknownOptionalFields}\n\t * the schema upgrade (assuming no other changes are included) will allow the previous version to view.\n\t * Even this case must still must be done with caution however as only clients with the newly added field will be able to do future upgrades.\n\t * Thus if a version of an application is shipped that adds an unknown optional field, all future versions should include it, even if its no longer used,\n\t * to ensure that documents containing it can still be upgraded.\n\t */\n\treadonly canUpgrade: boolean;\n\n\t/**\n\t * True iff the document is uninitialized (i.e. it has no schema and no content).\n\t *\n\t * To initialize the document, call {@link TreeView.initialize}.\n\t *\n\t * @remarks\n\t * It's not necessary to check this field before calling {@link TreeView.initialize} in most scenarios; application authors typically know from\n\t * branch that they're in a flow which creates a new `SharedTree` and would like to initialize it.\n\t */\n\treadonly canInitialize: boolean;\n\n\t// TODO: Consider extending this status to include:\n\t// - application-defined metadata about the stored schema\n\t// - details about the differences between the stored and view schema sufficient for implementing \"safe mismatch\" policies\n}\n\n/**\n * Events for {@link UntypedTreeView}.\n * @sealed @alpha\n */\nexport interface TreeBranchEvents {\n\t/**\n\t * Fired when a change is made to the branch. Includes data about the change that is made which listeners\n\t * can use to filter on changes they care about (e.g. local vs. remote changes).\n\t *\n\t * @param data - information about the change\n\t * @param getRevertible - a function that allows users to get a revertible for the change. If not provided,\n\t * this change is not revertible.\n\t */\n\tchanged(data: ChangeMetadata, getRevertible?: RevertibleAlphaFactory): void;\n}\n\n/**\n * Events for {@link TreeView}.\n * @remarks\n * See {@link TreeBranchEvents} for more events related to the underlying branch of the SharedTree.\n * @sealed @public\n */\nexport interface TreeViewEvents {\n\t/**\n\t * Raised whenever {@link TreeView.root} is invalidated.\n\t *\n\t * This includes changes to the document schema.\n\t * It also includes changes to the field containing the root such as setting or clearing an optional root or changing which node is the root.\n\t * This does NOT include changes to the content (fields/children) of the root node: for that case subscribe to events on the root node.\n\t */\n\trootChanged(): void;\n\n\t/**\n\t * The stored schema for the document has changed.\n\t * This may affect the compatibility between the view schema and the stored schema, and thus the ability to use the view.\n\t *\n\t * @remarks\n\t * This event implies that the old {@link TreeView.root} is no longer valid, but applications need not handle that separately:\n\t * {@link TreeViewEvents.rootChanged} will be fired after this event.\n\t */\n\tschemaChanged(): void;\n\n\t/**\n\t * Fired when:\n\t *\n\t * - a local commit is applied outside of a transaction\n\t *\n\t * - a local transaction is committed\n\t *\n\t * The event is not fired when:\n\t *\n\t * - a local commit is applied within a transaction\n\t *\n\t * - a remote commit is applied\n\t *\n\t * @param data - information about the commit that was applied\n\t * @param getRevertible - a function provided that allows users to get a revertible for the commit that was applied. If not provided,\n\t * this commit is not revertible.\n\t */\n\tcommitApplied(data: CommitMetadata, getRevertible?: RevertibleFactory): void;\n}\n\n/**\n * Retrieve the {@link TreeViewAlpha | alpha API} for a {@link TreeView}.\n * @alpha\n * @deprecated Use {@link (asAlpha:1)} instead.\n * @privateRemarks Despite being deprecated, this function should be used within the tree package (outside of tests) rather than `asAlpha` in order to avoid circular import dependencies.\n */\nexport function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeViewAlpha<TSchema> {\n\treturn view as TreeViewAlpha<TSchema>;\n}\n"]}
@@ -13,7 +13,7 @@ export interface StagedSchemaUpgradePolicy {
13
13
  * Whether schema upgrades should include staged upgrades that are already enabled in the
14
14
  * document's stored schema.
15
15
  *
16
- * @defaultValue `true`
16
+ * @defaultValue `false`
17
17
  */
18
18
  readonly includeAlreadyEnabledUpgrades?: boolean;
19
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"toStored.js","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8FH;;;GAGG;AACU,QAAA,yBAAyB,GAAqC;IAC1E,WAAW,EAAE;QACZ,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK;QAC1B,qBAAqB,EAAE,GAAG,EAAE,CAAC,KAAK;KAClC;IAED,UAAU,EAAE;QACX,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI;QACzB,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI;KACjC;IAED,qBAAqB,CAAC,GAAG,QAAyB;QACjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,iCAAyB,CAAC,WAAW,CAAC;QAC9C,CAAC;QACD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO;YACN,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC;YAC1D,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC;SAClE,CAAC;IACH,CAAC;CACD,CAAC;AAEF;;GAEG;AACU,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAGnD;;;;GAIG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SchemaUpgrade } from \"./allowedTypes.js\";\n\n/**\n * Policy controlling which staged schema upgrades are included when generating stored schema from a view schema.\n * @input\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicy {\n\t/**\n\t * Whether schema upgrades should include staged upgrades that are already enabled in the\n\t * document's stored schema.\n\t *\n\t * @defaultValue `true`\n\t */\n\treadonly includeAlreadyEnabledUpgrades?: boolean;\n\n\t/**\n\t * Determines whether to include staged allowed types in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStaged(upgrade: SchemaUpgrade): boolean;\n\n\t/**\n\t * Determines whether to treat a staged optional field as optional\n\t * (rather than required) in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStagedOptional(upgrade: SchemaUpgrade): boolean;\n}\n\n/**\n * Provides factory methods for creating {@link (StagedSchemaUpgradePolicy:interface)} instances.\n *\n * @remarks\n * Use the properties and methods on this object to obtain staged-schema generation options\n * for different scenarios:\n *\n * - {@link StagedSchemaUpgradePolicyFactory.restrictive} — no staged upgrades (default)\n *\n * - {@link StagedSchemaUpgradePolicyFactory.permissive} — all staged upgrades enabled\n *\n * - {@link StagedSchemaUpgradePolicyFactory.enabledStagedUpgrades} — only specific upgrades enabled\n *\n * @example\n * ```typescript\n * // Enable specific upgrades:\n * const options = StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade);\n *\n * // Use restrictive (default, no staged upgrades):\n * const options = StagedSchemaUpgradePolicy.restrictive;\n *\n * // Use permissive (all staged upgrades, useful for testing):\n * const options = StagedSchemaUpgradePolicy.permissive;\n * ```\n *\n * @sealed\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicyFactory {\n\t/**\n\t * Restrictive policy — excludes all staged schema members.\n\t *\n\t * @remarks\n\t * Use this when you want the most conservative stored schema for compatibility-sensitive\n\t * scenarios, or when staged schema upgrades should remain disabled.\n\t *\n\t * This is the default behavior when no staged upgrades are enabled.\n\t */\n\treadonly restrictive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Permissive policy — includes all staged schema upgrades.\n\t *\n\t * @remarks\n\t * Use this for testing, validation, and rollout rehearsal scenarios where you want to exercise\n\t * future document shapes before enabling staged upgrades broadly.\n\t */\n\treadonly permissive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Creates options that include only the specified staged schema upgrades.\n\t *\n\t * @param upgrades - The staged schema upgrades to enable.\n\t * @returns Options that include only the specified upgrades.\n\t *\n\t * @remarks\n\t * If an empty set of upgrades is passed, the result is equivalent to\n\t * `StagedSchemaUpgradePolicy.restrictive`.\n\t */\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy;\n}\n\n/**\n * {@inheritDoc (StagedSchemaUpgradePolicyFactory:interface)}\n * @alpha\n */\nexport const StagedSchemaUpgradePolicy: StagedSchemaUpgradePolicyFactory = {\n\trestrictive: {\n\t\tincludeStaged: () => false,\n\t\tincludeStagedOptional: () => false,\n\t},\n\n\tpermissive: {\n\t\tincludeStaged: () => true,\n\t\tincludeStagedOptional: () => true,\n\t},\n\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy {\n\t\tif (upgrades.length === 0) {\n\t\t\treturn StagedSchemaUpgradePolicy.restrictive;\n\t\t}\n\t\tconst enabledUpgradeSet = new Set(upgrades);\n\t\treturn {\n\t\t\tincludeStaged: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t\tincludeStagedOptional: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t};\n\t},\n};\n\n/**\n * Marker type indicating that the input schema is already a stored schema.\n */\nexport const ExpectStored = Symbol(\"ExpectStored\");\nexport type ExpectStored = typeof ExpectStored;\n\n/**\n * Marker type indicating that the input schema should not be transformed: data accessible from the simple schema API surface should be copied as is.\n * @remarks\n * The only real use-cases for this are deep-copying simple schema, and copying objects that implement more than just simple schema (such as {@link TreeSchema}) into simple object without extra prototypes and properties.\n */\nexport const Unchanged = Symbol(\"Unchanged\");\nexport type Unchanged = typeof Unchanged;\n\n/**\n * Subset of {@link SimpleSchemaTransformationOptions} for when the output is a known to be a stored schema.\n */\nexport type StoredSchemaGenerationOptions = StagedSchemaUpgradePolicy | ExpectStored;\n\n/**\n * Options for transforming a schema.\n * @remarks\n * See also {@link generateSchemaFromSimpleSchema} for a different schema transformation.\n * Note that if we want to make `generateSchemaFromSimpleSchema` consume view simple-schema, and use these transformation APIs to generate that view simple-schema from a stored simple-schema,\n * we will need to add a \"ToView\" option here.\n */\nexport type SimpleSchemaTransformationOptions =\n\t| StagedSchemaUpgradePolicy\n\t| ExpectStored\n\t| Unchanged;\n"]}
1
+ {"version":3,"file":"toStored.js","sourceRoot":"","sources":["../../../src/simple-tree/core/toStored.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8FH;;;GAGG;AACU,QAAA,yBAAyB,GAAqC;IAC1E,WAAW,EAAE;QACZ,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK;QAC1B,qBAAqB,EAAE,GAAG,EAAE,CAAC,KAAK;KAClC;IAED,UAAU,EAAE;QACX,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI;QACzB,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI;KACjC;IAED,qBAAqB,CAAC,GAAG,QAAyB;QACjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,iCAAyB,CAAC,WAAW,CAAC;QAC9C,CAAC;QACD,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO;YACN,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC;YAC1D,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC;SAClE,CAAC;IACH,CAAC;CACD,CAAC;AAEF;;GAEG;AACU,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAGnD;;;;GAIG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SchemaUpgrade } from \"./allowedTypes.js\";\n\n/**\n * Policy controlling which staged schema upgrades are included when generating stored schema from a view schema.\n * @input\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicy {\n\t/**\n\t * Whether schema upgrades should include staged upgrades that are already enabled in the\n\t * document's stored schema.\n\t *\n\t * @defaultValue `false`\n\t */\n\treadonly includeAlreadyEnabledUpgrades?: boolean;\n\n\t/**\n\t * Determines whether to include staged allowed types in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStaged(upgrade: SchemaUpgrade): boolean;\n\n\t/**\n\t * Determines whether to treat a staged optional field as optional\n\t * (rather than required) in the resulting stored schema.\n\t * @remarks\n\t * Due to caching, the behavior of this function must be pure.\n\t */\n\tincludeStagedOptional(upgrade: SchemaUpgrade): boolean;\n}\n\n/**\n * Provides factory methods for creating {@link (StagedSchemaUpgradePolicy:interface)} instances.\n *\n * @remarks\n * Use the properties and methods on this object to obtain staged-schema generation options\n * for different scenarios:\n *\n * - {@link StagedSchemaUpgradePolicyFactory.restrictive} — no staged upgrades (default)\n *\n * - {@link StagedSchemaUpgradePolicyFactory.permissive} — all staged upgrades enabled\n *\n * - {@link StagedSchemaUpgradePolicyFactory.enabledStagedUpgrades} — only specific upgrades enabled\n *\n * @example\n * ```typescript\n * // Enable specific upgrades:\n * const options = StagedSchemaUpgradePolicy.enabledStagedUpgrades(myUpgrade);\n *\n * // Use restrictive (default, no staged upgrades):\n * const options = StagedSchemaUpgradePolicy.restrictive;\n *\n * // Use permissive (all staged upgrades, useful for testing):\n * const options = StagedSchemaUpgradePolicy.permissive;\n * ```\n *\n * @sealed\n * @alpha\n */\nexport interface StagedSchemaUpgradePolicyFactory {\n\t/**\n\t * Restrictive policy — excludes all staged schema members.\n\t *\n\t * @remarks\n\t * Use this when you want the most conservative stored schema for compatibility-sensitive\n\t * scenarios, or when staged schema upgrades should remain disabled.\n\t *\n\t * This is the default behavior when no staged upgrades are enabled.\n\t */\n\treadonly restrictive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Permissive policy — includes all staged schema upgrades.\n\t *\n\t * @remarks\n\t * Use this for testing, validation, and rollout rehearsal scenarios where you want to exercise\n\t * future document shapes before enabling staged upgrades broadly.\n\t */\n\treadonly permissive: StagedSchemaUpgradePolicy;\n\t/**\n\t * Creates options that include only the specified staged schema upgrades.\n\t *\n\t * @param upgrades - The staged schema upgrades to enable.\n\t * @returns Options that include only the specified upgrades.\n\t *\n\t * @remarks\n\t * If an empty set of upgrades is passed, the result is equivalent to\n\t * `StagedSchemaUpgradePolicy.restrictive`.\n\t */\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy;\n}\n\n/**\n * {@inheritDoc (StagedSchemaUpgradePolicyFactory:interface)}\n * @alpha\n */\nexport const StagedSchemaUpgradePolicy: StagedSchemaUpgradePolicyFactory = {\n\trestrictive: {\n\t\tincludeStaged: () => false,\n\t\tincludeStagedOptional: () => false,\n\t},\n\n\tpermissive: {\n\t\tincludeStaged: () => true,\n\t\tincludeStagedOptional: () => true,\n\t},\n\n\tenabledStagedUpgrades(...upgrades: SchemaUpgrade[]): StagedSchemaUpgradePolicy {\n\t\tif (upgrades.length === 0) {\n\t\t\treturn StagedSchemaUpgradePolicy.restrictive;\n\t\t}\n\t\tconst enabledUpgradeSet = new Set(upgrades);\n\t\treturn {\n\t\t\tincludeStaged: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t\tincludeStagedOptional: (upgrade) => enabledUpgradeSet.has(upgrade),\n\t\t};\n\t},\n};\n\n/**\n * Marker type indicating that the input schema is already a stored schema.\n */\nexport const ExpectStored = Symbol(\"ExpectStored\");\nexport type ExpectStored = typeof ExpectStored;\n\n/**\n * Marker type indicating that the input schema should not be transformed: data accessible from the simple schema API surface should be copied as is.\n * @remarks\n * The only real use-cases for this are deep-copying simple schema, and copying objects that implement more than just simple schema (such as {@link TreeSchema}) into simple object without extra prototypes and properties.\n */\nexport const Unchanged = Symbol(\"Unchanged\");\nexport type Unchanged = typeof Unchanged;\n\n/**\n * Subset of {@link SimpleSchemaTransformationOptions} for when the output is a known to be a stored schema.\n */\nexport type StoredSchemaGenerationOptions = StagedSchemaUpgradePolicy | ExpectStored;\n\n/**\n * Options for transforming a schema.\n * @remarks\n * See also {@link generateSchemaFromSimpleSchema} for a different schema transformation.\n * Note that if we want to make `generateSchemaFromSimpleSchema` consume view simple-schema, and use these transformation APIs to generate that view simple-schema from a stored simple-schema,\n * we will need to add a \"ToView\" option here.\n */\nexport type SimpleSchemaTransformationOptions =\n\t| StagedSchemaUpgradePolicy\n\t| ExpectStored\n\t| Unchanged;\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/tree";
8
- export declare const pkgVersion = "2.118.0";
8
+ export declare const pkgVersion = "2.118.1";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/tree";
8
- export const pkgVersion = "2.118.0";
8
+ export const pkgVersion = "2.118.1";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.118.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.118.1\";\n"]}
@@ -166,7 +166,7 @@ let SchematizingSimpleTreeView = (() => {
166
166
  }
167
167
  get effectiveUpgradePolicy() {
168
168
  const configuredPolicy = this.stagedUpgradePolicy;
169
- if (configuredPolicy.includeAlreadyEnabledUpgrades === false) {
169
+ if (configuredPolicy.includeAlreadyEnabledUpgrades !== true) {
170
170
  return configuredPolicy;
171
171
  }
172
172
  const enabledUpgrades = this.currentEnabledUpgrades;
@@ -1 +1 @@
1
- {"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE1F,OAAO,EAAE,UAAU,EAAE,YAAY,EAA6B,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAEN,mBAAmB,EACnB,qBAAqB,EACrB,OAAO,EACP,aAAa,EAGb,UAAU,EAEV,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAKN,sBAAsB,EACtB,QAAQ,EACR,oBAAoB,EACpB,wBAAwB,EAexB,eAAe,EACf,iBAAiB,EACjB,2BAA2B,EAC3B,8BAA8B,EAE9B,kBAAkB,EAClB,gBAAgB,EAChB,0BAA0B,EAC1B,eAAe,EACf,eAAe,GAMf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,aAAa,EACb,aAAa,GAGb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGtF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,EAAiC,CAAC;AAEpE,SAAS,2BAA2B,CAAC,aAA4C;IAChF,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO;IACR,CAAC;IAED,MAAM,UAAU,GAAG,aAAa,CAAC,aAAa;QAC7C,CAAC,CAAC,oGAAoG;QACtG,CAAC,CAAC,aAAa,CAAC,UAAU;YACzB,CAAC,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,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;QAEM,6BAA6B,CACnC,OAA6B;YAE7B,OAAO,IAAI,CAAC,QAAQ,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;QAED,uBAAuB;QAEvB,IAAW,aAAa;YACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;QACpC,CAAC;;;;;QAlhBF,6KAmhBC;;;QAnhBY,uDAA0B;;;;SAA1B,0BAA0B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tHasListeners,\n\tIEmitter,\n\tListenable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { tagSchemaArtifacts, UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { anchorSlot, rootFieldKey, type RevertToOptionsAlpha } from \"../core/index.js\";\nimport {\n\ttype NodeIdentifierManager,\n\tdefaultSchemaPolicy,\n\tcursorForMapTreeField,\n\tContext,\n\tcombineChunks,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeUnknownUnboxed,\n\tFieldKinds,\n\ttype FlexTreeRequiredField,\n\tallowsRepoSuperset,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatusBeta,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\ttryGetTreeNodeForField,\n\tsetField,\n\tnormalizeFieldSchema,\n\tcheckSchemaCompatibility,\n\ttype InsertableContent,\n\ttype StagedSchemaUpgradePolicy,\n\ttype TreeViewConfiguration,\n\ttype TreeViewAlpha,\n\ttype InsertableField,\n\ttype ReadableField,\n\ttype ReadSchema,\n\ttype UnsafeUnknownSchema,\n\ttype TreeBranchEvents,\n\ttype VoidTransactionCallbackStatusAlpha,\n\ttype TransactionCallbackStatusAlpha,\n\ttype TransactionVoidResult,\n\ttype TransactionValueResult,\n\ttype RunTransactionParamsAlpha,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tareImplicitFieldSchemaEqual,\n\tprepareForInsertionContextless,\n\ttype FieldSchema,\n\ttryDisposeTreeNode,\n\tFieldSchemaAlpha,\n\tTreeViewConfigurationAlpha,\n\ttoInitialSchema,\n\ttoUpgradeSchema,\n\ttype TreeBranchHistory,\n\ttype UntypedTreeViewAlpha,\n\ttype TreeSchema,\n\ttype SchemaUpgrade,\n\ttype StagedUpgradeStatus,\n} from \"../simple-tree/index.js\";\nimport {\n\ttype Breakable,\n\tbreakingClass,\n\tdisposeSymbol,\n\ttype JsonCompatibleReadOnly,\n\ttype WithBreakable,\n} from \"../util/index.js\";\n\nimport { canInitialize, initialize, initializerFromChunk } from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\n\n/**\n * Creating multiple tree views from the same checkout is not supported. This slot is used to detect if one already\n * exists and error if creating a second.\n */\nexport const ViewSlot = anchorSlot<TreeView<ImplicitFieldSchema>>();\n\nfunction throwIfSchemaIsIncompatible(compatibility: SchemaCompatibilityStatusBeta): void {\n\tif (compatibility.canView) {\n\t\treturn;\n\t}\n\n\tconst resolution = compatibility.canInitialize\n\t\t? \"The document is uninitialized; call TreeView.initialize() before reading or writing TreeView.root.\"\n\t\t: compatibility.canUpgrade\n\t\t\t? \"The stored schema can be upgraded; call TreeView.upgradeSchema() before reading or writing TreeView.root.\"\n\t\t\t: \"The schemas cannot be upgraded automatically. Use a compatible view schema or explicitly migrate the document schema and data.\";\n\tthrow new UsageError(\n\t\t`TreeView.root is unavailable because the view schema is incompatible with the stored schema. ${resolution}`,\n\t\ttagSchemaArtifacts({\n\t\t\tschemaIncompatibilityDetails:\n\t\t\t\tcompatibility.discrepancies === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: JSON.stringify(compatibility.discrepancies),\n\t\t}),\n\t);\n}\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\n@breakingClass\nexport class SchematizingSimpleTreeView<\n\tin out TRootSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> implements TreeViewAlpha<TRootSchema>, WithBreakable\n{\n\t/**\n\t * This is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate flexTreeContext: Context | undefined;\n\n\t/**\n\t * Undefined if and only if uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatusBeta | undefined;\n\t/**\n\t * Cached map of upgrade statuses, computed alongside compatibility.\n\t * @remarks Undefined if and only if uninitialized or disposed.\n\t */\n\tprivate currentEnabledUpgrades: ReadonlyMap<SchemaUpgrade, StagedUpgradeStatus> | undefined;\n\tpublic readonly events: Listenable<TreeViewEvents & TreeBranchEvents> &\n\t\tIEmitter<TreeViewEvents & TreeBranchEvents> &\n\t\tHasListeners<TreeViewEvents & TreeBranchEvents> = createEmitter();\n\n\t/**\n\t * The schema for this view, captured at construction time for compatibility checking.\n\t */\n\tprivate readonly viewSchema: TreeSchema;\n\t/**\n\t * Stored-schema generation policy from the view configuration, frozen at construction time.\n\t */\n\tprivate readonly stagedUpgradePolicy: StagedSchemaUpgradePolicy;\n\n\t/**\n\t * Events to unregister upon flex-tree view disposal.\n\t */\n\tprivate readonly flexTreeViewUnregisterCallbacks = new Set<() => void>();\n\n\t/**\n\t * Events to unregister upon disposal.\n\t */\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\t/**\n\t * Hydration work deferred until Context has been created.\n\t */\n\tprivate pendingHydration?: () => void;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\tpublic readonly breaker: Breakable;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: TreeViewConfiguration<ReadSchema<TRootSchema>>,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t\tprivate readonly onDispose?: () => void,\n\t) {\n\t\tthis.breaker = checkout.breaker;\n\t\tif (checkout.forest.anchors.slots.has(ViewSlot)) {\n\t\t\tthrow new UsageError(\"Cannot create a second tree view from the same checkout\");\n\t\t}\n\t\tcheckout.forest.anchors.slots.set(ViewSlot, this);\n\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\n\t\tconst stagedUpgradePolicy =\n\t\t\tconfig instanceof TreeViewConfigurationAlpha ? config.stagedUpgradePolicy : undefined;\n\t\tconst configAlpha = new TreeViewConfigurationAlpha({\n\t\t\t...config,\n\t\t\tstagedUpgradePolicy,\n\t\t});\n\t\tthis.stagedUpgradePolicy = configAlpha.stagedUpgradePolicy;\n\n\t\t// Store viewSchema directly from the configuration (TreeViewConfigurationAlpha implements TreeSchema)\n\t\tthis.viewSchema = configAlpha;\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t\tdiscrepancies: undefined,\n\t\t};\n\t\tthis.currentEnabledUpgrades = new Map();\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"changed\", (data, getRevertible) => {\n\t\t\t\tthis.events.emit(\"changed\", data, getRevertible);\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible);\n\t\t\t}),\n\t\t);\n\t}\n\n\tpublic isBranch(): this is UntypedTreeViewAlpha {\n\t\treturn this.isView();\n\t}\n\n\tpublic isView(): this is UntypedTreeViewAlpha {\n\t\treturn true;\n\t}\n\n\tpublic applyChange(change: JsonCompatibleReadOnly): void {\n\t\tthis.checkout.applySerializedChange(change);\n\t}\n\n\tpublic hasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema> {\n\t\treturn areImplicitFieldSchemaEqual(this.rootFieldSchema, schema);\n\t}\n\n\tpublic get schema(): ReadSchema<TRootSchema> {\n\t\treturn this.config.schema;\n\t}\n\n\tpublic initialize(content: InsertableField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst schema = toInitialSchema(this.config.schema, this.stagedUpgradePolicy);\n\t\t\t// This has to be the contextless version, since when \"initialize\" is called (right after this),\n\t\t\t// it will do a schema change which would dispose of the current context (see inside `update`).\n\t\t\t// Thus using the current context (if any) would hydrate nodes then\n\t\t\t// immediately dispose them instead of having them actually be useable after initialize.\n\t\t\t// For this to work,\n\t\t\t// the hydration must be deferred until after the content is inserted into the tree and the final schema change is done (for required roots),\n\t\t\t// but before any user event could could run.\n\t\t\tconst mapTree = prepareForInsertionContextless(\n\t\t\t\tcontent as InsertableContent | undefined,\n\t\t\t\tthis.rootFieldSchema,\n\t\t\t\t{\n\t\t\t\t\tschema,\n\t\t\t\t\tpolicy: defaultSchemaPolicy,\n\t\t\t\t},\n\t\t\t\tthis,\n\t\t\t\tschema.rootFieldSchema,\n\t\t\t\t(batches, doHydration) => {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.pendingHydration === undefined,\n\t\t\t\t\t\t0xc74 /* pendingHydration already set */,\n\t\t\t\t\t);\n\t\t\t\t\tthis.pendingHydration = () => {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tbatches.length <= 1,\n\t\t\t\t\t\t\t0xc75 /* initialize should at most one hydration batch */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfor (const batch of batches) {\n\t\t\t\t\t\t\tdoHydration(batch, {\n\t\t\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\t\t\tparentField: rootFieldKey,\n\t\t\t\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tthis.runTransaction(() => {\n\t\t\t\tinitialize(\n\t\t\t\t\tthis.checkout,\n\t\t\t\t\tschema,\n\t\t\t\t\tinitializerFromChunk(this.checkout, () => {\n\t\t\t\t\t\t// This must be done after initial schema is set!\n\t\t\t\t\t\treturn combineChunks(\n\t\t\t\t\t\t\tthis.checkout.forest.chunkField(\n\t\t\t\t\t\t\t\tcursorForMapTreeField(mapTree === undefined ? [] : [mapTree]),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst newSchema = toUpgradeSchema(this.viewSchema.root, this.effectiveUpgradePolicy);\n\t\tconst storedSchema = this.checkout.storedSchema.clone();\n\t\tif (!allowsRepoSuperset(defaultSchemaPolicy, storedSchema, newSchema)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema cannot be upgraded to the requested schema (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\t\tif (allowsRepoSuperset(defaultSchemaPolicy, newSchema, storedSchema)) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tthis.runSchemaEdit(() => this.checkout.updateSchema(newSchema));\n\t}\n\n\tpublic isStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus {\n\t\tif (!this.currentEnabledUpgrades) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentEnabledUpgrades.get(upgrade) ?? \"disabled\";\n\t}\n\n\tprivate get effectiveUpgradePolicy(): StagedSchemaUpgradePolicy {\n\t\tconst configuredPolicy = this.stagedUpgradePolicy;\n\t\tif (configuredPolicy.includeAlreadyEnabledUpgrades === false) {\n\t\t\treturn configuredPolicy;\n\t\t}\n\t\tconst enabledUpgrades = this.currentEnabledUpgrades;\n\t\tassert(\n\t\t\tenabledUpgrades !== undefined,\n\t\t\t0xd3e /* Enabled upgrades must be available for an active view */,\n\t\t);\n\t\tif (enabledUpgrades.size === 0) {\n\t\t\treturn configuredPolicy;\n\t\t}\n\n\t\treturn {\n\t\t\tincludeStaged: (upgrade) =>\n\t\t\t\tconfiguredPolicy.includeStaged(upgrade) || enabledUpgrades.has(upgrade),\n\t\t\tincludeStagedOptional: (upgrade) =>\n\t\t\t\tconfiguredPolicy.includeStagedOptional(upgrade) || enabledUpgrades.has(upgrade),\n\t\t};\n\t}\n\n\t/**\n\t * Gets the flex-tree context. Throws when disposed or out of schema.\n\t */\n\tpublic getFlexTreeContext(): Context {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.flexTreeContext !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.flexTreeContext;\n\t}\n\n\tpublic runTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue>;\n\tpublic runTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatusAlpha | void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\tpublic runTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () =>\n\t\t\t| TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>\n\t\t\t| VoidTransactionCallbackStatusAlpha\n\t\t\t| void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue> | TransactionVoidResult {\n\t\tthis.ensureUndisposed();\n\t\treturn this.checkout.runTransaction(transaction, params);\n\t}\n\n\tpublic runTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;\n\tpublic runTransactionAsync(\n\t\ttransaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\tpublic async runTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<\n\t\t\t| TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>\n\t\t\t| VoidTransactionCallbackStatusAlpha\n\t\t\t| void\n\t\t>,\n\t\tparams: RunTransactionParamsAlpha | undefined,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue> | TransactionVoidResult> {\n\t\tthis.ensureUndisposed();\n\t\tif (this.checkout.transaction.size > 0) {\n\t\t\t// breaker.break() sets brokenBy synchronously before throwing.\n\t\t\t// A plain `throw` inside an async function would be captured as a rejected Promise\n\t\t\t// before @breakingClass could set brokenBy. By setting it here first, the\n\t\t\t// subsequent call to unmountTransaction (also @breakingClass-wrapped) will see the\n\t\t\t// broken state and throw synchronously, propagating out of the outer runTransaction\n\t\t\t// to its caller.\n\t\t\tthis.breaker.break(\n\t\t\t\tnew UsageError(\n\t\t\t\t\t\"An asynchronous transaction cannot be started while another transaction is already in progress.\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn this.checkout.runTransactionAsync(transaction, params);\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeFlexView();\n\n\t\tconst compatibility = this.computeCompatibility();\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tconst anchors = this.checkout.forest.anchors;\n\t\tconst slots = anchors.slots;\n\n\t\tif (compatibility.canView) {\n\t\t\tthis.flexTreeContext = new Context(\n\t\t\t\tdefaultSchemaPolicy,\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t\tassert(!slots.has(SimpleContextSlot), 0xa47 /* extra simple tree context */);\n\t\t\tassert(\n\t\t\t\tthis.rootFieldSchema instanceof FieldSchemaAlpha,\n\t\t\t\t0xbfa /* all field schema should be FieldSchemaAlpha */,\n\t\t\t);\n\t\t\tslots.set(\n\t\t\t\tSimpleContextSlot,\n\t\t\t\tnew HydratedContext(\n\t\t\t\t\tthis.flexTreeContext,\n\t\t\t\t\tHydratedContext.schemaMapFromRootSchema(\n\t\t\t\t\t\tthis.rootFieldSchema.allowedTypesFull.evaluate(),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\t// Trigger \"rootChanged\" events if the root changes in the future.\n\t\t\t{\n\t\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t\t// this.root.on(????)\n\t\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\".\n\t\t\t\t// Ideally these events would be just events for changes within the root.\n\t\t\t\t// TODO: provide a better event: this.view.flexTree.on(????) and/or integrate with with the normal event code paths.\n\n\t\t\t\t// Track what the root was before to be able to detect changes.\n\t\t\t\t// This uses the flex tree root to avoid demanding the simple-tree TreeNode when it might not be hydrated yet.\n\t\t\t\tlet lastRoot: FlexTreeUnknownUnboxed | undefined = (\n\t\t\t\t\tthis.flexTreeContext.root as FlexTreeOptionalField\n\t\t\t\t).content;\n\n\t\t\t\tthis.flexTreeViewUnregisterCallbacks.add(\n\t\t\t\t\tthis.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\t\t\tif (!this.midUpgrade && lastRoot !== this.flexRoot.content) {\n\t\t\t\t\t\t\tlastRoot = this.flexRoot.content;\n\t\t\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthis.flexTreeViewUnregisterCallbacks.add(\n\t\t\t// Will dispose the old view (if there is one) when its no longer valid, and create a new one if appropriate.\n\t\t\tthis.checkout.storedSchema.events.on(\"afterSchemaChange\", () => this.update()),\n\t\t);\n\n\t\tif (!this.midUpgrade) {\n\t\t\tassert(\n\t\t\t\tthis.pendingHydration === undefined,\n\t\t\t\t0xc76 /* no nodes should be pending hydration when triggering events that could access nodes */,\n\t\t\t);\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\t/**\n\t * Computes the current schema compatibility status and updates the cached enabled upgrades.\n\t */\n\tprivate computeCompatibility(): SchemaCompatibilityStatusBeta {\n\t\tconst { enabledUpgrades, ...compatibility } = checkSchemaCompatibility(\n\t\t\tthis.viewSchema,\n\t\t\tthis.checkout.storedSchema,\n\t\t\tthis.stagedUpgradePolicy,\n\t\t);\n\t\tthis.currentEnabledUpgrades = enabledUpgrades;\n\t\treturn {\n\t\t\t...compatibility,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\t// Ensure hydration is flushed before events run which could access nodes.\n\t\tthis.pendingHydration?.();\n\t\tthis.pendingHydration = undefined;\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeFlexView(): void {\n\t\tconst anchors = this.checkout.forest.anchors;\n\t\tif (this.flexTreeContext !== undefined) {\n\t\t\t// Cleanup any TreeNodes cached in the AnchorSet when disposing the flex-tree which they wrap.\n\t\t\tfor (const anchorNode of anchors) {\n\t\t\t\ttryDisposeTreeNode(anchorNode);\n\t\t\t}\n\n\t\t\tthis.flexTreeContext[disposeSymbol]();\n\t\t\tthis.flexTreeContext = undefined;\n\t\t}\n\t\tfor (const unregister of this.flexTreeViewUnregisterCallbacks) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.flexTreeViewUnregisterCallbacks.clear();\n\t\tanchors.slots.delete(SimpleContextSlot);\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatusBeta {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeFlexView();\n\t\tfor (const unregister of this.unregisterCallbacks) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.checkout.forest.anchors.slots.delete(ViewSlot);\n\t\tthis.currentCompatibility = undefined;\n\t\tthis.currentEnabledUpgrades = undefined;\n\t\tthis.onDispose?.();\n\t\tif (!this.checkout.isSharedBranch && !this.checkout.disposed) {\n\t\t\t// All non-shared branches are 1:1 with views, so if a user manually disposes a view, we should also dispose the checkout/branch.\n\t\t\tthis.checkout.dispose();\n\t\t}\n\t}\n\n\tprivate get flexRoot(): FlexTreeOptionalField | FlexTreeRequiredField {\n\t\tthis.breaker.use();\n\t\tthrowIfSchemaIsIncompatible(this.compatibility);\n\t\tconst view = this.getFlexTreeContext();\n\t\tassert(\n\t\t\tview.root.is(FieldKinds.optional) ||\n\t\t\t\tview.root.is(FieldKinds.required) ||\n\t\t\t\tview.root.is(FieldKinds.identifier),\n\t\t\t0xc77 /* unexpected root field kind */,\n\t\t);\n\t\treturn view.root;\n\t}\n\n\tpublic get root(): ReadableField<TRootSchema> {\n\t\treturn tryGetTreeNodeForField(this.flexRoot) as ReadableField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableField<TRootSchema>) {\n\t\tthis.breaker.use();\n\t\tthrowIfSchemaIsIncompatible(this.compatibility);\n\t\tconst view = this.getFlexTreeContext();\n\t\tsetField(\n\t\t\tview.root,\n\t\t\tthis.rootFieldSchema,\n\t\t\tnewRoot as InsertableContent | undefined,\n\t\t\tthis.checkout.storedSchema.rootFieldSchema,\n\t\t);\n\t}\n\n\t// #region Branching\n\n\tpublic fork(): ReturnType<UntypedTreeViewAlpha[\"fork\"]> &\n\t\tSchematizingSimpleTreeView<TRootSchema> {\n\t\treturn this.checkout.fork().viewWith(this.config);\n\t}\n\n\tpublic rewindTo(revision: string): void {\n\t\tthis.checkout.rewindTo(revision);\n\t}\n\n\tpublic revertTo(revision: string, options?: RevertToOptionsAlpha): void {\n\t\tthis.checkout.revertTo(revision, options);\n\t}\n\n\tpublic merge(context: UntypedTreeViewAlpha, disposeMerged = true): void {\n\t\tthis.checkout.merge(context, disposeMerged);\n\t}\n\n\tpublic rebaseOnto(context: UntypedTreeViewAlpha): void {\n\t\tthis.checkout.rebaseOnto(context);\n\t}\n\n\tpublic isMissingEditsFrom(context: UntypedTreeViewAlpha): boolean {\n\t\treturn this.checkout.isMissingEditsFrom(context);\n\t}\n\n\tpublic computeNetChangeIfRebasedOnto(\n\t\tcontext: UntypedTreeViewAlpha,\n\t): JsonCompatibleReadOnly | undefined {\n\t\treturn this.checkout.computeNetChangeIfRebasedOnto(context);\n\t}\n\n\t// #endregion Branching\n\n\tpublic get branchHistory(): TreeBranchHistory {\n\t\treturn this.checkout.branchHistory;\n\t}\n}\n"]}
1
+ {"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE1F,OAAO,EAAE,UAAU,EAAE,YAAY,EAA6B,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAEN,mBAAmB,EACnB,qBAAqB,EACrB,OAAO,EACP,aAAa,EAGb,UAAU,EAEV,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAKN,sBAAsB,EACtB,QAAQ,EACR,oBAAoB,EACpB,wBAAwB,EAexB,eAAe,EACf,iBAAiB,EACjB,2BAA2B,EAC3B,8BAA8B,EAE9B,kBAAkB,EAClB,gBAAgB,EAChB,0BAA0B,EAC1B,eAAe,EACf,eAAe,GAMf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,aAAa,EACb,aAAa,GAGb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGtF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,EAAiC,CAAC;AAEpE,SAAS,2BAA2B,CAAC,aAA4C;IAChF,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO;IACR,CAAC;IAED,MAAM,UAAU,GAAG,aAAa,CAAC,aAAa;QAC7C,CAAC,CAAC,oGAAoG;QACtG,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nC,CAAC;QAEM,kBAAkB,CAAC,OAA6B;YACtD,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;QAEM,6BAA6B,CACnC,OAA6B;YAE7B,OAAO,IAAI,CAAC,QAAQ,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;QAED,uBAAuB;QAEvB,IAAW,aAAa;YACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;QACpC,CAAC;;;;;QAlhBF,6KAmhBC;;;QAnhBY,uDAA0B;;;;SAA1B,0BAA0B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tHasListeners,\n\tIEmitter,\n\tListenable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { tagSchemaArtifacts, UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { anchorSlot, rootFieldKey, type RevertToOptionsAlpha } from \"../core/index.js\";\nimport {\n\ttype NodeIdentifierManager,\n\tdefaultSchemaPolicy,\n\tcursorForMapTreeField,\n\tContext,\n\tcombineChunks,\n\ttype FlexTreeOptionalField,\n\ttype FlexTreeUnknownUnboxed,\n\tFieldKinds,\n\ttype FlexTreeRequiredField,\n\tallowsRepoSuperset,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatusBeta,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\ttryGetTreeNodeForField,\n\tsetField,\n\tnormalizeFieldSchema,\n\tcheckSchemaCompatibility,\n\ttype InsertableContent,\n\ttype StagedSchemaUpgradePolicy,\n\ttype TreeViewConfiguration,\n\ttype TreeViewAlpha,\n\ttype InsertableField,\n\ttype ReadableField,\n\ttype ReadSchema,\n\ttype UnsafeUnknownSchema,\n\ttype TreeBranchEvents,\n\ttype VoidTransactionCallbackStatusAlpha,\n\ttype TransactionCallbackStatusAlpha,\n\ttype TransactionVoidResult,\n\ttype TransactionValueResult,\n\ttype RunTransactionParamsAlpha,\n\tHydratedContext,\n\tSimpleContextSlot,\n\tareImplicitFieldSchemaEqual,\n\tprepareForInsertionContextless,\n\ttype FieldSchema,\n\ttryDisposeTreeNode,\n\tFieldSchemaAlpha,\n\tTreeViewConfigurationAlpha,\n\ttoInitialSchema,\n\ttoUpgradeSchema,\n\ttype TreeBranchHistory,\n\ttype UntypedTreeViewAlpha,\n\ttype TreeSchema,\n\ttype SchemaUpgrade,\n\ttype StagedUpgradeStatus,\n} from \"../simple-tree/index.js\";\nimport {\n\ttype Breakable,\n\tbreakingClass,\n\tdisposeSymbol,\n\ttype JsonCompatibleReadOnly,\n\ttype WithBreakable,\n} from \"../util/index.js\";\n\nimport { canInitialize, initialize, initializerFromChunk } from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\n\n/**\n * Creating multiple tree views from the same checkout is not supported. This slot is used to detect if one already\n * exists and error if creating a second.\n */\nexport const ViewSlot = anchorSlot<TreeView<ImplicitFieldSchema>>();\n\nfunction throwIfSchemaIsIncompatible(compatibility: SchemaCompatibilityStatusBeta): void {\n\tif (compatibility.canView) {\n\t\treturn;\n\t}\n\n\tconst resolution = compatibility.canInitialize\n\t\t? \"The document is uninitialized; call TreeView.initialize() before reading or writing TreeView.root.\"\n\t\t: compatibility.canUpgrade\n\t\t\t? \"The stored schema can be upgraded; call TreeView.upgradeSchema() before reading or writing TreeView.root.\"\n\t\t\t: \"The schemas cannot be upgraded automatically. Use a compatible view schema or explicitly migrate the document schema and data.\";\n\tthrow new UsageError(\n\t\t`TreeView.root is unavailable because the view schema is incompatible with the stored schema. ${resolution}`,\n\t\ttagSchemaArtifacts({\n\t\t\tschemaIncompatibilityDetails:\n\t\t\t\tcompatibility.discrepancies === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: JSON.stringify(compatibility.discrepancies),\n\t\t}),\n\t);\n}\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\n@breakingClass\nexport class SchematizingSimpleTreeView<\n\tin out TRootSchema extends ImplicitFieldSchema | UnsafeUnknownSchema,\n> implements TreeViewAlpha<TRootSchema>, WithBreakable\n{\n\t/**\n\t * This is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate flexTreeContext: Context | undefined;\n\n\t/**\n\t * Undefined if and only if uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatusBeta | undefined;\n\t/**\n\t * Cached map of upgrade statuses, computed alongside compatibility.\n\t * @remarks Undefined if and only if uninitialized or disposed.\n\t */\n\tprivate currentEnabledUpgrades: ReadonlyMap<SchemaUpgrade, StagedUpgradeStatus> | undefined;\n\tpublic readonly events: Listenable<TreeViewEvents & TreeBranchEvents> &\n\t\tIEmitter<TreeViewEvents & TreeBranchEvents> &\n\t\tHasListeners<TreeViewEvents & TreeBranchEvents> = createEmitter();\n\n\t/**\n\t * The schema for this view, captured at construction time for compatibility checking.\n\t */\n\tprivate readonly viewSchema: TreeSchema;\n\t/**\n\t * Stored-schema generation policy from the view configuration, frozen at construction time.\n\t */\n\tprivate readonly stagedUpgradePolicy: StagedSchemaUpgradePolicy;\n\n\t/**\n\t * Events to unregister upon flex-tree view disposal.\n\t */\n\tprivate readonly flexTreeViewUnregisterCallbacks = new Set<() => void>();\n\n\t/**\n\t * Events to unregister upon disposal.\n\t */\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\t/**\n\t * Hydration work deferred until Context has been created.\n\t */\n\tprivate pendingHydration?: () => void;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\tpublic readonly breaker: Breakable;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: TreeViewConfiguration<ReadSchema<TRootSchema>>,\n\t\tpublic readonly nodeKeyManager: NodeIdentifierManager,\n\t\tprivate readonly onDispose?: () => void,\n\t) {\n\t\tthis.breaker = checkout.breaker;\n\t\tif (checkout.forest.anchors.slots.has(ViewSlot)) {\n\t\t\tthrow new UsageError(\"Cannot create a second tree view from the same checkout\");\n\t\t}\n\t\tcheckout.forest.anchors.slots.set(ViewSlot, this);\n\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\n\t\tconst stagedUpgradePolicy =\n\t\t\tconfig instanceof TreeViewConfigurationAlpha ? config.stagedUpgradePolicy : undefined;\n\t\tconst configAlpha = new TreeViewConfigurationAlpha({\n\t\t\t...config,\n\t\t\tstagedUpgradePolicy,\n\t\t});\n\t\tthis.stagedUpgradePolicy = configAlpha.stagedUpgradePolicy;\n\n\t\t// Store viewSchema directly from the configuration (TreeViewConfigurationAlpha implements TreeSchema)\n\t\tthis.viewSchema = configAlpha;\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t\tdiscrepancies: undefined,\n\t\t};\n\t\tthis.currentEnabledUpgrades = new Map();\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"changed\", (data, getRevertible) => {\n\t\t\t\tthis.events.emit(\"changed\", data, getRevertible);\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible);\n\t\t\t}),\n\t\t);\n\t}\n\n\tpublic isBranch(): this is UntypedTreeViewAlpha {\n\t\treturn this.isView();\n\t}\n\n\tpublic isView(): this is UntypedTreeViewAlpha {\n\t\treturn true;\n\t}\n\n\tpublic applyChange(change: JsonCompatibleReadOnly): void {\n\t\tthis.checkout.applySerializedChange(change);\n\t}\n\n\tpublic hasRootSchema<TSchema extends ImplicitFieldSchema>(\n\t\tschema: TSchema,\n\t): this is TreeViewAlpha<TSchema> {\n\t\treturn areImplicitFieldSchemaEqual(this.rootFieldSchema, schema);\n\t}\n\n\tpublic get schema(): ReadSchema<TRootSchema> {\n\t\treturn this.config.schema;\n\t}\n\n\tpublic initialize(content: InsertableField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst schema = toInitialSchema(this.config.schema, this.stagedUpgradePolicy);\n\t\t\t// This has to be the contextless version, since when \"initialize\" is called (right after this),\n\t\t\t// it will do a schema change which would dispose of the current context (see inside `update`).\n\t\t\t// Thus using the current context (if any) would hydrate nodes then\n\t\t\t// immediately dispose them instead of having them actually be useable after initialize.\n\t\t\t// For this to work,\n\t\t\t// the hydration must be deferred until after the content is inserted into the tree and the final schema change is done (for required roots),\n\t\t\t// but before any user event could could run.\n\t\t\tconst mapTree = prepareForInsertionContextless(\n\t\t\t\tcontent as InsertableContent | undefined,\n\t\t\t\tthis.rootFieldSchema,\n\t\t\t\t{\n\t\t\t\t\tschema,\n\t\t\t\t\tpolicy: defaultSchemaPolicy,\n\t\t\t\t},\n\t\t\t\tthis,\n\t\t\t\tschema.rootFieldSchema,\n\t\t\t\t(batches, doHydration) => {\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.pendingHydration === undefined,\n\t\t\t\t\t\t0xc74 /* pendingHydration already set */,\n\t\t\t\t\t);\n\t\t\t\t\tthis.pendingHydration = () => {\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tbatches.length <= 1,\n\t\t\t\t\t\t\t0xc75 /* initialize should at most one hydration batch */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfor (const batch of batches) {\n\t\t\t\t\t\t\tdoHydration(batch, {\n\t\t\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t\t\t\tparentField: rootFieldKey,\n\t\t\t\t\t\t\t\tparentIndex: 0,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tthis.runTransaction(() => {\n\t\t\t\tinitialize(\n\t\t\t\t\tthis.checkout,\n\t\t\t\t\tschema,\n\t\t\t\t\tinitializerFromChunk(this.checkout, () => {\n\t\t\t\t\t\t// This must be done after initial schema is set!\n\t\t\t\t\t\treturn combineChunks(\n\t\t\t\t\t\t\tthis.checkout.forest.chunkField(\n\t\t\t\t\t\t\t\tcursorForMapTreeField(mapTree === undefined ? [] : [mapTree]),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst newSchema = toUpgradeSchema(this.viewSchema.root, this.effectiveUpgradePolicy);\n\t\tconst storedSchema = this.checkout.storedSchema.clone();\n\t\tif (!allowsRepoSuperset(defaultSchemaPolicy, storedSchema, newSchema)) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema cannot be upgraded to the requested schema (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\t\tif (allowsRepoSuperset(defaultSchemaPolicy, newSchema, storedSchema)) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tthis.runSchemaEdit(() => this.checkout.updateSchema(newSchema));\n\t}\n\n\tpublic isStagedUpgradeEnabled(upgrade: SchemaUpgrade): StagedUpgradeStatus {\n\t\tif (!this.currentEnabledUpgrades) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentEnabledUpgrades.get(upgrade) ?? \"disabled\";\n\t}\n\n\tprivate get effectiveUpgradePolicy(): StagedSchemaUpgradePolicy {\n\t\tconst configuredPolicy = this.stagedUpgradePolicy;\n\t\tif (configuredPolicy.includeAlreadyEnabledUpgrades !== true) {\n\t\t\treturn configuredPolicy;\n\t\t}\n\t\tconst enabledUpgrades = this.currentEnabledUpgrades;\n\t\tassert(\n\t\t\tenabledUpgrades !== undefined,\n\t\t\t0xd3e /* Enabled upgrades must be available for an active view */,\n\t\t);\n\t\tif (enabledUpgrades.size === 0) {\n\t\t\treturn configuredPolicy;\n\t\t}\n\n\t\treturn {\n\t\t\tincludeStaged: (upgrade) =>\n\t\t\t\tconfiguredPolicy.includeStaged(upgrade) || enabledUpgrades.has(upgrade),\n\t\t\tincludeStagedOptional: (upgrade) =>\n\t\t\t\tconfiguredPolicy.includeStagedOptional(upgrade) || enabledUpgrades.has(upgrade),\n\t\t};\n\t}\n\n\t/**\n\t * Gets the flex-tree context. Throws when disposed or out of schema.\n\t */\n\tpublic getFlexTreeContext(): Context {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.flexTreeContext !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.flexTreeContext;\n\t}\n\n\tpublic runTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue>;\n\tpublic runTransaction(\n\t\ttransaction: () => VoidTransactionCallbackStatusAlpha | void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionVoidResult;\n\tpublic runTransaction<TSuccessValue, TFailureValue>(\n\t\ttransaction: () =>\n\t\t\t| TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>\n\t\t\t| VoidTransactionCallbackStatusAlpha\n\t\t\t| void,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): TransactionValueResult<TSuccessValue, TFailureValue> | TransactionVoidResult {\n\t\tthis.ensureUndisposed();\n\t\treturn this.checkout.runTransaction(transaction, params);\n\t}\n\n\tpublic runTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue>>;\n\tpublic runTransactionAsync(\n\t\ttransaction: () => Promise<VoidTransactionCallbackStatusAlpha | void>,\n\t\tparams?: RunTransactionParamsAlpha,\n\t): Promise<TransactionVoidResult>;\n\tpublic async runTransactionAsync<TSuccessValue, TFailureValue>(\n\t\ttransaction: () => Promise<\n\t\t\t| TransactionCallbackStatusAlpha<TSuccessValue, TFailureValue>\n\t\t\t| VoidTransactionCallbackStatusAlpha\n\t\t\t| void\n\t\t>,\n\t\tparams: RunTransactionParamsAlpha | undefined,\n\t): Promise<TransactionValueResult<TSuccessValue, TFailureValue> | TransactionVoidResult> {\n\t\tthis.ensureUndisposed();\n\t\tif (this.checkout.transaction.size > 0) {\n\t\t\t// breaker.break() sets brokenBy synchronously before throwing.\n\t\t\t// A plain `throw` inside an async function would be captured as a rejected Promise\n\t\t\t// before @breakingClass could set brokenBy. By setting it here first, the\n\t\t\t// subsequent call to unmountTransaction (also @breakingClass-wrapped) will see the\n\t\t\t// broken state and throw synchronously, propagating out of the outer runTransaction\n\t\t\t// to its caller.\n\t\t\tthis.breaker.break(\n\t\t\t\tnew UsageError(\n\t\t\t\t\t\"An asynchronous transaction cannot be started while another transaction is already in progress.\",\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn this.checkout.runTransactionAsync(transaction, params);\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeFlexView();\n\n\t\tconst compatibility = this.computeCompatibility();\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tconst anchors = this.checkout.forest.anchors;\n\t\tconst slots = anchors.slots;\n\n\t\tif (compatibility.canView) {\n\t\t\tthis.flexTreeContext = new Context(\n\t\t\t\tdefaultSchemaPolicy,\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t\tassert(!slots.has(SimpleContextSlot), 0xa47 /* extra simple tree context */);\n\t\t\tassert(\n\t\t\t\tthis.rootFieldSchema instanceof FieldSchemaAlpha,\n\t\t\t\t0xbfa /* all field schema should be FieldSchemaAlpha */,\n\t\t\t);\n\t\t\tslots.set(\n\t\t\t\tSimpleContextSlot,\n\t\t\t\tnew HydratedContext(\n\t\t\t\t\tthis.flexTreeContext,\n\t\t\t\t\tHydratedContext.schemaMapFromRootSchema(\n\t\t\t\t\t\tthis.rootFieldSchema.allowedTypesFull.evaluate(),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\t// Trigger \"rootChanged\" events if the root changes in the future.\n\t\t\t{\n\t\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t\t// this.root.on(????)\n\t\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\".\n\t\t\t\t// Ideally these events would be just events for changes within the root.\n\t\t\t\t// TODO: provide a better event: this.view.flexTree.on(????) and/or integrate with with the normal event code paths.\n\n\t\t\t\t// Track what the root was before to be able to detect changes.\n\t\t\t\t// This uses the flex tree root to avoid demanding the simple-tree TreeNode when it might not be hydrated yet.\n\t\t\t\tlet lastRoot: FlexTreeUnknownUnboxed | undefined = (\n\t\t\t\t\tthis.flexTreeContext.root as FlexTreeOptionalField\n\t\t\t\t).content;\n\n\t\t\t\tthis.flexTreeViewUnregisterCallbacks.add(\n\t\t\t\t\tthis.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\t\t\tif (!this.midUpgrade && lastRoot !== this.flexRoot.content) {\n\t\t\t\t\t\t\tlastRoot = this.flexRoot.content;\n\t\t\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthis.flexTreeViewUnregisterCallbacks.add(\n\t\t\t// Will dispose the old view (if there is one) when its no longer valid, and create a new one if appropriate.\n\t\t\tthis.checkout.storedSchema.events.on(\"afterSchemaChange\", () => this.update()),\n\t\t);\n\n\t\tif (!this.midUpgrade) {\n\t\t\tassert(\n\t\t\t\tthis.pendingHydration === undefined,\n\t\t\t\t0xc76 /* no nodes should be pending hydration when triggering events that could access nodes */,\n\t\t\t);\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\t/**\n\t * Computes the current schema compatibility status and updates the cached enabled upgrades.\n\t */\n\tprivate computeCompatibility(): SchemaCompatibilityStatusBeta {\n\t\tconst { enabledUpgrades, ...compatibility } = checkSchemaCompatibility(\n\t\t\tthis.viewSchema,\n\t\t\tthis.checkout.storedSchema,\n\t\t\tthis.stagedUpgradePolicy,\n\t\t);\n\t\tthis.currentEnabledUpgrades = enabledUpgrades;\n\t\treturn {\n\t\t\t...compatibility,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\t// Ensure hydration is flushed before events run which could access nodes.\n\t\tthis.pendingHydration?.();\n\t\tthis.pendingHydration = undefined;\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeFlexView(): void {\n\t\tconst anchors = this.checkout.forest.anchors;\n\t\tif (this.flexTreeContext !== undefined) {\n\t\t\t// Cleanup any TreeNodes cached in the AnchorSet when disposing the flex-tree which they wrap.\n\t\t\tfor (const anchorNode of anchors) {\n\t\t\t\ttryDisposeTreeNode(anchorNode);\n\t\t\t}\n\n\t\t\tthis.flexTreeContext[disposeSymbol]();\n\t\t\tthis.flexTreeContext = undefined;\n\t\t}\n\t\tfor (const unregister of this.flexTreeViewUnregisterCallbacks) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.flexTreeViewUnregisterCallbacks.clear();\n\t\tanchors.slots.delete(SimpleContextSlot);\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatusBeta {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeFlexView();\n\t\tfor (const unregister of this.unregisterCallbacks) {\n\t\t\tunregister();\n\t\t}\n\t\tthis.checkout.forest.anchors.slots.delete(ViewSlot);\n\t\tthis.currentCompatibility = undefined;\n\t\tthis.currentEnabledUpgrades = undefined;\n\t\tthis.onDispose?.();\n\t\tif (!this.checkout.isSharedBranch && !this.checkout.disposed) {\n\t\t\t// All non-shared branches are 1:1 with views, so if a user manually disposes a view, we should also dispose the checkout/branch.\n\t\t\tthis.checkout.dispose();\n\t\t}\n\t}\n\n\tprivate get flexRoot(): FlexTreeOptionalField | FlexTreeRequiredField {\n\t\tthis.breaker.use();\n\t\tthrowIfSchemaIsIncompatible(this.compatibility);\n\t\tconst view = this.getFlexTreeContext();\n\t\tassert(\n\t\t\tview.root.is(FieldKinds.optional) ||\n\t\t\t\tview.root.is(FieldKinds.required) ||\n\t\t\t\tview.root.is(FieldKinds.identifier),\n\t\t\t0xc77 /* unexpected root field kind */,\n\t\t);\n\t\treturn view.root;\n\t}\n\n\tpublic get root(): ReadableField<TRootSchema> {\n\t\treturn tryGetTreeNodeForField(this.flexRoot) as ReadableField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableField<TRootSchema>) {\n\t\tthis.breaker.use();\n\t\tthrowIfSchemaIsIncompatible(this.compatibility);\n\t\tconst view = this.getFlexTreeContext();\n\t\tsetField(\n\t\t\tview.root,\n\t\t\tthis.rootFieldSchema,\n\t\t\tnewRoot as InsertableContent | undefined,\n\t\t\tthis.checkout.storedSchema.rootFieldSchema,\n\t\t);\n\t}\n\n\t// #region Branching\n\n\tpublic fork(): ReturnType<UntypedTreeViewAlpha[\"fork\"]> &\n\t\tSchematizingSimpleTreeView<TRootSchema> {\n\t\treturn this.checkout.fork().viewWith(this.config);\n\t}\n\n\tpublic rewindTo(revision: string): void {\n\t\tthis.checkout.rewindTo(revision);\n\t}\n\n\tpublic revertTo(revision: string, options?: RevertToOptionsAlpha): void {\n\t\tthis.checkout.revertTo(revision, options);\n\t}\n\n\tpublic merge(context: UntypedTreeViewAlpha, disposeMerged = true): void {\n\t\tthis.checkout.merge(context, disposeMerged);\n\t}\n\n\tpublic rebaseOnto(context: UntypedTreeViewAlpha): void {\n\t\tthis.checkout.rebaseOnto(context);\n\t}\n\n\tpublic isMissingEditsFrom(context: UntypedTreeViewAlpha): boolean {\n\t\treturn this.checkout.isMissingEditsFrom(context);\n\t}\n\n\tpublic computeNetChangeIfRebasedOnto(\n\t\tcontext: UntypedTreeViewAlpha,\n\t): JsonCompatibleReadOnly | undefined {\n\t\treturn this.checkout.computeNetChangeIfRebasedOnto(context);\n\t}\n\n\t// #endregion Branching\n\n\tpublic get branchHistory(): TreeBranchHistory {\n\t\treturn this.checkout.branchHistory;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"schemaCompatibilityTester.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaCompatibilityTester.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,KAAK,gBAAgB,EAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAIjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAOnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAElF;;;GAGG;AACH,wBAAgB,+BAA+B,CAC9C,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,gBAAgB,GACtB,SAAS,iBAAiB,EAAE,GAAG,SAAS,CAO1C;AAmED;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,gBAAgB,EACxB,oBAAoB,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,yBAAyB,GACxE,IAAI,CAAC,6BAA6B,EAAE,eAAe,CAAC,GAAG;IACzD,eAAe,EAAE,WAAW,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;CACjE,CA4DA"}
1
+ {"version":3,"file":"schemaCompatibilityTester.d.ts","sourceRoot":"","sources":["../../../src/simple-tree/api/schemaCompatibilityTester.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,KAAK,gBAAgB,EAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAIjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAOnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAElF;;;GAGG;AACH,wBAAgB,+BAA+B,CAC9C,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,gBAAgB,GACtB,SAAS,iBAAiB,EAAE,GAAG,SAAS,CAO1C;AAmED;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAErE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,gBAAgB,EACxB,oBAAoB,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,yBAAyB,GACxE,IAAI,CAAC,6BAA6B,EAAE,eAAe,CAAC,GAAG;IACzD,eAAe,EAAE,WAAW,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;CACjE,CA6DA"}
@@ -98,7 +98,7 @@ export function checkSchemaCompatibility(viewSchema, stored, stagedSchemaUpgrade
98
98
  // The public API surface assumes defaultSchemaPolicy
99
99
  const policy = defaultSchemaPolicy;
100
100
  const configuredPolicy = resolveStoredSchemaGenerationOptions(stagedSchemaUpgrades);
101
- const includeAlreadyEnabledUpgrades = configuredPolicy.includeAlreadyEnabledUpgrades ?? true;
101
+ const includeAlreadyEnabledUpgrades = configuredPolicy.includeAlreadyEnabledUpgrades ?? false;
102
102
  // Collect upgrade locations during the discrepancy walk (single pass).
103
103
  const totalLocations = new Map();
104
104
  const enabledLocations = new Map();