Cleanup of external hooks

This commit is contained in:
Jan Oberhauser 2020-06-10 13:00:28 +02:00
parent 6e1254fd54
commit 57b3a2e05e
5 changed files with 7 additions and 51 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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 {

View file

@ -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;

View file

@ -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;