import { BriefcaseDb , BriefcaseManager } from "@bentley/imodeljs-backend" ; import { IModelVersion , LocalBriefcaseProps } from "@bentley/imodeljs-common" ; import { AuthorizedClientRequestContext } from "@bentley/itwin-client" ; export class BriefcaseProvider { private _iModelDb ? : BriefcaseDb ; public async getBriefcase ( requestContext , projectId , iModelId , changeSetId ) { requestContext . enter ( ) ; if ( ! this . _iModelDb ) { const briefcaseProps = await BriefcaseManager . downloadBriefcase ( requestContext , { contextId : projectId , iModelId , asOf : IModelVersion . asOfChangeSet ( changeSetId ) . toJSON ( ) } ) ; requestContext . enter ( ) ; this . _iModelDb = await BriefcaseDb . open ( requestContext , { fileName : briefcaseProps . fileName , readonly : false } ) ; } else { await this . _iModelDb . pullAndMergeChanges ( requestContext , IModelVersion . asOfChangeSet ( changeSetId ) ) ; } return this . _iModelDb ; } }