@itwin/core-backend
Version:
iTwin.js backend components
45 lines • 2.54 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module RpcInterface
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SnapshotIModelRpcImpl = void 0;
const core_common_1 = require("@itwin/core-common");
const IModelDb_1 = require("../IModelDb");
const IModelHost_1 = require("../IModelHost");
/* eslint-disable @typescript-eslint/no-deprecated */
/** The backend implementation of SnapshotIModelRpcInterface.
* @internal
* @deprecated in 5.0 - will not be removed until after 2026-06-13. Check [[IpcAppFunctions]] for replacements.
*/
class SnapshotIModelRpcImpl extends core_common_1.RpcInterface {
static register() { core_common_1.RpcManager.registerImpl(core_common_1.SnapshotIModelRpcInterface, SnapshotIModelRpcImpl); }
/** Ask the backend to open a snapshot iModel from a file name that is resolved by the backend. */
async openFile(filePath, opts) {
let resolvedFileName = filePath;
if (IModelHost_1.IModelHost.snapshotFileNameResolver) {
resolvedFileName = IModelHost_1.IModelHost.snapshotFileNameResolver.tryResolveFileName(filePath);
if (undefined === resolvedFileName)
throw new core_common_1.IModelNotFoundResponse(); // eslint-disable-line @typescript-eslint/only-throw-error
}
return IModelDb_1.SnapshotDb.openFile(resolvedFileName, opts).getConnectionProps();
}
/** Ask the backend to open a snapshot iModel from a key that is resolved by the backend. */
async openRemote(fileKey, opts) {
const resolvedFileName = IModelHost_1.IModelHost.snapshotFileNameResolver?.resolveKey(fileKey);
if (undefined === resolvedFileName)
throw new core_common_1.IModelNotFoundResponse(); // eslint-disable-line @typescript-eslint/only-throw-error
return IModelDb_1.SnapshotDb.openFile(resolvedFileName, { key: fileKey, ...opts }).getConnectionProps();
}
/** Ask the backend to close a snapshot iModel. */
async close(tokenProps) {
IModelDb_1.SnapshotDb.findByKey(tokenProps.key).close();
return true;
}
}
exports.SnapshotIModelRpcImpl = SnapshotIModelRpcImpl;
//# sourceMappingURL=SnapshotIModelRpcImpl.js.map