Skip to content

Commit

Permalink
fix(core): Properly resolve expressions in declarative node design
Browse files Browse the repository at this point in the history
  • Loading branch information
janober committed Jun 8, 2022
1 parent 481ccc7 commit 1999f4b
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/workflow/src/RoutingNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
56 changes: 56 additions & 0 deletions packages/workflow/test/RoutingNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ describe('RoutingNode', () => {
input: {
node: {
parameters: {
value1: '={{"test"}}',
multipleFields: {
value1: 'v1',
value2: 'v2',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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.',
},
],
},
],
},
],
},
],
Expand Down Expand Up @@ -1324,6 +1379,7 @@ describe('RoutingNode', () => {
value: 'cM1Value2',
},
],
testN: 'testV',
},
method: 'POST',
headers: {
Expand Down

0 comments on commit 1999f4b

Please sign in to comment.