/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ /** * @fileoverview Provides the contextual information for the onModify callbacks. */ import { SerializedChangeSet, Utils } from "@fluid-experimental/property-changeset"; import { BaseProperty } from "@fluid-experimental/property-properties"; import { PropertyElement } from "../internal/propertyElement.js"; import { BaseContext } from "./baseContext.js"; import { DataBinding } from "./dataBinding.js"; /** * Provides the contextual information for the onModify callbacks. * @alias ModificationContext * @extends BaseContext * @public */ export declare class ModificationContext extends BaseContext { _relativeTokenizedPath: string[]; _removedDataBindingPath: string | undefined; _propertyHint: BaseProperty | undefined; _boundToRef: boolean; /** * @param in_nestedChangeSet - * The ChangeSet represented by the modification context * @param in_operationType - * The operation type that has been applied to the root of the ChangeSet. It can take one of the following values: * of 'insert', 'modify' or 'remove' * @param in_path - * The full path to the property that is modified * @param in_context - * The context in which this ChangeSet is applied. It can take one of the following values: * 'single', 'map', 'set', 'array', 'template' or 'root' * @param in_baseDataBinding - * The data binding which triggered the event this modification context refers to. Used when this * ModificationContext is created for a sub-path notification. * @param in_relativeTokenizedPath - * Tokenized path from the base Data Binding to the root of this ModificationContext. Used when this * ModificationContext is created for a sub-path notification. * @param in_simulated - if true, the modification is being done retroactively on properties * that already existed in the workspace, i.e., the modification is being simulated. Default is false. * @param in_boundToRef - if true, the modification occurred on the * reference and not on the referred object. Default is false. * * @constructor * @package * @hideconstructor * @hidden */ constructor(in_nestedChangeSet: SerializedChangeSet, in_operationType: Utils.OperationType | undefined, in_path?: string, in_context?: string, in_baseDataBinding?: DataBinding, in_relativeTokenizedPath?: Array, in_simulated?: boolean, in_boundToRef?: boolean); /** * Returns the data binding (if it exists) at the path associated with this the modification. * If an optional binding type is supplied, data bindings that correspond to that type are returned, otherwise data * bindings which have the same type as the binding that triggered the event of this modificationContext are returned. * * @param in_bindingType - The requested data binding type. If none has been given, data bindings with * the same data binding type as the DataBinding that triggered this modification context are returned. * @returns A data binding (defined for the given bindingType) * which may be empty, if no data binding of the given type is present at the path associated * with this modification. * @public */ getDataBinding(in_bindingType?: string): DataBinding | undefined; /** * Return the property element at the root of the modification. * * @returns a property element representing the property at the root of the modification * * @hidden */ _getPropertyElement(): PropertyElement; /** * Returns the Property at the root of the modification. * * NOTE: If this ModificationContext is the result of registerOnPath with multiple subpaths, the property will * be undefined (since it is not unique). In this case, fetch the properties manually relative to the DataBinding. * * In the case of an element within a primitive collection (e.g., an Array of strings), this will give the * array. * * @returns The property at the root of this modification. * @public */ getProperty(): BaseProperty | undefined; /** * Returns the current path to the removed Data Binding that is used when querying for removed data bindings. * * @returns the current path * @package * @hidden */ _getRemovedDataBindingPath(): string | undefined; /** * Create a modification context from the information contained in a traversal context. * * @param in_traversalContext - traversal context * @param in_baseDataBinding - * The DataBinding which triggered the event this modification context refers to. Used when this * ModificationContext is created for a sub-path notification. * @param in_relativeTokenizedPath - * Tokenized path from the base Data Binding to the root of this ModificationContext. Used when this * ModificationContext is created for a sub-path notification. * @param in_boundToRef - if true, the context refers to the reference, and not the referenced object * @returns Modification context from traversal context * @package * @hidden */ static _fromContext(in_traversalContext: Utils.TraversalContext, in_baseDataBinding?: DataBinding, in_relativeTokenizedPath?: Array, in_boundToRef?: boolean): ModificationContext; /** * Sets the Property associated with this context. This overrides the contained Binding's associated Property. * This is used as a hint if the creator of the modification context happens to already know the property. * * @param in_property - the Property that should be associated with this context. * @package * @hidden */ _hintModifiedProperty(in_property: BaseProperty): void; /** * Sets the path to the removed Data Binding that is used when querying DataBinder for removed data bindings. * * @param in_removedDataBindingPath - the suffix that should make the path unique * @package * @hidden */ _setRemovedDataBindingPath(in_removedDataBindingPath: string): void; /** * clones the context object * * @returns the cloned context * @package * @hidden */ _clone(): ModificationContext; /** * Return the tokenized path relative to the DataBinding on which we are called. * For a path registered on the DataBinder, this path will be relative to the root. * * @returns the tokenized path, relative to the binding point * @public */ getRelativeTokenizedPath(): string[]; } //# sourceMappingURL=modificationContext.d.ts.map