@itwin/core-frontend
Version:
iTwin.js frontend components
180 lines • 10.4 kB
TypeScript
/** @packageDocumentation
* @module IModelConnection
*/
import { BeEvent, IModelStatus } from "@itwin/core-bentley";
import { ChangesetIndexAndId, EcefLocationProps, GeographicCRSProps, ModelIdAndGeometryGuid, NotifyEntitiesChangedArgs, RootSubjectProps, TxnNotifications } from "@itwin/core-common";
import { Range3dProps, XYZProps } from "@itwin/core-geometry";
import { BriefcaseConnection } from "./BriefcaseConnection";
import { NotificationHandler } from "./IpcApp";
import { TxnEntityChanges } from "./TxnEntityChanges";
/**
* Base class for notification handlers for events from the backend that are specific to a [[BriefcaseConnection]].
* @see [[BriefcaseTxns]].
* @public
*/
export declare abstract class BriefcaseNotificationHandler extends NotificationHandler {
private _key;
constructor(_key: string);
abstract get briefcaseChannelName(): string;
get channelName(): string;
}
/** Manages local changes to a [[BriefcaseConnection]] via [Txns]($docs/learning/InteractiveEditing.md).
* @see [[BriefcaseConnection.txns]].
* @see [TxnManager]($backend) for the backend counterpart.
* @public
*/
export declare class BriefcaseTxns extends BriefcaseNotificationHandler implements TxnNotifications {
private readonly _iModel;
private _cleanup?;
/** @internal */
get briefcaseChannelName(): "itwinjs-core/txns";
/** Event raised after Txn validation or changeset application to indicate the set of changed elements.
* @note If there are many changed elements in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.
*/
readonly onElementsChanged: BeEvent<(changes: TxnEntityChanges) => void>;
/** Event raised after Txn validation or changeset application to indicate the set of changed models.
* @note If there are many changed models in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.
*/
readonly onModelsChanged: BeEvent<(changes: TxnEntityChanges) => void>;
/** Event raised after the geometry within one or more [[GeometricModelState]]s is modified by applying a changeset or validation of a transaction.
* A model's geometry can change as a result of:
* - Insertion or deletion of a geometric element within the model; or
* - Modification of an existing element's geometric properties; or
* - An explicit request to flag it as changed via [IModelDb.Models.updateModel]($backend).
*/
readonly onModelGeometryChanged: BeEvent<(changes: ReadonlyArray<ModelIdAndGeometryGuid>) => void>;
/** Event raised before a commit operation is performed. Initiated by a call to [[BriefcaseConnection.saveChanges]], unless there are no changes to save.
* @see [[onCommitted]] for the event raised after the operation.
*/
readonly onCommit: BeEvent<() => void>;
/** Event raised after a commit operation is performed. Initiated by a call to [[BriefcaseConnection.saveChanges]], even if there were no changes to save.
* The event supplies the following information:
* - `hasPendingTxns`: true if the briefcase has local changes not yet pushed to the server.
* - `time`: the time at which changes were saved on the backend (obtained via `Date.now()`).
* @see [[onCommit]] for the event raised before the operation.
*/
readonly onCommitted: BeEvent<(hasPendingTxns: boolean, time: number) => void>;
/** Event raised for a read-only briefcase that was opened with the `watchForChanges` flag enabled when changes made by another connection are applied to the briefcase.
* @see [[onReplayedExternalTxns]] for the event raised after all such changes have been applied.
*/
readonly onReplayExternalTxns: BeEvent<() => void>;
/** Event raised for a read-only briefcase that was opened with the `watchForChanges` flag enabled when changes made by another connection are applied to the briefcase.
* @see [[onReplayExternalTxns]] for the event raised before the changes are applied.
*/
readonly onReplayedExternalTxns: BeEvent<() => void>;
/** Event raised after a changeset has been applied to the briefcase.
* Changesets may be applied as a result of [[BriefcaseConnection.pullChanges]], or by undo/redo operations.
*/
readonly onChangesApplied: BeEvent<() => void>;
/** Event raised before an undo/redo operation is performed.
* @see [[onAfterUndoRedo]] for the event raised after the operation.
*/
readonly onBeforeUndoRedo: BeEvent<(isUndo: boolean) => void>;
/** Event raised after an undo/redo operation is performed.
* @see [[onBeforeUndoRedo]] for the event raised before to the operation.
*/
readonly onAfterUndoRedo: BeEvent<(isUndo: boolean) => void>;
/** Event raised after changes are pulled and merged into the briefcase.
* @see [[BriefcaseConnection.pullAndMergeChanges]].
*/
readonly onChangesPulled: BeEvent<(parentChangeset: ChangesetIndexAndId) => void>;
/** Event raised after the briefcase's local changes are pushed.
* @see [[BriefcaseConnection.pushChanges]].
*/
readonly onChangesPushed: BeEvent<(parentChangeset: ChangesetIndexAndId) => void>;
/** @internal */
constructor(iModel: BriefcaseConnection);
/** @internal */
[Symbol.dispose](): void;
/** Query if the briefcase has any pending Txns waiting to be pushed. */
hasPendingTxns(): Promise<boolean>;
/** Determine if any reversible (undoable) changes exist.
* @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.
*/
isUndoPossible(): Promise<boolean>;
/** Determine if any reinstatable (redoable) changes exist.
* @see [[reinstateTxn]] to redo changes.
*/
isRedoPossible(): Promise<boolean>;
/** Get the description of the operation that would be reversed by calling [[reverseTxns]]`(1)`.
* This is useful for showing the operation that would be undone, for example in a menu.
*/
getUndoString(): Promise<string>;
/** Get a description of the operation that would be reinstated by calling [[reinstateTxn]].
* This is useful for showing the operation that would be redone, in a pull-down menu for example.
*/
getRedoString(): Promise<string>;
/** Reverse (undo) the most recent operation.
* @see [[reinstateTxn]] to redo operations.
* @see [[reverseAll]] to undo all operations.
* @see [[isUndoPossible]] to determine if any reversible operations exist.
*/
reverseSingleTxn(): Promise<IModelStatus>;
/** Reverse (undo) the most recent operation(s) to the briefcase in the current session.
* @param numOperations the number of operations to reverse. If this is greater than 1, the entire set of operations will
* be reinstated together when/if [[reinstateTxn]] is called.
* @note If there are any outstanding uncommitted changes, they are reversed.
* @note The term "operation" is used rather than Txn, since multiple Txns can be grouped together via [TxnManager.beginMultiTxnOperation]($backend). So,
* even if numOperations is 1, multiple Txns may be reversed if they were grouped together when they were made.
* @note If numOperations is too large only the number of reversible operations are reversed.
*/
reverseTxns(numOperations: number): Promise<IModelStatus>;
/** Reverse (undo) all changes back to the beginning of the session.
* @see [[reinstateTxn]] to redo changes.
* @see [[reverseSingleTxn]] to undo only the most recent operation.
* @see [[isUndoPossible]] to determine if any reversible operations exist.
*/
reverseAll(): Promise<IModelStatus>;
/** Reinstate (redo) the most recently reversed transaction. Since at any time multiple transactions can be reversed, it
* may take multiple calls to this method to reinstate all reversed operations.
* @returns Success if a reversed transaction was reinstated, error status otherwise.
* @note If there are any outstanding uncommitted changes, they are canceled before the Txn is reinstated.
* @see [[isRedoPossible]] to determine if any reinstatable operations exist.
* @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.
*/
reinstateTxn(): Promise<IModelStatus>;
/** Restart the current TxnManager session. This causes all Txns in the current session to no longer be undoable (as if the file was closed
* and reopened.)
* @note This can be quite disconcerting to the user expecting to be able to undo previously made changes. It should only be used
* under extreme circumstances where damage to the file or session could happen if the currently committed are reversed. Use sparingly and with care.
* Probably a good idea to alert the user it happened.
*/
restartTxnSession(): Promise<void>;
/** @internal */
notifyElementsChanged(changed: NotifyEntitiesChangedArgs): void;
/** @internal */
notifyModelsChanged(changed: NotifyEntitiesChangedArgs): void;
/** @internal */
notifyGeometryGuidsChanged(changes: ModelIdAndGeometryGuid[]): void;
/** @internal */
notifyCommit(): void;
/** @internal */
notifyCommitted(hasPendingTxns: boolean, time: number): void;
/** @internal */
notifyReplayExternalTxns(): void;
/** @internal */
notifyReplayedExternalTxns(): void;
/** @internal */
notifyChangesApplied(): void;
/** @internal */
notifyBeforeUndoRedo(isUndo: boolean): void;
/** @internal */
notifyAfterUndoRedo(isUndo: boolean): void;
/** @internal */
notifyPulledChanges(parentChangeset: ChangesetIndexAndId): void;
/** @internal */
notifyPushedChanges(parentChangeset: ChangesetIndexAndId): void;
/** @internal */
notifyIModelNameChanged(name: string): void;
/** @internal */
notifyRootSubjectChanged(subject: RootSubjectProps): void;
/** @internal */
notifyProjectExtentsChanged(range: Range3dProps): void;
/** @internal */
notifyGlobalOriginChanged(origin: XYZProps): void;
/** @internal */
notifyEcefLocationChanged(ecef: EcefLocationProps | undefined): void;
/** @internal */
notifyGeographicCoordinateSystemChanged(gcs: GeographicCRSProps | undefined): void;
}
//# sourceMappingURL=BriefcaseTxns.d.ts.map