Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public static async openIModel(accessToken: AccessToken, projectId: string, iModelId: string, changeSetId: string | undefined, openMode: OpenMode): Promise {
return IModelConnection.open(accessToken!, projectId, iModelId, openMode, changeSetId ? IModelVersion.asOfChangeSet(changeSetId) : IModelVersion.latest());
}
}
public async createNamedVersion(accessToken: AccessToken, iModelId: string, name: string, description: string): Promise {
const changeSetId: string = await IModelVersion.latest().evaluateChangeSet(actx, accessToken, iModelId, this._hubClient);
Logger.logTrace(ChangeSetUtilityConfig.loggingCategory, `Creating named version "${name}" on the Hub`);
return this._hubClient.versions.create(actx, accessToken, iModelId, changeSetId, name, description);
}
/** Push an iModel to the Hub */
public static async openIModel(accessToken: AccessToken, projectId: string, iModelId: string, changeSetId: string | undefined, openMode: OpenMode): Promise {
return IModelConnection.open(accessToken!, projectId, iModelId, openMode, changeSetId ? IModelVersion.asOfChangeSet(changeSetId) : IModelVersion.latest());
}
}
public static async openIModel(projectId: string, iModelId: string, changeSetId: string | undefined, openMode: OpenMode): Promise {
return IModelConnection.open(projectId, iModelId, openMode, changeSetId ? IModelVersion.asOfChangeSet(changeSetId) : IModelVersion.latest());
}
}
public async pullAndMergeChanges(requestContext: AuthorizedClientRequestContext, version: IModelVersion = IModelVersion.latest()): Promise {
requestContext.enter();
this.concurrencyControl.onMergeChanges();
await BriefcaseManager.pullAndMergeChanges(requestContext, this.briefcase, version);
requestContext.enter();
this.concurrencyControl.onMergedChanges();
this.iModelToken.changeSetId = this.briefcase.currentChangeSetId;
this.initializeIModelDb();
}
public static async open(requestContext: AuthorizedClientRequestContext, contextId: string, iModelId: string, openParams: OpenParams = OpenParams.pullAndPush(), version: IModelVersion = IModelVersion.latest()): Promise {
requestContext.enter();
const perfLogger = new PerfLogger("Opening iModel", () => ({ contextId, iModelId, ...openParams }));
IModelDb.onOpen.raiseEvent(requestContext, contextId, iModelId, openParams, version);
let briefcaseEntry: BriefcaseEntry;
let timedOut = false;
try {
briefcaseEntry = await BriefcaseManager.open(requestContext, contextId, iModelId, openParams, version);
requestContext.enter();
if (briefcaseEntry.isPending) {
if (typeof openParams.timeout === "undefined")
await briefcaseEntry.isPending;
else {
timedOut = true;
public static async pullAndMergeChanges(requestContext: AuthorizedClientRequestContext, briefcase: BriefcaseEntry, mergeToVersion: IModelVersion = IModelVersion.latest()): Promise {
requestContext.enter();
const { changeSetId: targetChangeSetId, changeSetIndex: targetChangeSetIndex } = await BriefcaseManager.evaluateVersion(requestContext, mergeToVersion, briefcase.iModelId);
requestContext.enter();
if (targetChangeSetIndex < briefcase.currentChangeSetIndex)
return Promise.reject(new IModelError(ChangeSetStatus.NothingToMerge, "Nothing to merge", Logger.logError, loggerCategory, () => ({ ...briefcase.getDebugInfo(), targetChangeSetId, targetChangeSetIndex })));
await BriefcaseManager.updatePendingChangeSets(requestContext, briefcase);
requestContext.enter();
return BriefcaseManager.processChangeSets(requestContext, briefcase, targetChangeSetId, targetChangeSetIndex);
}
public async reinstateChanges(requestContext: AuthorizedClientRequestContext, version: IModelVersion = IModelVersion.latest()): Promise {
requestContext.enter();
await BriefcaseManager.reinstateChanges(requestContext, this.briefcase, version);
requestContext.enter();
this.initializeIModelDb();
}
public static async open(contextId: string, iModelId: string, openMode: OpenMode = OpenMode.Readonly, version: IModelVersion = IModelVersion.latest()): Promise {
if (!IModelApp.initialized)
throw new IModelError(BentleyStatus.ERROR, "Call IModelApp.startup() before calling open");
const requestContext = await AuthorizedFrontendRequestContext.create();
requestContext.enter();
const changeSetId: string = await version.evaluateChangeSet(requestContext, iModelId, IModelApp.iModelClient);
requestContext.enter();
const iModelToken = new IModelToken(undefined, contextId, iModelId, changeSetId, openMode);
const openResponse: IModelProps = await IModelConnection.callOpen(requestContext, iModelToken, openMode);
requestContext.enter();
const connection = new IModelConnection(openResponse, openMode);
RpcRequest.notFoundHandlers.addListener(connection._reopenConnectionHandler);
public async reverseChanges(requestContext: AuthorizedClientRequestContext, version: IModelVersion = IModelVersion.latest()): Promise {
requestContext.enter();
await BriefcaseManager.reverseChanges(requestContext, this.briefcase, version);
requestContext.enter();
this.initializeIModelDb();
}