mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 09:04:07 -08:00
9c94050deb
* refactor: replace Vue.extend with defineComponent in editor-ui * fix: change $externalHooks extractions from mixins * fix: refactor externalHooks mixin
19 lines
494 B
TypeScript
19 lines
494 B
TypeScript
import type { IDataObject } from 'n8n-workflow';
|
|
import type { Store } from 'pinia';
|
|
|
|
export async function runExternalHook(eventName: string, store: Store, metadata?: IDataObject) {
|
|
if (!window.n8nExternalHooks) {
|
|
return;
|
|
}
|
|
|
|
const [resource, operator] = eventName.split('.');
|
|
|
|
if (window.n8nExternalHooks[resource]?.[operator]) {
|
|
const hookMethods = window.n8nExternalHooks[resource][operator];
|
|
|
|
for (const hookMethod of hookMethods) {
|
|
await hookMethod(store, metadata);
|
|
}
|
|
}
|
|
}
|