Skip to content

Commit

Permalink
fix(core): Fix resolve RL values in expressions (#4173)
Browse files Browse the repository at this point in the history
* update interface

* update expression resolving

* 🔥 remove ExtractValue functions

* add flags

* update resolving

* update expr

* fix for list mode

* clean up

* Fix up

* update guard

* fix bug with switching

* update to handle expr referencing

* fix legacy expression

* fix when switching

* update spacing

Co-authored-by: Valya Bullions <valya@n8n.io>
  • Loading branch information
mutdmour and valya authored Sep 22, 2022
1 parent d01f7d4 commit 469c391
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 361 deletions.
183 changes: 0 additions & 183 deletions packages/core/src/ExtractValue.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import {
LoggerProxy as Logger,
IExecuteData,
OAuth2GrantType,
IGetNodeParameterOptions,
NodeParameterValueType,
NodeExecutionWithMetadata,
IPairedItemData,
Expand Down Expand Up @@ -100,7 +99,6 @@ import {
IWorkflowSettings,
PLACEHOLDER_EMPTY_EXECUTION_ID,
} from '.';
import { extractValue } from './ExtractValue';

axios.defaults.timeout = 300000;
// Prevent axios from adding x-form-www-urlencoded headers by default
Expand Down Expand Up @@ -1727,7 +1725,6 @@ export function getNodeParameter(
additionalKeys: IWorkflowDataProxyAdditionalKeys,
executeData?: IExecuteData,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object {
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
if (nodeType === undefined) {
Expand Down Expand Up @@ -1762,11 +1759,6 @@ export function getNodeParameter(
throw e;
}

// This is outside the try/catch because it throws errors with proper messages
if (options?.extractValue) {
returnData = extractValue(returnData, parameterName, node, nodeType);
}

return returnData;
}

Expand Down Expand Up @@ -1939,7 +1931,6 @@ export function getExecutePollFunctions(
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
Expand All @@ -1959,7 +1950,6 @@ export function getExecutePollFunctions(
getAdditionalKeys(additionalData),
undefined,
fallbackValue,
options,
);
},
getRestApiUrl: (): string => {
Expand Down Expand Up @@ -2094,7 +2084,6 @@ export function getExecuteTriggerFunctions(
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
Expand All @@ -2114,7 +2103,6 @@ export function getExecuteTriggerFunctions(
getAdditionalKeys(additionalData),
undefined,
fallbackValue,
options,
);
},
getRestApiUrl: (): string => {
Expand Down Expand Up @@ -2314,7 +2302,6 @@ export function getExecuteFunctions(
parameterName: string,
itemIndex: number,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
return getNodeParameter(
workflow,
Expand All @@ -2329,7 +2316,6 @@ export function getExecuteFunctions(
getAdditionalKeys(additionalData),
executeData,
fallbackValue,
options,
);
},
getMode: (): WorkflowExecuteMode => {
Expand Down Expand Up @@ -2589,7 +2575,6 @@ export function getExecuteSingleFunctions(
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
return getNodeParameter(
workflow,
Expand All @@ -2604,7 +2589,6 @@ export function getExecuteSingleFunctions(
getAdditionalKeys(additionalData),
executeData,
fallbackValue,
options,
);
},
getWorkflow: () => {
Expand Down Expand Up @@ -2758,7 +2742,6 @@ export function getLoadOptionsFunctions(
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
Expand All @@ -2778,7 +2761,6 @@ export function getLoadOptionsFunctions(
getAdditionalKeys(additionalData),
undefined,
fallbackValue,
options,
);
},
getTimezone: (): string => {
Expand Down Expand Up @@ -2886,7 +2868,6 @@ export function getExecuteHookFunctions(
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
Expand All @@ -2906,7 +2887,6 @@ export function getExecuteHookFunctions(
getAdditionalKeys(additionalData),
undefined,
fallbackValue,
options,
);
},
getNodeWebhookUrl: (name: string): string | undefined => {
Expand Down Expand Up @@ -3046,7 +3026,6 @@ export function getExecuteWebhookFunctions(
getNodeParameter: (
parameterName: string,
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
Expand All @@ -3066,7 +3045,6 @@ export function getExecuteWebhookFunctions(
getAdditionalKeys(additionalData),
undefined,
fallbackValue,
options,
);
},
getParamsData(): object {
Expand Down
11 changes: 6 additions & 5 deletions packages/editor-ui/src/components/ParameterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div @keydown.stop :class="parameterInputClasses">
<expression-edit
:dialogVisible="expressionEditDialogVisible"
:value="isResourceLocatorParameter ? (value ? value.value : '') : value"
:value="isResourceLocatorParameter && typeof value !== 'string' ? (value ? value.value : '') : value"
:parameter="parameter"
:path="path"
:eventSource="eventSource || 'ndv'"
Expand Down Expand Up @@ -295,6 +295,7 @@ import {
INodeParameters,
INodePropertyOptions,
Workflow,
NodeParameterValueType,
} from 'n8n-workflow';
import CodeEdit from '@/components/CodeEdit.vue';
Expand Down Expand Up @@ -819,7 +820,7 @@ export default mixins(
return this.parameter.typeOptions[argumentName];
},
expressionUpdated (value: string) {
const val = this.isResourceLocatorParameter ? { value, mode: this.value.mode } : value;
const val: NodeParameterValueType = this.isResourceLocatorParameter ? { __rl: true, value, mode: this.value.mode } : value;
this.valueChanged(val);
},
openExpressionEdit() {
Expand Down Expand Up @@ -937,9 +938,9 @@ export default mixins(
} else if (command === 'addExpression') {
if (this.isResourceLocatorParameter) {
if (isResourceLocatorValue(this.value)) {
this.valueChanged({ value: `=${this.value.value}`, mode: this.value.mode });
this.valueChanged({ __rl: true, value: `=${this.value.value}`, mode: this.value.mode });
} else {
this.valueChanged({ value: `=${this.value}`, mode: '' });
this.valueChanged({ __rl: true, value: `=${this.value}`, mode: '' });
}
}
else if (this.parameter.type === 'number' || this.parameter.type === 'boolean') {
Expand All @@ -962,7 +963,7 @@ export default mixins(
}
if (this.isResourceLocatorParameter) {
this.valueChanged({ value, mode: this.value.mode });
this.valueChanged({ __rl: true, value, mode: this.value.mode });
} else {
this.valueChanged(typeof value !== 'undefined' ? value : null);
}
Expand Down
Loading

0 comments on commit 469c391

Please sign in to comment.