Comparing version 0.7.0 to 0.8.0
@@ -1,2 +0,2 @@ | ||
import { ITriggerResponse, IWorkflowExecuteAdditionalData, Workflow } from 'n8n-workflow'; | ||
import { IGetExecuteTriggerFunctions, ITriggerResponse, IWorkflowExecuteAdditionalData, Workflow } from 'n8n-workflow'; | ||
export interface WorkflowData { | ||
@@ -11,4 +11,4 @@ workflow: Workflow; | ||
get(id: string): WorkflowData | undefined; | ||
add(id: string, workflow: Workflow, additionalData: IWorkflowExecuteAdditionalData): Promise<void>; | ||
add(id: string, workflow: Workflow, additionalData: IWorkflowExecuteAdditionalData, getTriggerFunctions: IGetExecuteTriggerFunctions): Promise<void>; | ||
remove(id: string): Promise<void>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const _1 = require("./"); | ||
class ActiveWorkflows { | ||
@@ -17,3 +16,3 @@ constructor() { | ||
} | ||
async add(id, workflow, additionalData) { | ||
async add(id, workflow, additionalData, getTriggerFunctions) { | ||
console.log('ADD ID (active): ' + id); | ||
@@ -26,3 +25,3 @@ this.workflowData[id] = { | ||
for (const triggerNode of triggerNodes) { | ||
triggerResponse = await workflow.runTrigger(triggerNode, _1.NodeExecuteFunctions, additionalData, 'trigger'); | ||
triggerResponse = await workflow.runTrigger(triggerNode, getTriggerFunctions, additionalData, 'trigger'); | ||
if (triggerResponse !== undefined) { | ||
@@ -29,0 +28,0 @@ this.workflowData[id].triggerResponse = triggerResponse; |
@@ -10,5 +10,4 @@ export * from './ActiveWorkflows'; | ||
export * from './WorkflowExecute'; | ||
import * as ActiveExecutions from './ActiveExecutions'; | ||
import * as NodeExecuteFunctions from './NodeExecuteFunctions'; | ||
import * as UserSettings from './UserSettings'; | ||
export { ActiveExecutions, NodeExecuteFunctions, UserSettings, }; | ||
export { NodeExecuteFunctions, UserSettings, }; |
@@ -19,4 +19,2 @@ "use strict"; | ||
__export(require("./WorkflowExecute")); | ||
const ActiveExecutions = require("./ActiveExecutions"); | ||
exports.ActiveExecutions = ActiveExecutions; | ||
const NodeExecuteFunctions = require("./NodeExecuteFunctions"); | ||
@@ -23,0 +21,0 @@ exports.NodeExecuteFunctions = NodeExecuteFunctions; |
/// <reference types="node" /> | ||
import { IBinaryData, ICredentialType, IDataObject, IExecuteFunctions as IExecuteFunctionsBase, IExecuteSingleFunctions as IExecuteSingleFunctionsBase, IHookFunctions as IHookFunctionsBase, ILoadOptionsFunctions as ILoadOptionsFunctionsBase, INodeExecutionData, INodeType, IRun, IRunExecutionData, ITriggerFunctions as ITriggerFunctionsBase, IWebhookFunctions as IWebhookFunctionsBase, IWorkflowSettings as IWorkflowSettingsWorkflow, Workflow, WorkflowExecuteMode } from 'n8n-workflow'; | ||
import { IDeferredPromise } from '.'; | ||
import { IBinaryData, ICredentialType, IDataObject, IExecuteFunctions as IExecuteFunctionsBase, IExecuteSingleFunctions as IExecuteSingleFunctionsBase, IHookFunctions as IHookFunctionsBase, ILoadOptionsFunctions as ILoadOptionsFunctionsBase, INodeExecutionData, INodeType, ITriggerFunctions as ITriggerFunctionsBase, IWebhookFunctions as IWebhookFunctionsBase, IWorkflowSettings as IWorkflowSettingsWorkflow } from 'n8n-workflow'; | ||
import * as request from 'request'; | ||
@@ -9,2 +8,6 @@ import * as requestPromise from 'request-promise-native'; | ||
} | ||
export interface IProcessMessage { | ||
data?: any; | ||
type: string; | ||
} | ||
export interface IExecuteFunctions extends IExecuteFunctionsBase { | ||
@@ -23,15 +26,2 @@ helpers: { | ||
} | ||
export interface IExecutingWorkflowData { | ||
runExecutionData: IRunExecutionData; | ||
startedAt: Date; | ||
mode: WorkflowExecuteMode; | ||
workflow: Workflow; | ||
postExecutePromises: Array<IDeferredPromise<IRun>>; | ||
} | ||
export interface IExecutionsCurrentSummary { | ||
id: string; | ||
startedAt: Date; | ||
mode: WorkflowExecuteMode; | ||
workflowId: string; | ||
} | ||
export interface ITriggerFunctions extends ITriggerFunctionsBase { | ||
@@ -38,0 +28,0 @@ helpers: { |
@@ -147,23 +147,3 @@ "use strict"; | ||
emit: (data) => { | ||
const workflowExecute = new _1.WorkflowExecute(additionalData, mode); | ||
const nodeExecutionStack = [ | ||
{ | ||
node, | ||
data: { | ||
main: data, | ||
} | ||
} | ||
]; | ||
const runExecutionData = { | ||
startData: {}, | ||
resultData: { | ||
runData: {}, | ||
}, | ||
executionData: { | ||
contextData: {}, | ||
nodeExecutionStack, | ||
waitingExecution: {}, | ||
}, | ||
}; | ||
workflowExecute.runExecutionData(workflow, runExecutionData); | ||
throw new Error('Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function!'); | ||
}, | ||
@@ -170,0 +150,0 @@ getCredentials(type) { |
@@ -1,13 +0,14 @@ | ||
import { IConnection, INode, INodeExecutionData, IRunData, IRunExecutionData, IWorkflowExecuteAdditionalData, WorkflowExecuteMode, Workflow } from 'n8n-workflow'; | ||
import { IConnection, IExecutionError, INode, INodeExecutionData, IRun, IRunData, IRunExecutionData, IWorkflowExecuteAdditionalData, WorkflowExecuteMode, Workflow } from 'n8n-workflow'; | ||
export declare class WorkflowExecute { | ||
runExecutionData: IRunExecutionData; | ||
private additionalData; | ||
private mode; | ||
private activeExecutions; | ||
private executionId; | ||
constructor(additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode); | ||
run(workflow: Workflow, startNode?: INode, destinationNode?: string): Promise<string>; | ||
runPartialWorkflow(workflow: Workflow, runData: IRunData, startNodes: string[], destinationNode: string): Promise<string>; | ||
constructor(additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, runExecutionData?: IRunExecutionData); | ||
run(workflow: Workflow, startNode?: INode, destinationNode?: string): Promise<IRun>; | ||
runPartialWorkflow(workflow: Workflow, runData: IRunData, startNodes: string[], destinationNode: string): Promise<IRun>; | ||
executeHook(hookName: string, parameters: any[]): Promise<void>; | ||
addNodeToBeExecuted(workflow: Workflow, runExecutionData: IRunExecutionData, connectionData: IConnection, outputIndex: number, parentNodeName: string, nodeSuccessData: INodeExecutionData[][], runIndex: number): void; | ||
runExecutionData(workflow: Workflow, runExecutionData: IRunExecutionData): Promise<string>; | ||
addNodeToBeExecuted(workflow: Workflow, connectionData: IConnection, outputIndex: number, parentNodeName: string, nodeSuccessData: INodeExecutionData[][], runIndex: number): void; | ||
processRunExecutionData(workflow: Workflow): Promise<IRun>; | ||
processSuccessExecution(startedAt: Date, workflow: Workflow, executionError?: IExecutionError): Promise<IRun>; | ||
getFullRunData(startedAt: Date): IRun; | ||
} |
@@ -5,7 +5,16 @@ "use strict"; | ||
class WorkflowExecute { | ||
constructor(additionalData, mode) { | ||
this.executionId = null; | ||
constructor(additionalData, mode, runExecutionData) { | ||
this.additionalData = additionalData; | ||
this.activeExecutions = _1.ActiveExecutions.getInstance(); | ||
this.mode = mode; | ||
this.runExecutionData = runExecutionData || { | ||
startData: {}, | ||
resultData: { | ||
runData: {}, | ||
}, | ||
executionData: { | ||
contextData: {}, | ||
nodeExecutionStack: [], | ||
waitingExecution: {}, | ||
}, | ||
}; | ||
} | ||
@@ -36,3 +45,3 @@ async run(workflow, startNode, destinationNode) { | ||
]; | ||
const runExecutionData = { | ||
this.runExecutionData = { | ||
startData: { | ||
@@ -51,3 +60,3 @@ destinationNode, | ||
}; | ||
return this.runExecutionData(workflow, runExecutionData); | ||
return this.processRunExecutionData(workflow); | ||
} | ||
@@ -112,3 +121,3 @@ async runPartialWorkflow(workflow, runData, startNodes, destinationNode) { | ||
runNodeFilter.push(destinationNode); | ||
const runExecutionData = { | ||
this.runExecutionData = { | ||
startData: { | ||
@@ -127,3 +136,3 @@ destinationNode, | ||
}; | ||
return await this.runExecutionData(workflow, runExecutionData); | ||
return await this.processRunExecutionData(workflow); | ||
} | ||
@@ -148,28 +157,28 @@ async executeHook(hookName, parameters) { | ||
} | ||
addNodeToBeExecuted(workflow, runExecutionData, connectionData, outputIndex, parentNodeName, nodeSuccessData, runIndex) { | ||
addNodeToBeExecuted(workflow, connectionData, outputIndex, parentNodeName, nodeSuccessData, runIndex) { | ||
let stillDataMissing = false; | ||
if (workflow.connectionsByDestinationNode[connectionData.node]['main'].length > 1) { | ||
let nodeWasWaiting = true; | ||
if (runExecutionData.executionData.waitingExecution[connectionData.node] === undefined) { | ||
runExecutionData.executionData.waitingExecution[connectionData.node] = {}; | ||
if (this.runExecutionData.executionData.waitingExecution[connectionData.node] === undefined) { | ||
this.runExecutionData.executionData.waitingExecution[connectionData.node] = {}; | ||
nodeWasWaiting = false; | ||
} | ||
if (runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] === undefined) { | ||
runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] = { | ||
if (this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] === undefined) { | ||
this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] = { | ||
main: [] | ||
}; | ||
for (let i = 0; i < workflow.connectionsByDestinationNode[connectionData.node]['main'].length; i++) { | ||
runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main.push(null); | ||
this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main.push(null); | ||
} | ||
} | ||
if (nodeSuccessData === null) { | ||
runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main[connectionData.index] = null; | ||
this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main[connectionData.index] = null; | ||
} | ||
else { | ||
runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main[connectionData.index] = nodeSuccessData[outputIndex]; | ||
this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main[connectionData.index] = nodeSuccessData[outputIndex]; | ||
} | ||
let thisExecutionData; | ||
let allDataFound = true; | ||
for (let i = 0; i < runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main.length; i++) { | ||
thisExecutionData = runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main[i]; | ||
for (let i = 0; i < this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main.length; i++) { | ||
thisExecutionData = this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex].main[i]; | ||
if (thisExecutionData === null) { | ||
@@ -181,9 +190,9 @@ allDataFound = false; | ||
if (allDataFound === true) { | ||
runExecutionData.executionData.nodeExecutionStack.push({ | ||
this.runExecutionData.executionData.nodeExecutionStack.push({ | ||
node: workflow.nodes[connectionData.node], | ||
data: runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] | ||
data: this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] | ||
}); | ||
delete runExecutionData.executionData.waitingExecution[connectionData.node][runIndex]; | ||
if (Object.keys(runExecutionData.executionData.waitingExecution[connectionData.node]).length === 0) { | ||
delete runExecutionData.executionData.waitingExecution[connectionData.node]; | ||
delete this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex]; | ||
if (Object.keys(this.runExecutionData.executionData.waitingExecution[connectionData.node]).length === 0) { | ||
delete this.runExecutionData.executionData.waitingExecution[connectionData.node]; | ||
} | ||
@@ -210,3 +219,3 @@ return; | ||
} | ||
const executionStackNodes = runExecutionData.executionData.nodeExecutionStack.map((stackData) => stackData.node.name); | ||
const executionStackNodes = this.runExecutionData.executionData.nodeExecutionStack.map((stackData) => stackData.node.name); | ||
if (inputData.node !== parentNodeName && checkOutputNodes.includes(inputData.node)) { | ||
@@ -218,3 +227,3 @@ continue; | ||
} | ||
if (runExecutionData.resultData.runData[inputData.node] !== undefined) { | ||
if (this.runExecutionData.resultData.runData[inputData.node] !== undefined) { | ||
continue; | ||
@@ -235,3 +244,3 @@ } | ||
} | ||
if (runExecutionData.resultData.runData[parentNode] !== undefined) { | ||
if (this.runExecutionData.resultData.runData[parentNode] !== undefined) { | ||
break; | ||
@@ -245,3 +254,3 @@ } | ||
if (workflow.connectionsByDestinationNode[nodeToAdd] === undefined) { | ||
runExecutionData.executionData.nodeExecutionStack.push({ | ||
this.runExecutionData.executionData.nodeExecutionStack.push({ | ||
node: workflow.getNode(nodeToAdd), | ||
@@ -274,6 +283,6 @@ data: { | ||
if (stillDataMissing === true) { | ||
if (!runExecutionData.executionData.waitingExecution.hasOwnProperty(connectionData.node)) { | ||
runExecutionData.executionData.waitingExecution[connectionData.node] = {}; | ||
if (!this.runExecutionData.executionData.waitingExecution.hasOwnProperty(connectionData.node)) { | ||
this.runExecutionData.executionData.waitingExecution[connectionData.node] = {}; | ||
} | ||
runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] = { | ||
this.runExecutionData.executionData.waitingExecution[connectionData.node][runIndex] = { | ||
main: connectionDataArray | ||
@@ -283,3 +292,3 @@ }; | ||
else { | ||
runExecutionData.executionData.nodeExecutionStack.push({ | ||
this.runExecutionData.executionData.nodeExecutionStack.push({ | ||
node: workflow.nodes[connectionData.node], | ||
@@ -292,4 +301,4 @@ data: { | ||
} | ||
async runExecutionData(workflow, runExecutionData) { | ||
const startedAt = new Date().getTime(); | ||
async processRunExecutionData(workflow) { | ||
const startedAt = new Date(); | ||
const workflowIssues = workflow.checkReadyForExecution(); | ||
@@ -306,22 +315,18 @@ if (workflowIssues !== null) { | ||
let taskData; | ||
if (runExecutionData.startData === undefined) { | ||
runExecutionData.startData = {}; | ||
if (this.runExecutionData.startData === undefined) { | ||
this.runExecutionData.startData = {}; | ||
} | ||
this.executionId = this.activeExecutions.add(workflow, runExecutionData, this.mode); | ||
this.executeHook('workflowExecuteBefore', [this.executionId]); | ||
this.executeHook('workflowExecuteBefore', []); | ||
let currentExecutionTry = ''; | ||
let lastExecutionTry = ''; | ||
process.nextTick(() => (async () => { | ||
executionLoop: while (runExecutionData.executionData.nodeExecutionStack.length !== 0) { | ||
if (this.activeExecutions.shouldBeStopped(this.executionId) === true) { | ||
break; | ||
} | ||
return (async () => { | ||
executionLoop: while (this.runExecutionData.executionData.nodeExecutionStack.length !== 0) { | ||
nodeSuccessData = null; | ||
executionError = undefined; | ||
executionData = runExecutionData.executionData.nodeExecutionStack.shift(); | ||
executionData = this.runExecutionData.executionData.nodeExecutionStack.shift(); | ||
executionNode = executionData.node; | ||
this.executeHook('nodeExecuteBefore', [this.executionId, executionNode.name]); | ||
this.executeHook('nodeExecuteBefore', [executionNode.name]); | ||
runIndex = 0; | ||
if (runExecutionData.resultData.runData.hasOwnProperty(executionNode.name)) { | ||
runIndex = runExecutionData.resultData.runData[executionNode.name].length; | ||
if (this.runExecutionData.resultData.runData.hasOwnProperty(executionNode.name)) { | ||
runIndex = this.runExecutionData.resultData.runData[executionNode.name].length; | ||
} | ||
@@ -332,3 +337,3 @@ currentExecutionTry = `${executionNode.name}:${runIndex}`; | ||
} | ||
if (runExecutionData.startData.runNodeFilter !== undefined && runExecutionData.startData.runNodeFilter.indexOf(executionNode.name) === -1) { | ||
if (this.runExecutionData.startData.runNodeFilter !== undefined && this.runExecutionData.startData.runNodeFilter.indexOf(executionNode.name) === -1) { | ||
continue; | ||
@@ -346,3 +351,3 @@ } | ||
if (!executionData.data.hasOwnProperty('main')) { | ||
runExecutionData.executionData.nodeExecutionStack.push(executionData); | ||
this.runExecutionData.executionData.nodeExecutionStack.push(executionData); | ||
lastExecutionTry = currentExecutionTry; | ||
@@ -352,3 +357,3 @@ continue executionLoop; | ||
if (executionData.data.main.length < connectionIndex || executionData.data.main[connectionIndex] === null) { | ||
runExecutionData.executionData.nodeExecutionStack.push(executionData); | ||
this.runExecutionData.executionData.nodeExecutionStack.push(executionData); | ||
lastExecutionTry = currentExecutionTry; | ||
@@ -381,7 +386,4 @@ continue executionLoop; | ||
} | ||
if (this.activeExecutions.shouldBeStopped(this.executionId) === true) { | ||
break; | ||
} | ||
runExecutionData.resultData.lastNodeExecuted = executionData.node.name; | ||
nodeSuccessData = await workflow.runNode(executionData.node, executionData.data, runExecutionData, runIndex, this.additionalData, _1.NodeExecuteFunctions, this.mode); | ||
this.runExecutionData.resultData.lastNodeExecuted = executionData.node.name; | ||
nodeSuccessData = await workflow.runNode(executionData.node, executionData.data, this.runExecutionData, runIndex, this.additionalData, _1.NodeExecuteFunctions, this.mode); | ||
if (nodeSuccessData === null) { | ||
@@ -399,4 +401,4 @@ continue executionLoop; | ||
} | ||
if (!runExecutionData.resultData.runData.hasOwnProperty(executionNode.name)) { | ||
runExecutionData.resultData.runData[executionNode.name] = []; | ||
if (!this.runExecutionData.resultData.runData.hasOwnProperty(executionNode.name)) { | ||
this.runExecutionData.resultData.runData[executionNode.name] = []; | ||
} | ||
@@ -417,5 +419,5 @@ taskData = { | ||
else { | ||
runExecutionData.resultData.runData[executionNode.name].push(taskData); | ||
runExecutionData.executionData.nodeExecutionStack.unshift(executionData); | ||
this.executeHook('nodeExecuteAfter', [this.executionId, executionNode.name, taskData]); | ||
this.runExecutionData.resultData.runData[executionNode.name].push(taskData); | ||
this.runExecutionData.executionData.nodeExecutionStack.unshift(executionData); | ||
this.executeHook('nodeExecuteAfter', [executionNode.name, taskData]); | ||
break; | ||
@@ -427,5 +429,5 @@ } | ||
}; | ||
this.executeHook('nodeExecuteAfter', [this.executionId, executionNode.name, taskData]); | ||
runExecutionData.resultData.runData[executionNode.name].push(taskData); | ||
if (runExecutionData.startData && runExecutionData.startData.destinationNode && runExecutionData.startData.destinationNode === executionNode.name) { | ||
this.executeHook('nodeExecuteAfter', [executionNode.name, taskData]); | ||
this.runExecutionData.resultData.runData[executionNode.name].push(taskData); | ||
if (this.runExecutionData.startData && this.runExecutionData.startData.destinationNode && this.runExecutionData.startData.destinationNode === executionNode.name) { | ||
continue; | ||
@@ -444,3 +446,3 @@ } | ||
} | ||
this.addNodeToBeExecuted(workflow, runExecutionData, connectionData, parseInt(outputIndex, 10), executionNode.name, nodeSuccessData, runIndex); | ||
this.addNodeToBeExecuted(workflow, connectionData, parseInt(outputIndex, 10), executionNode.name, nodeSuccessData, runIndex); | ||
} | ||
@@ -454,25 +456,6 @@ } | ||
.then(async () => { | ||
const fullRunData = { | ||
data: runExecutionData, | ||
mode: this.mode, | ||
startedAt: new Date(startedAt), | ||
stoppedAt: new Date(), | ||
}; | ||
if (executionError !== undefined) { | ||
fullRunData.data.resultData.error = executionError; | ||
} | ||
else { | ||
fullRunData.finished = true; | ||
} | ||
this.activeExecutions.remove(this.executionId, fullRunData); | ||
await this.executeHook('workflowExecuteAfter', [fullRunData, this.executionId]); | ||
return fullRunData; | ||
return this.processSuccessExecution(startedAt, workflow, executionError); | ||
}) | ||
.catch(async (error) => { | ||
const fullRunData = { | ||
data: runExecutionData, | ||
mode: this.mode, | ||
startedAt: new Date(startedAt), | ||
stoppedAt: new Date(), | ||
}; | ||
const fullRunData = this.getFullRunData(startedAt); | ||
fullRunData.data.resultData.error = { | ||
@@ -482,10 +465,36 @@ message: error.message, | ||
}; | ||
this.activeExecutions.remove(this.executionId, fullRunData); | ||
await this.executeHook('workflowExecuteAfter', [fullRunData, this.executionId]); | ||
let newStaticData; | ||
if (workflow.staticData.__dataChanged === true) { | ||
newStaticData = workflow.staticData; | ||
} | ||
await this.executeHook('workflowExecuteAfter', [fullRunData, newStaticData]); | ||
return fullRunData; | ||
})); | ||
return this.executionId; | ||
}); | ||
} | ||
async processSuccessExecution(startedAt, workflow, executionError) { | ||
const fullRunData = this.getFullRunData(startedAt); | ||
if (executionError !== undefined) { | ||
fullRunData.data.resultData.error = executionError; | ||
} | ||
else { | ||
fullRunData.finished = true; | ||
} | ||
let newStaticData; | ||
if (workflow.staticData.__dataChanged === true) { | ||
newStaticData = workflow.staticData; | ||
} | ||
await this.executeHook('workflowExecuteAfter', [fullRunData, newStaticData]); | ||
return fullRunData; | ||
} | ||
getFullRunData(startedAt) { | ||
const fullRunData = { | ||
data: this.runExecutionData, | ||
mode: this.mode, | ||
startedAt, | ||
stoppedAt: new Date(), | ||
}; | ||
return fullRunData; | ||
} | ||
} | ||
exports.WorkflowExecute = WorkflowExecute; | ||
//# sourceMappingURL=WorkflowExecute.js.map |
@@ -1,6 +0,6 @@ | ||
import { INodeType, INodeTypes, INodeTypesObject, IRun, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; | ||
import { INodeType, INodeTypes, INodeTypeData, IRun, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; | ||
import { IDeferredPromise } from '../src'; | ||
declare class NodeTypesClass implements INodeTypes { | ||
nodeTypes: INodeTypesObject; | ||
init(nodeTypes: INodeTypesObject): Promise<void>; | ||
nodeTypes: INodeTypeData; | ||
init(nodeTypes: INodeTypeData): Promise<void>; | ||
getAll(): INodeType[]; | ||
@@ -7,0 +7,0 @@ getByName(nodeType: string): INodeType; |
@@ -8,176 +8,190 @@ "use strict"; | ||
'n8n-nodes-base.merge': { | ||
description: { | ||
displayName: 'Merge', | ||
name: 'merge', | ||
icon: 'fa:clone', | ||
group: ['transform'], | ||
version: 1, | ||
description: 'Merges data of multiple streams once data of both is available', | ||
defaults: { | ||
name: 'Merge', | ||
color: '#00cc22', | ||
}, | ||
inputs: ['main', 'main'], | ||
outputs: ['main'], | ||
properties: [ | ||
{ | ||
displayName: 'Mode', | ||
name: 'mode', | ||
type: 'options', | ||
options: [ | ||
{ | ||
name: 'Append', | ||
value: 'append', | ||
description: 'Combines data of both inputs. The output will contain items of input 1 and input 2.', | ||
}, | ||
{ | ||
name: 'Pass-through', | ||
value: 'passThrough', | ||
description: 'Passes through data of one input. The output will conain only items of the defined input.', | ||
}, | ||
{ | ||
name: 'Wait', | ||
value: 'wait', | ||
description: 'Waits till data of both inputs is available and will then output a single empty item.', | ||
}, | ||
], | ||
default: 'append', | ||
description: 'How data should be merged. If it should simply<br />be appended or merged depending on a property.', | ||
sourcePath: '', | ||
type: { | ||
description: { | ||
displayName: 'Merge', | ||
name: 'merge', | ||
icon: 'fa:clone', | ||
group: ['transform'], | ||
version: 1, | ||
description: 'Merges data of multiple streams once data of both is available', | ||
defaults: { | ||
name: 'Merge', | ||
color: '#00cc22', | ||
}, | ||
{ | ||
displayName: 'Output Data', | ||
name: 'output', | ||
type: 'options', | ||
displayOptions: { | ||
show: { | ||
mode: [ | ||
'passThrough' | ||
], | ||
inputs: ['main', 'main'], | ||
outputs: ['main'], | ||
properties: [ | ||
{ | ||
displayName: 'Mode', | ||
name: 'mode', | ||
type: 'options', | ||
options: [ | ||
{ | ||
name: 'Append', | ||
value: 'append', | ||
description: 'Combines data of both inputs. The output will contain items of input 1 and input 2.', | ||
}, | ||
{ | ||
name: 'Pass-through', | ||
value: 'passThrough', | ||
description: 'Passes through data of one input. The output will conain only items of the defined input.', | ||
}, | ||
{ | ||
name: 'Wait', | ||
value: 'wait', | ||
description: 'Waits till data of both inputs is available and will then output a single empty item.', | ||
}, | ||
], | ||
default: 'append', | ||
description: 'How data should be merged. If it should simply<br />be appended or merged depending on a property.', | ||
}, | ||
{ | ||
displayName: 'Output Data', | ||
name: 'output', | ||
type: 'options', | ||
displayOptions: { | ||
show: { | ||
mode: [ | ||
'passThrough' | ||
], | ||
}, | ||
}, | ||
options: [ | ||
{ | ||
name: 'Input 1', | ||
value: 'input1', | ||
}, | ||
{ | ||
name: 'Input 2', | ||
value: 'input2', | ||
}, | ||
], | ||
default: 'input1', | ||
description: 'Defines of which input the data should be used as output of node.', | ||
}, | ||
options: [ | ||
{ | ||
name: 'Input 1', | ||
value: 'input1', | ||
}, | ||
{ | ||
name: 'Input 2', | ||
value: 'input2', | ||
}, | ||
], | ||
default: 'input1', | ||
description: 'Defines of which input the data should be used as output of node.', | ||
}, | ||
] | ||
}, | ||
async execute() { | ||
const returnData = []; | ||
const mode = this.getNodeParameter('mode', 0); | ||
if (mode === 'append') { | ||
for (let i = 0; i < 2; i++) { | ||
returnData.push.apply(returnData, this.getInputData(i)); | ||
] | ||
}, | ||
async execute() { | ||
const returnData = []; | ||
const mode = this.getNodeParameter('mode', 0); | ||
if (mode === 'append') { | ||
for (let i = 0; i < 2; i++) { | ||
returnData.push.apply(returnData, this.getInputData(i)); | ||
} | ||
} | ||
} | ||
else if (mode === 'passThrough') { | ||
const output = this.getNodeParameter('output', 0); | ||
if (output === 'input1') { | ||
returnData.push.apply(returnData, this.getInputData(0)); | ||
else if (mode === 'passThrough') { | ||
const output = this.getNodeParameter('output', 0); | ||
if (output === 'input1') { | ||
returnData.push.apply(returnData, this.getInputData(0)); | ||
} | ||
else { | ||
returnData.push.apply(returnData, this.getInputData(1)); | ||
} | ||
} | ||
else { | ||
returnData.push.apply(returnData, this.getInputData(1)); | ||
else if (mode === 'wait') { | ||
returnData.push({ json: {} }); | ||
} | ||
return [returnData]; | ||
} | ||
else if (mode === 'wait') { | ||
returnData.push({ json: {} }); | ||
} | ||
return [returnData]; | ||
} | ||
}, | ||
}, | ||
'n8n-nodes-base.set': { | ||
description: { | ||
displayName: 'Set', | ||
name: 'set', | ||
group: ['input'], | ||
version: 1, | ||
description: 'Sets a value', | ||
defaults: { | ||
name: 'Set', | ||
color: '#0000FF', | ||
}, | ||
inputs: ['main'], | ||
outputs: ['main'], | ||
properties: [ | ||
{ | ||
displayName: 'Keep Only Set', | ||
name: 'keepOnlySet', | ||
type: 'boolean', | ||
default: false, | ||
description: 'If only the values set on this node should be<br />kept and all others removed.', | ||
sourcePath: '', | ||
type: { | ||
description: { | ||
displayName: 'Set', | ||
name: 'set', | ||
group: ['input'], | ||
version: 1, | ||
description: 'Sets a value', | ||
defaults: { | ||
name: 'Set', | ||
color: '#0000FF', | ||
}, | ||
{ | ||
displayName: 'Values to Set', | ||
name: 'values', | ||
placeholder: 'Add Value', | ||
type: 'fixedCollection', | ||
typeOptions: { | ||
multipleValues: true, | ||
inputs: ['main'], | ||
outputs: ['main'], | ||
properties: [ | ||
{ | ||
displayName: 'Keep Only Set', | ||
name: 'keepOnlySet', | ||
type: 'boolean', | ||
default: false, | ||
description: 'If only the values set on this node should be<br />kept and all others removed.', | ||
}, | ||
description: 'The value to set.', | ||
default: {}, | ||
options: [ | ||
{ | ||
name: 'number', | ||
displayName: 'Number', | ||
values: [ | ||
{ | ||
displayName: 'Name', | ||
name: 'name', | ||
type: 'string', | ||
default: 'propertyName', | ||
description: 'Name of the property to write data to.<br />Supports dot-notation.<br />Example: "data.person[0].name"', | ||
}, | ||
{ | ||
displayName: 'Value', | ||
name: 'value', | ||
type: 'number', | ||
default: 0, | ||
description: 'The number value to write in the property.', | ||
}, | ||
] | ||
{ | ||
displayName: 'Values to Set', | ||
name: 'values', | ||
placeholder: 'Add Value', | ||
type: 'fixedCollection', | ||
typeOptions: { | ||
multipleValues: true, | ||
}, | ||
], | ||
}, | ||
] | ||
description: 'The value to set.', | ||
default: {}, | ||
options: [ | ||
{ | ||
name: 'number', | ||
displayName: 'Number', | ||
values: [ | ||
{ | ||
displayName: 'Name', | ||
name: 'name', | ||
type: 'string', | ||
default: 'propertyName', | ||
description: 'Name of the property to write data to.<br />Supports dot-notation.<br />Example: "data.person[0].name"', | ||
}, | ||
{ | ||
displayName: 'Value', | ||
name: 'value', | ||
type: 'number', | ||
default: 0, | ||
description: 'The number value to write in the property.', | ||
}, | ||
] | ||
}, | ||
], | ||
}, | ||
] | ||
}, | ||
execute() { | ||
const items = this.getInputData(); | ||
const returnData = []; | ||
let item; | ||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { | ||
item = items[itemIndex]; | ||
const newItem = { | ||
json: JSON.parse(JSON.stringify(item.json)), | ||
}; | ||
this.getNodeParameter('values.number', itemIndex, []).forEach((setItem) => { | ||
lodash_1.set(newItem.json, setItem.name, setItem.value); | ||
}); | ||
returnData.push(newItem); | ||
} | ||
return this.prepareOutputData(returnData); | ||
} | ||
}, | ||
execute() { | ||
const items = this.getInputData(); | ||
let item; | ||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { | ||
item = items[itemIndex]; | ||
this.getNodeParameter('values.number', itemIndex, []).forEach((setItem) => { | ||
lodash_1.set(item.json, setItem.name, setItem.value); | ||
}); | ||
} | ||
return this.prepareOutputData(items); | ||
} | ||
}, | ||
'n8n-nodes-base.start': { | ||
description: { | ||
displayName: 'Start', | ||
name: 'start', | ||
group: ['input'], | ||
version: 1, | ||
description: 'Starts the workflow execution from this node', | ||
defaults: { | ||
name: 'Start', | ||
color: '#553399', | ||
sourcePath: '', | ||
type: { | ||
description: { | ||
displayName: 'Start', | ||
name: 'start', | ||
group: ['input'], | ||
version: 1, | ||
description: 'Starts the workflow execution from this node', | ||
defaults: { | ||
name: 'Start', | ||
color: '#553399', | ||
}, | ||
inputs: [], | ||
outputs: ['main'], | ||
properties: [] | ||
}, | ||
inputs: [], | ||
outputs: ['main'], | ||
properties: [] | ||
execute() { | ||
const items = this.getInputData(); | ||
return this.prepareOutputData(items); | ||
}, | ||
}, | ||
execute() { | ||
const items = this.getInputData(); | ||
return this.prepareOutputData(items); | ||
}, | ||
}, | ||
@@ -188,6 +202,6 @@ }; | ||
getAll() { | ||
return Object.values(this.nodeTypes); | ||
return Object.values(this.nodeTypes).map((data) => data.type); | ||
} | ||
getByName(nodeType) { | ||
return this.nodeTypes[nodeType]; | ||
return this.nodeTypes[nodeType].type; | ||
} | ||
@@ -209,3 +223,3 @@ } | ||
nodeExecuteAfter: [ | ||
async (executionId, nodeName, data) => { | ||
async (nodeName, data) => { | ||
nodeExecutionOrder.push(nodeName); | ||
@@ -215,3 +229,3 @@ }, | ||
workflowExecuteAfter: [ | ||
async (fullRunData, executionId) => { | ||
async (fullRunData) => { | ||
waitPromise.resolve(fullRunData); | ||
@@ -218,0 +232,0 @@ }, |
@@ -550,5 +550,5 @@ "use strict"; | ||
const workflowExecute = new src_1.WorkflowExecute(additionalData, executionMode); | ||
const executionId = await workflowExecute.run(workflowInstance, undefined); | ||
expect(executionId).toBeDefined(); | ||
const executionData = await workflowExecute.run(workflowInstance, undefined); | ||
const result = await waitPromise.promise(); | ||
expect(executionData).toEqual(result); | ||
for (const nodeName of Object.keys(testData.output.nodeData)) { | ||
@@ -555,0 +555,0 @@ if (result.data.resultData.runData[nodeName] === undefined) { |
{ | ||
"name": "n8n-core", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Core functionality of n8n", | ||
@@ -43,3 +43,3 @@ "license": "SEE LICENSE IN LICENSE.md", | ||
"mmmagic": "^0.5.2", | ||
"n8n-workflow": "^0.8.0", | ||
"n8n-workflow": "^0.9.0", | ||
"request-promise-native": "^1.0.7" | ||
@@ -46,0 +46,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
177217
45
2326
+ Addedn8n-workflow@0.9.0(transitive)
- Removedn8n-workflow@0.8.0(transitive)
Updatedn8n-workflow@^0.9.0