Small fixes and fix that some nodes changed incoming data

This commit is contained in:
Jan Oberhauser 2019-08-01 18:22:48 +02:00
parent fc4952f022
commit 1d42a16d25
8 changed files with 29 additions and 28 deletions

View file

@ -1,4 +1,4 @@
## n8n - Workflow Automation # n8n - Workflow Automation
![n8n.io - Workflow Automation](https://raw.githubusercontent.com/n8n-io/n8n/master/docs/images/n8n-logo.png) ![n8n.io - Workflow Automation](https://raw.githubusercontent.com/n8n-io/n8n/master/docs/images/n8n-logo.png)

View file

@ -254,7 +254,7 @@ export function getNodeWebhookUrl(name: string, workflow: Workflow, node: INode,
return undefined; return undefined;
} }
return NodeHelpers.getNodeWebhookUrl(baseUrl, workflow.id!, node, path); return NodeHelpers.getNodeWebhookUrl(baseUrl, workflow.id!, node, path.toString());
} }

View file

@ -92,10 +92,8 @@ export class ExecuteCommand implements INodeType {
items = [items[0]]; items = [items[0]];
} }
let item: INodeExecutionData; const returnItems: INodeExecutionData[] = [];
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
item = items[itemIndex];
command = this.getNodeParameter('command', itemIndex) as string; command = this.getNodeParameter('command', itemIndex) as string;
const { const {
@ -105,13 +103,17 @@ export class ExecuteCommand implements INodeType {
stderr, stderr,
} = await execPromise(command); } = await execPromise(command);
item.json = { returnItems.push(
exitCode, {
stderr, json: {
stdout, exitCode,
}; stderr,
stdout,
},
},
);
} }
return this.prepareOutputData(items); return this.prepareOutputData(returnItems);
} }
} }

View file

@ -129,10 +129,10 @@ export class HttpRequest implements INodeType {
name: 'String', name: 'String',
value: 'string' value: 'string'
}, },
{ // {
name: 'XML (not implemented)', // name: 'XML (not implemented)',
value: 'xml' // value: 'xml'
}, // },
], ],
default: 'json', default: 'json',
description: 'The format in which the data gets returned from the URL.', description: 'The format in which the data gets returned from the URL.',
@ -325,10 +325,6 @@ export class HttpRequest implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> { async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData(); const items = this.getInputData();
if (items.length === 0) {
items.push({json: {}});
}
// TODO: Should have a setting which makes clear that this parameter can not change for each item // TODO: Should have a setting which makes clear that this parameter can not change for each item
const requestMethod = this.getNodeParameter('requestMethod', 0) as string; const requestMethod = this.getNodeParameter('requestMethod', 0) as string;
const parametersAreJson = this.getNodeParameter('jsonParameters', 0) as boolean; const parametersAreJson = this.getNodeParameter('jsonParameters', 0) as boolean;
@ -362,6 +358,7 @@ export class HttpRequest implements INodeType {
}, },
}; };
const returnItems: INodeExecutionData[] = [];
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
item = items[itemIndex]; item = items[itemIndex];
@ -431,14 +428,14 @@ export class HttpRequest implements INodeType {
const response = await this.helpers.request(requestOptions); const response = await this.helpers.request(requestOptions);
if (responseFormat === 'json') { if (responseFormat === 'json') {
item.json = response; returnItems.push({ json: response });
} else if (responseFormat === 'xml') { // } else if (responseFormat === 'xml') {
// TODO: Not implemented yet // // TODO: Not implemented yet
} else { } else {
item.json.reponse = response; returnItems.push({ json: { response } });
} }
} }
return this.prepareOutputData(items); return this.prepareOutputData(returnItems);
} }
} }

View file

@ -14,6 +14,7 @@ export class Merge implements INodeType {
icon: 'fa:code-branch', icon: 'fa:code-branch',
group: ['transform'], group: ['transform'],
version: 1, version: 1,
subtitle: '={{$parameter["mode"]}}',
description: 'Merges data of multiple streams once data of both is available', description: 'Merges data of multiple streams once data of both is available',
defaults: { defaults: {
name: 'Merge', name: 'Merge',

View file

@ -515,6 +515,8 @@ export function getNodeWebhooks(workflow: Workflow, node: INode, additionalData:
continue; continue;
} }
nodeWebhookPath = nodeWebhookPath.toString();
if (nodeWebhookPath.charAt(0) === '/') { if (nodeWebhookPath.charAt(0) === '/') {
nodeWebhookPath = nodeWebhookPath.slice(1); nodeWebhookPath = nodeWebhookPath.slice(1);
} }
@ -530,7 +532,7 @@ export function getNodeWebhooks(workflow: Workflow, node: INode, additionalData:
} }
returnData.push({ returnData.push({
httpMethod: httpMethod as WebhookHttpMethod, httpMethod: httpMethod.toString() as WebhookHttpMethod,
node: node.name, node: node.name,
path, path,
webhookDescription, webhookDescription,

View file

@ -688,7 +688,7 @@ export class Workflow {
* @returns {(string | undefined)} * @returns {(string | undefined)}
* @memberof Workflow * @memberof Workflow
*/ */
getSimpleParameterValue(node: INode, parameterValue: string | undefined, defaultValue?: string): string | undefined { getSimpleParameterValue(node: INode, parameterValue: string | undefined, defaultValue?: boolean | number | string): boolean | number | string | undefined {
if (parameterValue === undefined) { if (parameterValue === undefined) {
// Value is not set so return the default // Value is not set so return the default
return defaultValue; return defaultValue;
@ -704,7 +704,7 @@ export class Workflow {
} }
}; };
return this.getParameterValue(parameterValue, runData, runIndex, itemIndex, node.name, connectionInputData) as string | undefined; return this.getParameterValue(parameterValue, runData, runIndex, itemIndex, node.name, connectionInputData) as boolean | number | string | undefined;
} }

View file

@ -102,7 +102,6 @@ let nodeTypesInstance: NodeTypesClass | undefined;
export function NodeTypes(): NodeTypesClass { export function NodeTypes(): NodeTypesClass {
if (nodeTypesInstance === undefined) { if (nodeTypesInstance === undefined) {
nodeTypesInstance = new NodeTypesClass(); nodeTypesInstance = new NodeTypesClass();
nodeTypesInstance.init({});
} }
return nodeTypesInstance; return nodeTypesInstance;