From 57b3a2e05eb59bbfdbd53c39c64d49fb9d0ed150 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Wed, 10 Jun 2020 13:00:28 +0200 Subject: [PATCH] :zap: Cleanup of external hooks --- packages/cli/commands/execute.ts | 5 +++ packages/cli/commands/start.ts | 3 -- packages/cli/src/ExternalHooks.ts | 1 - packages/cli/src/Server.ts | 4 +- .../cli/src/externalHooksTemp/test-hooks.ts | 45 ------------------- 5 files changed, 7 insertions(+), 51 deletions(-) delete mode 100644 packages/cli/src/externalHooksTemp/test-hooks.ts diff --git a/packages/cli/commands/execute.ts b/packages/cli/commands/execute.ts index 7501b4aa9b..54016c5d55 100644 --- a/packages/cli/commands/execute.ts +++ b/packages/cli/commands/execute.ts @@ -10,6 +10,7 @@ import { import { ActiveExecutions, Db, + ExternalHooks, GenericHelpers, IWorkflowBase, IWorkflowExecutionDataProcess, @@ -103,6 +104,10 @@ export class Execute extends Command { // Wait till the n8n-packages have been read await loadNodesAndCredentialsPromise; + // Load all external hooks + const externalHooks = ExternalHooks(); + await externalHooks.init(); + // Add the found types to an instance other parts of the application can use const nodeTypes = NodeTypes(); await nodeTypes.init(loadNodesAndCredentials.nodeTypes); diff --git a/packages/cli/commands/start.ts b/packages/cli/commands/start.ts index 65edec601d..bce82bf890 100644 --- a/packages/cli/commands/start.ts +++ b/packages/cli/commands/start.ts @@ -5,7 +5,6 @@ import { } from 'n8n-core'; import { Command, flags } from '@oclif/command'; const open = require('open'); -// import { dirname } from 'path'; import * as config from '../config'; import { @@ -113,8 +112,6 @@ export class Start extends Command { const externalHooks = ExternalHooks(); await externalHooks.init(); - // await externalHooks.run('credentials.new'); - // Add the found types to an instance other parts of the application can use const nodeTypes = NodeTypes(); await nodeTypes.init(loadNodesAndCredentials.nodeTypes); diff --git a/packages/cli/src/ExternalHooks.ts b/packages/cli/src/ExternalHooks.ts index 9d195ccbad..b2b84cd7c7 100644 --- a/packages/cli/src/ExternalHooks.ts +++ b/packages/cli/src/ExternalHooks.ts @@ -6,7 +6,6 @@ import { import * as config from '../config'; -// export EXTERNAL_HOOK_FILES=/data/packages/cli/dist/src/externalHooksTemp/test-hooks.js class ExternalHooksClass implements IExternalHooksClass { diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index a36a2fd81e..d302e3970a 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -34,7 +34,7 @@ import { IExecutionsListResponse, IExecutionsStopData, IExecutionsSummary, - IExternalHooks, + IExternalHooksClass, IN8nUISettings, IPackageVersions, IWorkflowBase, @@ -94,7 +94,7 @@ class App { testWebhooks: TestWebhooks.TestWebhooks; endpointWebhook: string; endpointWebhookTest: string; - externalHooks: IExternalHooks; + externalHooks: IExternalHooksClass; saveDataErrorExecution: string; saveDataSuccessExecution: string; saveManualExecutions: boolean; diff --git a/packages/cli/src/externalHooksTemp/test-hooks.ts b/packages/cli/src/externalHooksTemp/test-hooks.ts deleted file mode 100644 index b49c0600b2..0000000000 --- a/packages/cli/src/externalHooksTemp/test-hooks.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { - WorkflowExecuteMode, -} from 'n8n-workflow'; - -import { - IExternalHooks, - IExternalHooksFunctions, - IWorkflowBase, - IWorkflowDb, -} from '../'; - - -export = { - credentials: { - create: [ - async function (this: IExternalHooksFunctions) { - // Here any additional code can run or the creation blocked - // throw new Error('No additional credentials can be created.'); - }, - ], - }, - workflow: { - execute: [ - async function (this: IExternalHooksFunctions, workflowData: IWorkflowDb, mode: WorkflowExecuteMode) { - console.log('execute: ' + mode); - // if (mode === 'integrated') { - // throw new Error('Workflow can not be executed.'); - // } - } - ], - update: [ - async function (this: IExternalHooksFunctions, workflowData: IWorkflowBase) { - console.log('update workflow hook'); - - // const responseData = await this.dbCollections.Workflow!.findOne(workflowData.id); - // console.log('workflowData'); - // console.log(responseData); - // console.log(workflowData); - - // Here any additional code can run or the creation blocked - // throw new Error('Workflow can not be updated.'); - }, - ], - }, -} as IExternalHooks;