Comparing version 0.22.0 to 0.23.0
@@ -1,2 +0,2 @@ | ||
import { IWebhookData, WebhookHttpMethod, WorkflowExecuteMode } from 'n8n-workflow'; | ||
import { IWebhookData, WebhookHttpMethod, Workflow, WorkflowExecuteMode } from 'n8n-workflow'; | ||
export declare class ActiveWebhooks { | ||
@@ -6,7 +6,8 @@ private workflowWebhooks; | ||
testWebhooks: boolean; | ||
add(webhookData: IWebhookData, mode: WorkflowExecuteMode): Promise<void>; | ||
add(workflow: Workflow, webhookData: IWebhookData, mode: WorkflowExecuteMode): Promise<void>; | ||
get(httpMethod: WebhookHttpMethod, path: string): IWebhookData | undefined; | ||
getWorkflowIds(): string[]; | ||
getWebhookKey(httpMethod: WebhookHttpMethod, path: string): string; | ||
removeByWorkflowId(workflowId: string): Promise<boolean>; | ||
removeAll(): Promise<void>; | ||
removeWorkflow(workflow: Workflow): Promise<boolean>; | ||
removeAll(workflows: Workflow[]): Promise<void>; | ||
} |
@@ -10,16 +10,15 @@ "use strict"; | ||
} | ||
async add(webhookData, mode) { | ||
if (webhookData.workflow.id === undefined) { | ||
async add(workflow, webhookData, mode) { | ||
if (workflow.id === undefined) { | ||
throw new Error('Webhooks can only be added for saved workflows as an id is needed!'); | ||
} | ||
if (this.workflowWebhooks[webhookData.workflow.id] === undefined) { | ||
this.workflowWebhooks[webhookData.workflow.id] = []; | ||
if (this.workflowWebhooks[webhookData.workflowId] === undefined) { | ||
this.workflowWebhooks[webhookData.workflowId] = []; | ||
} | ||
this.webhookUrls[this.getWebhookKey(webhookData.httpMethod, webhookData.path)] = webhookData; | ||
const webhookExists = await webhookData.workflow.runWebhookMethod('checkExists', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
const webhookExists = await workflow.runWebhookMethod('checkExists', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
if (webhookExists === false) { | ||
await webhookData.workflow.runWebhookMethod('create', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
await workflow.runWebhookMethod('create', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
} | ||
await webhookData.workflow.runNodeHooks('activate', webhookData, _1.NodeExecuteFunctions, mode); | ||
this.workflowWebhooks[webhookData.workflow.id].push(webhookData); | ||
this.workflowWebhooks[webhookData.workflowId].push(webhookData); | ||
} | ||
@@ -33,6 +32,10 @@ get(httpMethod, path) { | ||
} | ||
getWorkflowIds() { | ||
return Object.keys(this.workflowWebhooks); | ||
} | ||
getWebhookKey(httpMethod, path) { | ||
return `${httpMethod}|${path}`; | ||
} | ||
async removeByWorkflowId(workflowId) { | ||
async removeWorkflow(workflow) { | ||
const workflowId = workflow.id.toString(); | ||
if (this.workflowWebhooks[workflowId] === undefined) { | ||
@@ -44,4 +47,3 @@ return false; | ||
for (const webhookData of webhooks) { | ||
await webhookData.workflow.runWebhookMethod('delete', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
await webhookData.workflow.runNodeHooks('deactivate', webhookData, _1.NodeExecuteFunctions, mode); | ||
await workflow.runWebhookMethod('delete', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
delete this.webhookUrls[this.getWebhookKey(webhookData.httpMethod, webhookData.path)]; | ||
@@ -52,7 +54,6 @@ } | ||
} | ||
async removeAll() { | ||
const workflowIds = Object.keys(this.workflowWebhooks); | ||
async removeAll(workflows) { | ||
const removePromises = []; | ||
for (const workflowId of workflowIds) { | ||
removePromises.push(this.removeByWorkflowId(workflowId)); | ||
for (const workflow of workflows) { | ||
removePromises.push(this.removeWorkflow(workflow)); | ||
} | ||
@@ -59,0 +60,0 @@ await Promise.all(removePromises); |
@@ -19,5 +19,3 @@ "use strict"; | ||
console.log('ADD ID (active): ' + id); | ||
this.workflowData[id] = { | ||
workflow | ||
}; | ||
this.workflowData[id] = {}; | ||
const triggerNodes = workflow.getTriggerNodes(); | ||
@@ -24,0 +22,0 @@ let triggerResponse; |
/// <reference types="node" /> | ||
import { IBinaryData, ICredentialType, IDataObject, IExecuteFunctions as IExecuteFunctionsBase, IExecuteSingleFunctions as IExecuteSingleFunctionsBase, IHookFunctions as IHookFunctionsBase, ILoadOptionsFunctions as ILoadOptionsFunctionsBase, INodeExecutionData, INodeType, IPollFunctions as IPollFunctionsBase, IPollResponse, ITriggerFunctions as ITriggerFunctionsBase, ITriggerResponse, IWebhookFunctions as IWebhookFunctionsBase, IWorkflowSettings as IWorkflowSettingsWorkflow, Workflow } from 'n8n-workflow'; | ||
import { IBinaryData, ICredentialType, IDataObject, IExecuteFunctions as IExecuteFunctionsBase, IExecuteSingleFunctions as IExecuteSingleFunctionsBase, IHookFunctions as IHookFunctionsBase, ILoadOptionsFunctions as ILoadOptionsFunctionsBase, INodeExecutionData, INodeType, IPollFunctions as IPollFunctionsBase, IPollResponse, ITriggerFunctions as ITriggerFunctionsBase, ITriggerResponse, IWebhookFunctions as IWebhookFunctionsBase, IWorkflowSettings as IWorkflowSettingsWorkflow } from 'n8n-workflow'; | ||
import * as requestPromise from 'request-promise-native'; | ||
@@ -81,4 +81,3 @@ interface Constructable<T> { | ||
triggerResponses?: ITriggerResponse[]; | ||
workflow: Workflow; | ||
} | ||
export {}; |
{ | ||
"name": "n8n-core", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"description": "Core functionality of n8n", | ||
@@ -46,3 +46,3 @@ "license": "SEE LICENSE IN LICENSE.md", | ||
"mmmagic": "^0.5.2", | ||
"n8n-workflow": "~0.20.0", | ||
"n8n-workflow": "~0.21.0", | ||
"p-cancelable": "^2.0.0", | ||
@@ -49,0 +49,0 @@ "request-promise-native": "^1.0.7" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191253
2533
+ Addedn8n-workflow@0.21.0(transitive)
- Removedn8n-workflow@0.20.0(transitive)
Updatedn8n-workflow@~0.21.0