import { mockBridge as bridge , BridgeMethods , SpecialMethods , Fn , APBridgeMethods } from '@goldfishjs/bridge' ; import { GetPlugin } from './Plugin' ; import ConfigPlugin , { IConfig } from './ConfigPlugin' ; import BridgePlugin from './BridgePlugin' ; export default class MockBridgePlugin extends BridgePlugin { private host ? : string ; public async init ( getPlugin ) { const configPlugin = getPlugin ( ConfigPlugin ) as ConfigPlugin < IConfig > ; this . host = configPlugin . get ( 'bridgeMockServerHost' ) ; } public destroy ( ) { } public async call < T extends keyof R , R extends Record < string , any > = BridgeMethods & SpecialMethods > ( api , params ? ) { return this . host ? bridge . call ( this . host , api , params ) : super . call ( api , params ) ; } public async mycall < R , P = Record < string , any > > ( api , params ? ) { return this . host ? bridge . mycall ( this . host , api , params ) : super . mycall ( api , params ) ; } public async ap < T extends keyof R , R extends Record < string , Fn > = APBridgeMethods > ( api , params ? ) { return this . host ? bridge . ap ( this . host , api , params ) : super . ap ( api , params ) ; } }