🔀 Merge branch 'master' into oauth-support

This commit is contained in:
Jan Oberhauser
2020-04-04 17:34:10 +02:00
376 changed files with 45850 additions and 2723 deletions

View File

@@ -28,6 +28,7 @@ import {
IWebhookFunctions,
IWorkflowDataProxyData,
IWorkflowExecuteAdditionalData,
IWorkflowMetadata,
NodeHelpers,
NodeParameterValue,
Workflow,
@@ -253,6 +254,19 @@ export function getCredentials(workflow: Workflow, node: INode, type: string, ad
/**
* Returns a copy of the node
*
* @export
* @param {INode} node
* @returns {INode}
*/
export function getNode(node: INode): INode {
return JSON.parse(JSON.stringify(node));
}
/**
* Returns the requested resolved (all expressions replaced) node parameters.
*
@@ -292,6 +306,19 @@ export function getNodeParameter(workflow: Workflow, runExecutionData: IRunExecu
/**
* Returns if execution should be continued even if there was an error.
*
* @export
* @param {INode} node
* @returns {boolean}
*/
export function continueOnFail(node: INode): boolean {
return get(node, 'continueOnFail', false);
}
/**
* Returns the webhook URL of the webhook with the given name
*
@@ -369,6 +396,23 @@ export function getWebhookDescription(name: string, workflow: Workflow, node: IN
/**
* Returns the workflow metadata
*
* @export
* @param {Workflow} workflow
* @returns {IWorkflowMetadata}
*/
export function getWorkflowMetadata(workflow: Workflow): IWorkflowMetadata {
return {
id: workflow.id,
name: workflow.name,
active: workflow.active,
};
}
/**
* Returns the execute functions the poll nodes have access to.
*
@@ -392,6 +436,9 @@ export function getExecutePollFunctions(workflow: Workflow, node: INode, additio
getMode: (): WorkflowExecuteMode => {
return mode;
},
getNode: () => {
return getNode(node);
},
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
@@ -406,6 +453,9 @@ export function getExecutePollFunctions(workflow: Workflow, node: INode, additio
getTimezone: (): string => {
return getTimezone(workflow, additionalData);
},
getWorkflow: () => {
return getWorkflowMetadata(workflow);
},
getWorkflowStaticData(type: string): IDataObject {
return workflow.getStaticData(type, node);
},
@@ -443,6 +493,9 @@ export function getExecuteTriggerFunctions(workflow: Workflow, node: INode, addi
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData);
},
getNode: () => {
return getNode(node);
},
getMode: (): WorkflowExecuteMode => {
return mode;
},
@@ -460,6 +513,9 @@ export function getExecuteTriggerFunctions(workflow: Workflow, node: INode, addi
getTimezone: (): string => {
return getTimezone(workflow, additionalData);
},
getWorkflow: () => {
return getWorkflowMetadata(workflow);
},
getWorkflowStaticData(type: string): IDataObject {
return workflow.getStaticData(type, node);
},
@@ -494,6 +550,12 @@ export function getExecuteTriggerFunctions(workflow: Workflow, node: INode, addi
export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteFunctions {
return ((workflow, runExecutionData, connectionInputData, inputData, node) => {
return {
continueOnFail: () => {
return continueOnFail(node);
},
evaluateExpression: (expression: string, itemIndex: number) => {
return workflow.resolveSimpleParameterValue('=' + expression, runExecutionData, runIndex, itemIndex, node.name, connectionInputData);
},
async executeWorkflow(workflowInfo: IExecuteWorkflowInfo, inputData?: INodeExecutionData[]): Promise<any> { // tslint:disable-line:no-any
return additionalData.executeWorkflow(workflowInfo, additionalData, inputData);
},
@@ -530,12 +592,18 @@ export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunEx
getMode: (): WorkflowExecuteMode => {
return mode;
},
getNode: () => {
return getNode(node);
},
getRestApiUrl: (): string => {
return additionalData.restApiUrl;
},
getTimezone: (): string => {
return getTimezone(workflow, additionalData);
},
getWorkflow: () => {
return getWorkflowMetadata(workflow);
},
getWorkflowDataProxy: (itemIndex: number): IWorkflowDataProxyData => {
const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData);
return dataProxy.getDataProxy();
@@ -576,6 +644,13 @@ export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunEx
export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, itemIndex: number, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteSingleFunctions {
return ((workflow, runExecutionData, connectionInputData, inputData, node, itemIndex) => {
return {
continueOnFail: () => {
return continueOnFail(node);
},
evaluateExpression: (expression: string, evaluateItemIndex: number | undefined) => {
evaluateItemIndex = evaluateItemIndex === undefined ? itemIndex : evaluateItemIndex;
return workflow.resolveSimpleParameterValue('=' + expression, runExecutionData, runIndex, evaluateItemIndex, node.name, connectionInputData);
},
getContext(type: string): IContextObject {
return NodeHelpers.getContext(runExecutionData, type, node);
},
@@ -610,6 +685,9 @@ export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData:
getMode: (): WorkflowExecuteMode => {
return mode;
},
getNode: () => {
return getNode(node);
},
getRestApiUrl: (): string => {
return additionalData.restApiUrl;
},
@@ -619,6 +697,9 @@ export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData:
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, fallbackValue);
},
getWorkflow: () => {
return getWorkflowMetadata(workflow);
},
getWorkflowDataProxy: (): IWorkflowDataProxyData => {
const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData);
return dataProxy.getDataProxy();
@@ -663,6 +744,9 @@ export function getLoadOptionsFunctions(workflow: Workflow, node: INode, additio
getCurrentNodeParameters: (): INodeParameters | undefined => {
return JSON.parse('' + additionalData.currentNodeParameters);
},
getNode: () => {
return getNode(node);
},
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
@@ -709,6 +793,9 @@ export function getExecuteHookFunctions(workflow: Workflow, node: INode, additio
getMode: (): WorkflowExecuteMode => {
return mode;
},
getNode: () => {
return getNode(node);
},
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
@@ -732,6 +819,9 @@ export function getExecuteHookFunctions(workflow: Workflow, node: INode, additio
getWebhookDescription(name: string): IWebhookDescription | undefined {
return getWebhookDescription(name, workflow, node);
},
getWorkflow: () => {
return getWorkflowMetadata(workflow);
},
getWorkflowStaticData(type: string): IDataObject {
return workflow.getStaticData(type, node);
},
@@ -780,6 +870,9 @@ export function getExecuteWebhookFunctions(workflow: Workflow, node: INode, addi
getMode: (): WorkflowExecuteMode => {
return mode;
},
getNode: () => {
return getNode(node);
},
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
@@ -812,6 +905,9 @@ export function getExecuteWebhookFunctions(workflow: Workflow, node: INode, addi
getTimezone: (): string => {
return getTimezone(workflow, additionalData);
},
getWorkflow: () => {
return getWorkflowMetadata(workflow);
},
getWorkflowStaticData(type: string): IDataObject {
return workflow.getStaticData(type, node);
},