mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Make workflow metadata available in expresions and
node-functions
This commit is contained in:
@@ -41,6 +41,7 @@ tmpl.tmpl.errorHandler = () => { };
|
||||
|
||||
export class Workflow {
|
||||
id: string | undefined;
|
||||
name: string | undefined;
|
||||
nodes: INodes = {};
|
||||
connectionsBySourceNode: IConnections;
|
||||
connectionsByDestinationNode: IConnections;
|
||||
@@ -52,15 +53,17 @@ export class Workflow {
|
||||
// ids of registred webhooks of nodes
|
||||
staticData: IDataObject;
|
||||
|
||||
constructor(id: string | undefined, nodes: INode[], connections: IConnections, active: boolean, nodeTypes: INodeTypes, staticData?: IDataObject, settings?: IWorkflowSettings) {
|
||||
this.id = id;
|
||||
this.nodeTypes = nodeTypes;
|
||||
// constructor(id: string | undefined, nodes: INode[], connections: IConnections, active: boolean, nodeTypes: INodeTypes, staticData?: IDataObject, settings?: IWorkflowSettings) {
|
||||
constructor(parameters: {id?: string, name?: string, nodes: INode[], connections: IConnections, active: boolean, nodeTypes: INodeTypes, staticData?: IDataObject, settings?: IWorkflowSettings}) {
|
||||
this.id = parameters.id;
|
||||
this.name = parameters.name;
|
||||
this.nodeTypes = parameters.nodeTypes;
|
||||
|
||||
// Save nodes in workflow as object to be able to get the
|
||||
// nodes easily by its name.
|
||||
// Also directly add the default values of the node type.
|
||||
let nodeType: INodeType | undefined;
|
||||
for (const node of nodes) {
|
||||
for (const node of parameters.nodes) {
|
||||
this.nodes[node.name] = node;
|
||||
nodeType = this.nodeTypes.getByName(node.type);
|
||||
|
||||
@@ -77,16 +80,16 @@ export class Workflow {
|
||||
const nodeParameters = NodeHelpers.getNodeParameters(nodeType.description.properties, node.parameters, true, false);
|
||||
node.parameters = nodeParameters !== null ? nodeParameters : {};
|
||||
}
|
||||
this.connectionsBySourceNode = connections;
|
||||
this.connectionsBySourceNode = parameters.connections;
|
||||
|
||||
// Save also the connections by the destionation nodes
|
||||
this.connectionsByDestinationNode = this.__getConnectionsByDestination(connections);
|
||||
this.connectionsByDestinationNode = this.__getConnectionsByDestination(parameters.connections);
|
||||
|
||||
this.active = active || false;
|
||||
this.active = parameters.active || false;
|
||||
|
||||
this.staticData = ObservableObject.create(staticData || {}, undefined, { ignoreEmptyOnFirstChild: true });
|
||||
this.staticData = ObservableObject.create(parameters.staticData || {}, undefined, { ignoreEmptyOnFirstChild: true });
|
||||
|
||||
this.settings = settings || {};
|
||||
this.settings = parameters.settings || {};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user