mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
fix(core): Custom workflow tool tweaks (#8561)
This commit is contained in:
parent
e28b374170
commit
ccc0ad5009
|
@ -189,10 +189,9 @@ export class ToolCode implements INodeType {
|
||||||
|
|
||||||
if (typeof response !== 'string') {
|
if (typeof response !== 'string') {
|
||||||
// TODO: Do some more testing. Issues here should actually fail the workflow
|
// TODO: Do some more testing. Issues here should actually fail the workflow
|
||||||
executionError = new NodeOperationError(
|
executionError = new NodeOperationError(this.getNode(), 'Wrong output type returned', {
|
||||||
this.getNode(),
|
description: `The response property should be a string, but it is an ${typeof response}`,
|
||||||
`The code did not return a valid value. Instead of a string did a value of type '${typeof response}' get returned.`,
|
});
|
||||||
);
|
|
||||||
response = `There was an error: "${executionError.message}"`;
|
response = `There was an error: "${executionError.message}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ export class ToolWorkflow implements INodeType {
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName:
|
displayName:
|
||||||
'The workflow will receive "query" as input and the output of the last node will be returned as response',
|
'This tool will call the workflow you define below, and look in the last node for the response. The workflow needs to start with an Execute Workflow trigger',
|
||||||
name: 'executeNotice',
|
name: 'executeNotice',
|
||||||
type: 'notice',
|
type: 'notice',
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -87,9 +87,9 @@ export class ToolWorkflow implements INodeType {
|
||||||
description: 'Load the workflow from the database by ID',
|
description: 'Load the workflow from the database by ID',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Parameter',
|
name: 'Define Below',
|
||||||
value: 'parameter',
|
value: 'parameter',
|
||||||
description: 'Load the workflow from a parameter',
|
description: 'Pass the JSON code of a workflow',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'database',
|
default: 'database',
|
||||||
|
@ -111,6 +111,7 @@ export class ToolWorkflow implements INodeType {
|
||||||
default: '',
|
default: '',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The workflow to execute',
|
description: 'The workflow to execute',
|
||||||
|
hint: 'Can be found in the URL of the workflow',
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -128,27 +129,30 @@ export class ToolWorkflow implements INodeType {
|
||||||
source: ['parameter'],
|
source: ['parameter'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '\n\n\n',
|
default: '\n\n\n\n\n\n\n\n\n',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The workflow JSON code to execute',
|
description: 'The workflow JSON code to execute',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Response Property Name',
|
|
||||||
name: 'responsePropertyName',
|
|
||||||
type: 'string',
|
|
||||||
default: 'response',
|
|
||||||
description: 'The name of the property of the last node that will be returned as response',
|
|
||||||
},
|
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// For all
|
// For all
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Workflow Values',
|
displayName: 'Field to Return',
|
||||||
|
name: 'responsePropertyName',
|
||||||
|
type: 'string',
|
||||||
|
default: 'response',
|
||||||
|
required: true,
|
||||||
|
hint: 'The field in the last-executed node of the workflow that contains the response',
|
||||||
|
description:
|
||||||
|
'Where to find the data that this tool should return. n8n will look in the output of the last-executed node of the workflow for a field with this name, and return its value.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Extra Workflow Inputs',
|
||||||
name: 'fields',
|
name: 'fields',
|
||||||
placeholder: 'Add Value',
|
placeholder: 'Add Value',
|
||||||
type: 'fixedCollection',
|
type: 'fixedCollection',
|
||||||
description: 'Set the values which should be made available in the workflow',
|
description:
|
||||||
|
"These will be output by the 'execute workflow' trigger of the workflow being called",
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
multipleValues: true,
|
multipleValues: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
@ -296,6 +300,14 @@ export class ToolWorkflow implements INodeType {
|
||||||
itemIndex,
|
itemIndex,
|
||||||
) as string;
|
) as string;
|
||||||
|
|
||||||
|
if (!responsePropertyName) {
|
||||||
|
throw new NodeOperationError(this.getNode(), "Field to return can't be empty", {
|
||||||
|
itemIndex,
|
||||||
|
description:
|
||||||
|
'Enter the name of a field in the last node of the workflow that contains the response to return',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const workflowInfo: IExecuteWorkflowInfo = {};
|
const workflowInfo: IExecuteWorkflowInfo = {};
|
||||||
if (source === 'database') {
|
if (source === 'database') {
|
||||||
// Read workflow from database
|
// Read workflow from database
|
||||||
|
@ -399,10 +411,9 @@ export class ToolWorkflow implements INodeType {
|
||||||
|
|
||||||
if (typeof response !== 'string') {
|
if (typeof response !== 'string') {
|
||||||
// TODO: Do some more testing. Issues here should actually fail the workflow
|
// TODO: Do some more testing. Issues here should actually fail the workflow
|
||||||
executionError = new NodeOperationError(
|
executionError = new NodeOperationError(this.getNode(), 'Wrong output type returned', {
|
||||||
this.getNode(),
|
description: `The response property should be a string, but it is an ${typeof response}`,
|
||||||
`The code did not return a valid value. Instead of a string did a value of type '${typeof response}' get returned.`,
|
});
|
||||||
);
|
|
||||||
response = `There was an error: "${executionError.message}"`;
|
response = `There was an error: "${executionError.message}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue