UNPKG

@itwin/core-backend

Version:
118 lines 5.32 kB
/** @packageDocumentation * @module iModels */ import { BeEvent, GuidString } from "@itwin/core-bentley"; import { ChangesetId, ChangesetIdWithIndex, LocalDirName, LocalFileName, OpenCheckpointArgs } from "@itwin/core-common"; import { CloudSqlite } from "./CloudSqlite"; import { SnapshotDb, TokenArg } from "./IModelDb"; import { _mockCheckpoint } from "./internal/Symbols"; /** @internal */ export interface MockCheckpoint { mockAttach(checkpoint: CheckpointProps): string; mockDownload(_request: DownloadRequest): void; } /** * Properties of a checkpoint * @public */ export interface CheckpointProps extends TokenArg { readonly expectV2?: boolean; /** iTwin that the iModel belongs to */ readonly iTwinId: GuidString; /** Id of the iModel */ readonly iModelId: GuidString; /** changeset for the checkpoint */ readonly changeset: ChangesetIdWithIndex; /** If true, then the latest successful v2 checkpoint at or before the provided changeset will be returned when calling queryV2Checkpoint. */ readonly allowPreceding?: boolean; /** The number of seconds before the current token expires to attempt to reacquire a new token. Default is 1 hour. */ readonly reattachSafetySeconds?: number; } /** Return value from [[ProgressFunction]]. * @public */ export declare enum ProgressStatus { /** Continue download. */ Continue = 0, /** Abort download. */ Abort = 1 } /** Called to show progress during a download. If this function returns non-zero, the download is aborted. * @public */ export type ProgressFunction = (loaded: number, total: number) => ProgressStatus; /** The parameters that specify a request to download a checkpoint file from iModelHub. * @internal */ export interface DownloadRequest { /** name of local file to hold the downloaded data. */ localFile: LocalFileName; /** A list of full fileName paths to test before downloading. If a valid file exists by one of these names, * no download is performed and `localFile` is updated to reflect the fact that the file exists with that name. * This can be used, for example, to look for checkpoints from previous versions if the naming strategy changes. */ readonly aliasFiles?: ReadonlyArray<string>; /** Properties of the checkpoint to be downloaded */ readonly checkpoint: CheckpointProps; /** If present, this function will be called to indicate progress as the briefcase is downloaded. If this * function returns a non-zero value, the download is aborted. */ readonly onProgress?: ProgressFunction; } /** @internal */ export interface DownloadJob { request: DownloadRequest; promise?: Promise<any>; } /** @internal */ export declare class Downloads { private static _active; private static process; static isInProgress(pathName: LocalFileName): DownloadJob | undefined; static download<T>(request: DownloadRequest, downloadFn: (job: DownloadJob) => Promise<T>): Promise<any>; } /** * Utility class for opening V2 checkpoints from cloud containers, and also for downloading them. * @internal */ export declare class V2CheckpointManager { static readonly cloudCacheName = "Checkpoints"; private static _cloudCache?; private static containers; /** used by HubMock * @internal */ static [_mockCheckpoint]?: MockCheckpoint; static getFolder(): LocalDirName; static cleanup(): void; private static get cloudCache(); /** Member names differ slightly between the V2Checkpoint api and the CloudSqlite api. Add aliases `accessName` for `accountName` and `accessToken` for `sasToken` */ private static toCloudContainerProps; private static getContainer; static attach(checkpoint: CheckpointProps): Promise<{ dbName: string; container: CloudSqlite.CloudContainer | undefined; }>; /** @internal */ private static performDownload; /** Fully download a V2 checkpoint to a local file that can be used to create a briefcase or to work offline. * @returns a Promise that is resolved when the download completes with the changesetId of the downloaded checkpoint (which will * be the same as the requested changesetId or the most recent checkpoint before it.) */ static downloadCheckpoint(request: DownloadRequest): Promise<ChangesetId>; } /** @internal */ export declare class CheckpointManager { static readonly onDownloadV2: BeEvent<(job: DownloadJob) => void>; static getKey(checkpoint: CheckpointProps): string; private static doDownload; static updateToRequestedVersion(request: DownloadRequest): Promise<void>; /** Download a checkpoint file from iModelHub into a local file specified in the request parameters. */ static downloadCheckpoint(request: DownloadRequest): Promise<void>; /** checks a file's dbGuid & iTwinId for consistency, and updates the dbGuid when possible */ static validateCheckpointGuids(checkpoint: CheckpointProps, snapshotDb: SnapshotDb): void; /** @returns true if the file is the checkpoint requested */ static verifyCheckpoint(checkpoint: CheckpointProps, fileName: LocalFileName): boolean; static toCheckpointProps(args: OpenCheckpointArgs): Promise<CheckpointProps>; } //# sourceMappingURL=CheckpointManager.d.ts.map