import { IExternalHooks , IRootState } from '@/Interface' ; import { IDataObject } from 'n8n-workflow' ; import Vue from 'vue' ; import { Store } from 'vuex' ; export async function runExternalHook ( eventName , store , metadata ? ) { if ( ! window . n8nExternalHooks ) { return ; } const [ resource , operator ] = eventName . split ( '.' ) ; if ( window . n8nExternalHooks [ resource ] && window . n8nExternalHooks [ resource ] [ operator ] ) { const hookMethods = window . n8nExternalHooks [ resource ] [ operator ] ; for ( const hookmethod of hookMethods ) { await hookmethod ( store , metadata ) ; } } } export const externalHooks = Vue . extend ( { methods : { $externalHooks ( ) { return { run : async ( eventName , metadata ? ) : Promise < void > => { await runExternalHook . call ( this , eventName , this . $store , metadata ) ; } , } ; } , } , } ) ;