Make special variables like $node, $parameter, ... accessible

in Function Nodes
This commit is contained in:
Jan Oberhauser
2019-09-04 14:53:39 +02:00
parent c1e753e9d1
commit 48ccb36536
5 changed files with 37 additions and 6 deletions

View File

@@ -154,6 +154,7 @@ export interface IExecuteFunctions {
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData[];
getMode(): WorkflowExecuteMode;
getNodeParameter(parameterName: string, itemIndex: number, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; //tslint:disable-line:no-any
getWorkflowDataProxy(itemIndex: number): IWorkflowDataProxyData;
getWorkflowStaticData(type: string): IDataObject;
getTimezone(): string;
prepareOutputData(outputData: INodeExecutionData[], outputIndex?: number): Promise<INodeExecutionData[][]>;
@@ -170,6 +171,7 @@ export interface IExecuteSingleFunctions {
getMode(): WorkflowExecuteMode;
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; //tslint:disable-line:no-any
getTimezone(): string;
getWorkflowDataProxy(): IWorkflowDataProxyData;
getWorkflowStaticData(type: string): IDataObject;
helpers: {
[key: string]: (...args: any[]) => any //tslint:disable-line:no-any
@@ -466,6 +468,14 @@ export interface IWebhookDescription {
responseData?: WebhookResponseData | string;
}
export interface IWorkflowDataProxyData {
$binary: any; // tslint:disable-line:no-any
$data: any; // tslint:disable-line:no-any
$env: any; // tslint:disable-line:no-any
$node: any; // tslint:disable-line:no-any
$parameter: any; // tslint:disable-line:no-any
}
export type WebhookHttpMethod = 'GET' | 'POST';
export interface IWebhookResonseData {

View File

@@ -1,8 +1,9 @@
import {
IDataObject,
INodeExecutionData,
NodeHelpers,
IRunExecutionData,
IWorkflowDataProxyData,
NodeHelpers,
Workflow,
} from './';
@@ -184,12 +185,12 @@ export class WorkflowDataProxy {
return executionData[that.itemIndex].json;
} else if (name === 'binary') {
// Binary-Data
if (!executionData[that.itemIndex].binary) {
throw new Error(`No binary data for node "${nodeName}" has been found!`);
}
const returnData: IDataObject = {};
if (!executionData[that.itemIndex].binary) {
return returnData;
}
const binaryKeyData = executionData[that.itemIndex].binary!;
for (const keyName of Object.keys(binaryKeyData)) {
@@ -263,7 +264,7 @@ export class WorkflowDataProxy {
* @returns
* @memberof WorkflowDataGetter
*/
getDataProxy() {
getDataProxy(): IWorkflowDataProxyData {
const that = this;
const base = {