import * as nock from "nock" ; import { IModelDb , IModelHost , IModelJsFs , NativeHost } from "@itwin/core-backend" ; import { V1CheckpointManager } from "@itwin/core-backend/lib/cjs/CheckpointManager" ; import { IModelRpcProps , RpcInterface , RpcManager } from "@itwin/core-common" ; import { TestRpcInterface } from "../common/RpcInterfaces" ; export class TestRpcImpl extends RpcInterface implements TestRpcInterface { public static register ( ) { RpcManager . registerImpl ( TestRpcInterface , TestRpcImpl ) ; } public async restartIModelHost ( ) { await IModelHost . shutdown ( ) ; await IModelHost . startup ( ) ; } public async executeTest ( tokenProps , testName , params ) { return JSON . parse ( IModelDb . findByKey ( tokenProps . key ) . nativeDb . executeTest ( testName , JSON . stringify ( params ) ) ) ; } public async purgeCheckpoints ( iModelId ) { IModelJsFs . removeSync ( V1CheckpointManager . getFolder ( iModelId ) ) ; } public async purgeStorageCache ( ) { return IModelJsFs . purgeDirSync ( NativeHost . appSettingsCacheDir ) ; } public async beginOfflineScope ( ) { nock ( /^ https: \/\/.*$/i ) . log ( ( message , optionalParams ) => { console . log ( message , optionalParams ) ; } ) . get ( "/" ) . reply ( 503 ) ; } public async endOfflineScope ( ) { nock . cleanAll ( ) ; } } TestRpcImpl . register ( ) ;