UNPKG

@itwin/core-frontend

Version:
153 lines • 7.91 kB
/** @packageDocumentation * @module IModelConnection */ import { BeEvent, GuidString, Id64String, OpenMode } from "@itwin/core-bentley"; import { ChangesetIndex, ChangesetIndexAndId, IModelConnectionProps, OpenBriefcaseProps, StandaloneOpenOptions } from "@itwin/core-common"; import { BriefcaseTxns } from "./BriefcaseTxns"; import { GraphicalEditingScope } from "./GraphicalEditingScope"; import { IModelConnection } from "./IModelConnection"; /** * Download progress information. * @public */ export interface DownloadProgressInfo { /** Bytes downloaded. */ loaded: number; /** Total size of the download in bytes. */ total: number; } /** * Called to show progress during a download. * @public */ export type OnDownloadProgress = (progress: DownloadProgressInfo) => void; /** * Partial interface of AbortSignal. * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal * @beta */ export interface GenericAbortSignal { /** Add Listener for abort signal. */ addEventListener: (type: "abort", listener: (this: GenericAbortSignal, ev: any) => any) => void; /** Remove Listener for abort signal. */ removeEventListener: (type: "abort", listener: (this: GenericAbortSignal, ev: any) => any) => void; } /** * Options for pulling iModel changes. * @public */ export interface PullChangesOptions { /** Function called regularly to report progress of changes download. */ downloadProgressCallback?: OnDownloadProgress; /** Interval for calling progress callback (in milliseconds). */ progressInterval?: number; /** Signal for cancelling the download. * @beta */ abortSignal?: GenericAbortSignal; } /** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]]. * For example, tools that want to create new elements can consult the briefcase's editor tool settings to * determine into which model and category to insert the elements. * Specialized tools are free to ignore these settings. * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase. * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings. * @beta */ export declare class BriefcaseEditorToolSettings { private _category?; private _model?; /** An event raised just after the default [[category]] is changed. */ readonly onCategoryChanged: BeEvent<(previousCategory: Id64String | undefined) => void>; /** An event raised just after the default [[model]] is changed. */ readonly onModelChanged: BeEvent<(previousModel: Id64String | undefined) => void>; /** The [Category]($backend) into which new elements should be inserted by default. * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category. * @see [[onCategoryChanged]] to be notified when this property is modified. * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting. */ get category(): Id64String | undefined; set category(category: Id64String | undefined); /** The [Model]($backend) into which new elements should be inserted by default. * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model. * @see [[onModelChanged]] to be notified when this property is modified. * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting. */ get model(): Id64String | undefined; set model(model: Id64String | undefined); } /** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate * to the backend and may only be used by [[IpcApp]]s. * @public */ export declare class BriefcaseConnection extends IModelConnection { protected _isClosed?: boolean; private readonly _modelsMonitor; /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase. * @beta */ readonly editorToolSettings: BriefcaseEditorToolSettings; /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */ readonly txns: BriefcaseTxns; isBriefcaseConnection(): this is BriefcaseConnection; /** The Guid that identifies the iTwin that owns this iModel. */ get iTwinId(): GuidString; /** The Guid that identifies this iModel. */ get iModelId(): GuidString; protected constructor(props: IModelConnectionProps, openMode: OpenMode); /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */ static openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection>; /** Open a BriefcaseConnection to a [StandaloneDb]($backend) * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions. */ static openStandalone(filePath: string, openMode?: OpenMode, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection>; /** Returns `true` if [[close]] has already been called. */ get isClosed(): boolean; /** * Close this BriefcaseConnection. * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned. */ close(): Promise<void>; protected requireTimeline(): void; /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */ hasPendingTxns(): Promise<boolean>; /** Commit pending changes to this briefcase. * @param description Optional description of the changes. */ saveChanges(description?: string): Promise<void>; /** Abandon pending changes to this briefcase. */ abandonChanges(): Promise<void>; /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes. * @param options Options for pulling changes. * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled. */ pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void>; /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table. * @param description The description for the changeset * @returns the changesetId of the pushed changes * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed. */ pushChanges(description: string): Promise<ChangesetIndexAndId>; /** The current graphical editing scope, if one is in progress. * @see [[enterEditingScope]] to begin graphical editing. */ get editingScope(): GraphicalEditingScope | undefined; /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of * the BisCore ECSchema older than v0.1.11. * @see [[enterEditingScope]] to enable graphical editing. */ supportsGraphicalEditing(): Promise<boolean>; /** Begin a new graphical editing scope. * @throws Error if an editing scope already exists or one could not be created. * @see [[GraphicalEditingScope.exit]] to exit the scope. * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed. * @see [[editingScope]] to obtain the current editing scope, if one is in progress. */ enterEditingScope(): Promise<GraphicalEditingScope>; /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered. * @internal */ readonly onBufferedModelChanges: BeEvent<(changedModelIds: Set<string>) => void>; } //# sourceMappingURL=BriefcaseConnection.d.ts.map