Comparing version 0.59.0 to 0.60.0
@@ -7,8 +7,8 @@ import { IWebhookData, WebhookHttpMethod, Workflow, WorkflowExecuteMode } from 'n8n-workflow'; | ||
add(workflow: Workflow, webhookData: IWebhookData, mode: WorkflowExecuteMode): Promise<void>; | ||
get(httpMethod: WebhookHttpMethod, path: string): IWebhookData | undefined; | ||
get(httpMethod: WebhookHttpMethod, path: string, webhookId?: string): IWebhookData | undefined; | ||
getWebhookMethods(path: string): string[]; | ||
getWorkflowIds(): string[]; | ||
getWebhookKey(httpMethod: WebhookHttpMethod, path: string): string; | ||
getWebhookKey(httpMethod: WebhookHttpMethod, path: string, webhookId?: string): string; | ||
removeWorkflow(workflow: Workflow): Promise<boolean>; | ||
removeAll(workflows: Workflow[]): Promise<void>; | ||
} |
@@ -15,4 +15,4 @@ "use strict"; | ||
} | ||
const webhookKey = this.getWebhookKey(webhookData.httpMethod, webhookData.path); | ||
if (this.webhookUrls[webhookKey] !== undefined) { | ||
const webhookKey = this.getWebhookKey(webhookData.httpMethod, webhookData.path, webhookData.webhookId); | ||
if (this.webhookUrls[webhookKey] && !webhookData.webhookId) { | ||
throw new Error(`Test-Webhook can not be activated because another one with the same method "${webhookData.httpMethod}" and path "${webhookData.path}" is already active!`); | ||
@@ -23,3 +23,6 @@ } | ||
} | ||
this.webhookUrls[webhookKey] = webhookData; | ||
if (!this.webhookUrls[webhookKey]) { | ||
this.webhookUrls[webhookKey] = []; | ||
} | ||
this.webhookUrls[webhookKey].push(webhookData); | ||
try { | ||
@@ -32,3 +35,8 @@ const webhookExists = await workflow.runWebhookMethod('checkExists', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
catch (error) { | ||
delete this.webhookUrls[webhookKey]; | ||
if (this.webhookUrls[webhookKey].length <= 1) { | ||
delete this.webhookUrls[webhookKey]; | ||
} | ||
else { | ||
this.webhookUrls[webhookKey] = this.webhookUrls[webhookKey].filter(webhook => webhook.path !== webhookData.path); | ||
} | ||
throw error; | ||
@@ -38,8 +46,25 @@ } | ||
} | ||
get(httpMethod, path) { | ||
const webhookKey = this.getWebhookKey(httpMethod, path); | ||
get(httpMethod, path, webhookId) { | ||
const webhookKey = this.getWebhookKey(httpMethod, path, webhookId); | ||
if (this.webhookUrls[webhookKey] === undefined) { | ||
return undefined; | ||
} | ||
return this.webhookUrls[webhookKey]; | ||
let webhook = this.webhookUrls[webhookKey][0]; | ||
if (this.webhookUrls[webhookKey].length > 1) { | ||
let maxMatches = 0; | ||
const pathElementsSet = new Set(path.split('/')); | ||
this.webhookUrls[webhookKey].forEach(dynamicWebhook => { | ||
const intersection = dynamicWebhook.path | ||
.split('/') | ||
.reduce((acc, element) => pathElementsSet.has(element) ? acc += 1 : acc, 0); | ||
if (intersection > maxMatches) { | ||
maxMatches = intersection; | ||
webhook = dynamicWebhook; | ||
} | ||
}); | ||
if (maxMatches === 0) { | ||
return undefined; | ||
} | ||
} | ||
return webhook; | ||
} | ||
@@ -58,3 +83,10 @@ getWebhookMethods(path) { | ||
} | ||
getWebhookKey(httpMethod, path) { | ||
getWebhookKey(httpMethod, path, webhookId) { | ||
if (webhookId) { | ||
if (path.startsWith(webhookId)) { | ||
const cutFromIndex = path.indexOf('/') + 1; | ||
path = path.slice(cutFromIndex); | ||
} | ||
return `${httpMethod}|${webhookId}|${path.split('/').length}`; | ||
} | ||
return `${httpMethod}|${path}`; | ||
@@ -71,3 +103,3 @@ } | ||
await workflow.runWebhookMethod('delete', webhookData, _1.NodeExecuteFunctions, mode, this.testWebhooks); | ||
delete this.webhookUrls[this.getWebhookKey(webhookData.httpMethod, webhookData.path)]; | ||
delete this.webhookUrls[this.getWebhookKey(webhookData.httpMethod, webhookData.path, webhookData.webhookId)]; | ||
} | ||
@@ -74,0 +106,0 @@ delete this.workflowWebhooks[workflowId]; |
@@ -10,3 +10,3 @@ /// <reference types="node" /> | ||
export declare function returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[]; | ||
export declare function getCredentials(workflow: Workflow, node: INode, type: string, additionalData: IWorkflowExecuteAdditionalData): ICredentialDataDecryptedObject | undefined; | ||
export declare function getCredentials(workflow: Workflow, node: INode, type: string, additionalData: IWorkflowExecuteAdditionalData, runExecutionData?: IRunExecutionData | null, runIndex?: number, connectionInputData?: INodeExecutionData[], itemIndex?: number): ICredentialDataDecryptedObject | undefined; | ||
export declare function getNode(node: INode): INode; | ||
@@ -13,0 +13,0 @@ export declare function getNodeParameter(workflow: Workflow, runExecutionData: IRunExecutionData | null, runIndex: number, connectionInputData: INodeExecutionData[], node: INode, parameterName: string, itemIndex: number, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; |
@@ -147,3 +147,3 @@ "use strict"; | ||
exports.returnJsonArray = returnJsonArray; | ||
function getCredentials(workflow, node, type, additionalData) { | ||
function getCredentials(workflow, node, type, additionalData, runExecutionData, runIndex, connectionInputData, itemIndex) { | ||
const nodeType = workflow.nodeTypes.getByName(node.type); | ||
@@ -176,4 +176,15 @@ if (nodeType === undefined) { | ||
} | ||
let expressionResolveValues; | ||
if (connectionInputData && runExecutionData && runIndex !== undefined) { | ||
expressionResolveValues = { | ||
connectionInputData, | ||
itemIndex: itemIndex || 0, | ||
node, | ||
runExecutionData, | ||
runIndex, | ||
workflow, | ||
}; | ||
} | ||
const name = node.credentials[type]; | ||
const decryptedDataObject = additionalData.credentialsHelper.getDecrypted(name, type); | ||
const decryptedDataObject = additionalData.credentialsHelper.getDecrypted(name, type, false, expressionResolveValues); | ||
return decryptedDataObject; | ||
@@ -368,4 +379,4 @@ } | ||
}, | ||
getCredentials(type) { | ||
return getCredentials(workflow, node, type, additionalData); | ||
getCredentials(type, itemIndex) { | ||
return getCredentials(workflow, node, type, additionalData, runExecutionData, runIndex, connectionInputData, itemIndex); | ||
}, | ||
@@ -439,3 +450,3 @@ getInputData: (inputIndex = 0, inputName = 'main') => { | ||
getCredentials(type) { | ||
return getCredentials(workflow, node, type, additionalData); | ||
return getCredentials(workflow, node, type, additionalData, runExecutionData, runIndex, connectionInputData, itemIndex); | ||
}, | ||
@@ -628,2 +639,8 @@ getInputData: (inputIndex = 0, inputName = 'main') => { | ||
}, | ||
getParamsData() { | ||
if (additionalData.httpRequest === undefined) { | ||
throw new Error('Request is missing!'); | ||
} | ||
return additionalData.httpRequest.params; | ||
}, | ||
getQueryData() { | ||
@@ -630,0 +647,0 @@ if (additionalData.httpRequest === undefined) { |
{ | ||
"name": "n8n-core", | ||
"version": "0.59.0", | ||
"version": "0.60.0", | ||
"description": "Core functionality of n8n", | ||
@@ -50,3 +50,3 @@ "license": "SEE LICENSE IN LICENSE.md", | ||
"mime-types": "^2.1.27", | ||
"n8n-workflow": "~0.48.0", | ||
"n8n-workflow": "~0.49.0", | ||
"oauth-1.0a": "^2.2.6", | ||
@@ -53,0 +53,0 @@ "p-cancelable": "^2.0.0", |
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
280191
3717
+ Addedn8n-workflow@0.49.0(transitive)
- Removedn8n-workflow@0.48.0(transitive)
Updatedn8n-workflow@~0.49.0