fix(core): Properly resolve expressions in declarative node design

This commit is contained in:
Jan Oberhauser 2022-06-08 18:16:55 +02:00
parent 481ccc7647
commit 1999f4b066
2 changed files with 71 additions and 2 deletions

View file

@ -564,7 +564,10 @@ export class RoutingNode {
additionalKeys?: IWorkflowDataProxyAdditionalKeys,
returnObjectAsString = false,
): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | string {
if (typeof parameterValue === 'string' && parameterValue.charAt(0) === '=') {
if (
typeof parameterValue === 'object' ||
(typeof parameterValue === 'string' && parameterValue.charAt(0) === '=')
) {
return this.workflow.expression.getParameterValue(
parameterValue,
this.runExecutionData ?? null,
@ -820,8 +823,18 @@ export class RoutingNode {
value = [value];
}
// Resolve expressions
value = this.getParameterValue(
value as INodeParameters[],
itemIndex,
runIndex,
executeSingleFunctions.getExecuteData(),
{ ...additionalKeys },
false,
) as INodeParameters[];
const loopBasePath = `${basePath}${propertyOptions.name}`;
for (let i = 0; i < (value as INodeParameters[]).length; i++) {
for (let i = 0; i < value.length; i++) {
for (const option of propertyOptions.values) {
const tempOptions = this.getRequestOptionsFromParameters(
executeSingleFunctions,

View file

@ -961,6 +961,7 @@ describe('RoutingNode', () => {
input: {
node: {
parameters: {
value1: '={{"test"}}',
multipleFields: {
value1: 'v1',
value2: 'v2',
@ -998,11 +999,25 @@ describe('RoutingNode', () => {
},
],
},
customPropertiesMultiExp: {
property0: [
{
name: '={{$parameter["value1"]}}N',
value: '={{$parameter["value1"]}}V',
},
],
},
},
},
},
nodeType: {
properties: [
{
displayName: 'Value 1',
name: 'value1',
type: 'string',
default: '',
},
{
displayName: 'Multiple Fields',
name: 'multipleFields',
@ -1285,6 +1300,46 @@ describe('RoutingNode', () => {
},
],
},
// Test fixed collection: multipleValues=true with expression which references an expression
{
displayName: 'Custom Properties (multi)',
name: 'customPropertiesMultiExp',
placeholder: 'Add Custom Property',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'property0',
displayName: 'Property0',
values: [
// To set: { name0: 'value0', name1: 'value1' }
{
displayName: 'Property Name',
name: 'name',
type: 'string',
default: '',
description: 'Name of the property to set.',
},
{
displayName: 'Property Value',
name: 'value',
type: 'string',
default: '',
routing: {
send: {
property: '={{$parent.name}}',
type: 'body',
},
},
description: 'Value of the property to set.',
},
],
},
],
},
],
},
],
@ -1324,6 +1379,7 @@ describe('RoutingNode', () => {
value: 'cM1Value2',
},
],
testN: 'testV',
},
method: 'POST',
headers: {