mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Make workflow metadata available in expresions and
node-functions
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
||||
IWebhookFunctions,
|
||||
IWorkflowDataProxyData,
|
||||
IWorkflowExecuteAdditionalData,
|
||||
IWorkflowMetadata,
|
||||
NodeHelpers,
|
||||
NodeParameterValue,
|
||||
Workflow,
|
||||
@@ -196,6 +197,19 @@ export function getCredentials(workflow: Workflow, node: INode, type: string, ad
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a copy of the node
|
||||
*
|
||||
* @export
|
||||
* @param {INode} node
|
||||
* @returns {INode}
|
||||
*/
|
||||
export function getNode(node: INode): INode {
|
||||
return JSON.parse(JSON.stringify(node));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the requested resolved (all expressions replaced) node parameters.
|
||||
*
|
||||
@@ -312,6 +326,23 @@ export function getWebhookDescription(name: string, workflow: Workflow, node: IN
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the workflow metadata
|
||||
*
|
||||
* @export
|
||||
* @param {Workflow} workflow
|
||||
* @returns {IWorkflowMetadata}
|
||||
*/
|
||||
export function getWorkflowMetadata(workflow: Workflow): IWorkflowMetadata {
|
||||
return {
|
||||
id: workflow.id,
|
||||
name: workflow.name,
|
||||
active: workflow.active,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the execute functions the poll nodes have access to.
|
||||
*
|
||||
@@ -335,6 +366,9 @@ export function getExecutePollFunctions(workflow: Workflow, node: INode, additio
|
||||
getMode: (): WorkflowExecuteMode => {
|
||||
return mode;
|
||||
},
|
||||
getNode: () => {
|
||||
return getNode(node);
|
||||
},
|
||||
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
|
||||
const runExecutionData: IRunExecutionData | null = null;
|
||||
const itemIndex = 0;
|
||||
@@ -349,6 +383,9 @@ export function getExecutePollFunctions(workflow: Workflow, node: INode, additio
|
||||
getTimezone: (): string => {
|
||||
return getTimezone(workflow, additionalData);
|
||||
},
|
||||
getWorkflow: () => {
|
||||
return getWorkflowMetadata(workflow);
|
||||
},
|
||||
getWorkflowStaticData(type: string): IDataObject {
|
||||
return workflow.getStaticData(type, node);
|
||||
},
|
||||
@@ -383,6 +420,9 @@ export function getExecuteTriggerFunctions(workflow: Workflow, node: INode, addi
|
||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
|
||||
return getCredentials(workflow, node, type, additionalData);
|
||||
},
|
||||
getNode: () => {
|
||||
return getNode(node);
|
||||
},
|
||||
getMode: (): WorkflowExecuteMode => {
|
||||
return mode;
|
||||
},
|
||||
@@ -400,6 +440,9 @@ export function getExecuteTriggerFunctions(workflow: Workflow, node: INode, addi
|
||||
getTimezone: (): string => {
|
||||
return getTimezone(workflow, additionalData);
|
||||
},
|
||||
getWorkflow: () => {
|
||||
return getWorkflowMetadata(workflow);
|
||||
},
|
||||
getWorkflowStaticData(type: string): IDataObject {
|
||||
return workflow.getStaticData(type, node);
|
||||
},
|
||||
@@ -467,12 +510,18 @@ export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunEx
|
||||
getMode: (): WorkflowExecuteMode => {
|
||||
return mode;
|
||||
},
|
||||
getNode: () => {
|
||||
return getNode(node);
|
||||
},
|
||||
getRestApiUrl: (): string => {
|
||||
return additionalData.restApiUrl;
|
||||
},
|
||||
getTimezone: (): string => {
|
||||
return getTimezone(workflow, additionalData);
|
||||
},
|
||||
getWorkflow: () => {
|
||||
return getWorkflowMetadata(workflow);
|
||||
},
|
||||
getWorkflowDataProxy: (itemIndex: number): IWorkflowDataProxyData => {
|
||||
const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData);
|
||||
return dataProxy.getDataProxy();
|
||||
@@ -544,6 +593,9 @@ export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData:
|
||||
getMode: (): WorkflowExecuteMode => {
|
||||
return mode;
|
||||
},
|
||||
getNode: () => {
|
||||
return getNode(node);
|
||||
},
|
||||
getRestApiUrl: (): string => {
|
||||
return additionalData.restApiUrl;
|
||||
},
|
||||
@@ -553,6 +605,9 @@ export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData:
|
||||
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
|
||||
return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, fallbackValue);
|
||||
},
|
||||
getWorkflow: () => {
|
||||
return getWorkflowMetadata(workflow);
|
||||
},
|
||||
getWorkflowDataProxy: (): IWorkflowDataProxyData => {
|
||||
const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData);
|
||||
return dataProxy.getDataProxy();
|
||||
@@ -594,6 +649,9 @@ export function getLoadOptionsFunctions(workflow: Workflow, node: INode, additio
|
||||
getCurrentNodeParameters: (): INodeParameters | undefined => {
|
||||
return JSON.parse('' + additionalData.currentNodeParameters);
|
||||
},
|
||||
getNode: () => {
|
||||
return getNode(node);
|
||||
},
|
||||
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
|
||||
const runExecutionData: IRunExecutionData | null = null;
|
||||
const itemIndex = 0;
|
||||
@@ -637,6 +695,9 @@ export function getExecuteHookFunctions(workflow: Workflow, node: INode, additio
|
||||
getMode: (): WorkflowExecuteMode => {
|
||||
return mode;
|
||||
},
|
||||
getNode: () => {
|
||||
return getNode(node);
|
||||
},
|
||||
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
|
||||
const runExecutionData: IRunExecutionData | null = null;
|
||||
const itemIndex = 0;
|
||||
@@ -660,6 +721,9 @@ export function getExecuteHookFunctions(workflow: Workflow, node: INode, additio
|
||||
getWebhookDescription(name: string): IWebhookDescription | undefined {
|
||||
return getWebhookDescription(name, workflow, node);
|
||||
},
|
||||
getWorkflow: () => {
|
||||
return getWorkflowMetadata(workflow);
|
||||
},
|
||||
getWorkflowStaticData(type: string): IDataObject {
|
||||
return workflow.getStaticData(type, node);
|
||||
},
|
||||
@@ -705,6 +769,9 @@ export function getExecuteWebhookFunctions(workflow: Workflow, node: INode, addi
|
||||
getMode: (): WorkflowExecuteMode => {
|
||||
return mode;
|
||||
},
|
||||
getNode: () => {
|
||||
return getNode(node);
|
||||
},
|
||||
getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any
|
||||
const runExecutionData: IRunExecutionData | null = null;
|
||||
const itemIndex = 0;
|
||||
@@ -737,6 +804,9 @@ export function getExecuteWebhookFunctions(workflow: Workflow, node: INode, addi
|
||||
getTimezone: (): string => {
|
||||
return getTimezone(workflow, additionalData);
|
||||
},
|
||||
getWorkflow: () => {
|
||||
return getWorkflowMetadata(workflow);
|
||||
},
|
||||
getWorkflowStaticData(type: string): IDataObject {
|
||||
return workflow.getStaticData(type, node);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user