n8n-workflow
Advanced tools
Comparing version 0.22.0 to 0.23.0
@@ -110,2 +110,3 @@ import { Workflow } from './Workflow'; | ||
getMode(): WorkflowExecuteMode; | ||
getNode(): INode; | ||
getNodeParameter(parameterName: string, itemIndex: number, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
@@ -116,2 +117,3 @@ getWorkflowDataProxy(itemIndex: number): IWorkflowDataProxyData; | ||
getTimezone(): string; | ||
getWorkflow(workflow: Workflow): IWorkflowMetadata; | ||
prepareOutputData(outputData: INodeExecutionData[], outputIndex?: number): Promise<INodeExecutionData[][]>; | ||
@@ -127,5 +129,7 @@ helpers: { | ||
getMode(): WorkflowExecuteMode; | ||
getNode(): INode; | ||
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
getRestApiUrl(): string; | ||
getTimezone(): string; | ||
getWorkflow(workflow: Workflow): IWorkflowMetadata; | ||
getWorkflowDataProxy(): IWorkflowDataProxyData; | ||
@@ -143,2 +147,3 @@ getWorkflowStaticData(type: string): IDataObject; | ||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined; | ||
getNode(): INode; | ||
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
@@ -156,2 +161,3 @@ getCurrentNodeParameter(parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined; | ||
getMode(): WorkflowExecuteMode; | ||
getNode(): INode; | ||
getNodeWebhookUrl: (name: string) => string | undefined; | ||
@@ -162,2 +168,3 @@ getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
getWebhookName(): string; | ||
getWorkflow(workflow: Workflow): IWorkflowMetadata; | ||
getWorkflowStaticData(type: string): IDataObject; | ||
@@ -172,5 +179,7 @@ helpers: { | ||
getMode(): WorkflowExecuteMode; | ||
getNode(): INode; | ||
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
getRestApiUrl(): string; | ||
getTimezone(): string; | ||
getWorkflow(workflow: Workflow): IWorkflowMetadata; | ||
getWorkflowStaticData(type: string): IDataObject; | ||
@@ -185,5 +194,7 @@ helpers: { | ||
getMode(): WorkflowExecuteMode; | ||
getNode(): INode; | ||
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
getRestApiUrl(): string; | ||
getTimezone(): string; | ||
getWorkflow(workflow: Workflow): IWorkflowMetadata; | ||
getWorkflowStaticData(type: string): IDataObject; | ||
@@ -199,2 +210,3 @@ helpers: { | ||
getMode(): WorkflowExecuteMode; | ||
getNode(): INode; | ||
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; | ||
@@ -208,2 +220,3 @@ getNodeWebhookUrl: (name: string) => string | undefined; | ||
getWorkflowStaticData(type: string): IDataObject; | ||
getWorkflow(workflow: Workflow): IWorkflowMetadata; | ||
prepareOutputData(outputData: INodeExecutionData[], outputIndex?: number): Promise<INodeExecutionData[][]>; | ||
@@ -420,2 +433,7 @@ helpers: { | ||
} | ||
export interface IWorkflowMetadata { | ||
id?: number | string; | ||
name?: string; | ||
active: boolean; | ||
} | ||
export declare type WebhookHttpMethod = 'GET' | 'POST'; | ||
@@ -422,0 +440,0 @@ export interface IWebhookResponseData { |
@@ -5,2 +5,3 @@ import { IConnections, IGetExecuteTriggerFunctions, INode, INodes, INodeExecuteFunctions, INodeExecutionData, INodeParameters, INodeType, INodeTypes, IPollFunctions, IRunExecutionData, ITaskDataConnections, ITriggerResponse, IWebhookData, IWebhookResponseData, IWorfklowIssues, IWorkflowExecuteAdditionalData, IWorkflowSettings, NodeParameterValue, WebhookSetupMethodNames, WorkflowExecuteMode } from './'; | ||
id: string | undefined; | ||
name: string | undefined; | ||
nodes: INodes; | ||
@@ -13,3 +14,12 @@ connectionsBySourceNode: IConnections; | ||
staticData: IDataObject; | ||
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; | ||
}); | ||
__getConnectionsByDestination(connections: IConnections): IConnections; | ||
@@ -16,0 +26,0 @@ convertObjectValueToString(value: object): string; |
@@ -8,8 +8,9 @@ "use strict"; | ||
class Workflow { | ||
constructor(id, nodes, connections, active, nodeTypes, staticData, settings) { | ||
constructor(parameters) { | ||
this.nodes = {}; | ||
this.id = id; | ||
this.nodeTypes = nodeTypes; | ||
this.id = parameters.id; | ||
this.name = parameters.name; | ||
this.nodeTypes = parameters.nodeTypes; | ||
let nodeType; | ||
for (const node of nodes) { | ||
for (const node of parameters.nodes) { | ||
this.nodes[node.name] = node; | ||
@@ -23,7 +24,7 @@ nodeType = this.nodeTypes.getByName(node.type); | ||
} | ||
this.connectionsBySourceNode = connections; | ||
this.connectionsByDestinationNode = this.__getConnectionsByDestination(connections); | ||
this.active = active || false; | ||
this.staticData = _1.ObservableObject.create(staticData || {}, undefined, { ignoreEmptyOnFirstChild: true }); | ||
this.settings = settings || {}; | ||
this.connectionsBySourceNode = parameters.connections; | ||
this.connectionsByDestinationNode = this.__getConnectionsByDestination(parameters.connections); | ||
this.active = parameters.active || false; | ||
this.staticData = _1.ObservableObject.create(parameters.staticData || {}, undefined, { ignoreEmptyOnFirstChild: true }); | ||
this.settings = parameters.settings || {}; | ||
} | ||
@@ -30,0 +31,0 @@ __getConnectionsByDestination(connections) { |
@@ -14,4 +14,5 @@ import { INodeExecutionData, IRunExecutionData, IWorkflowDataProxyData, Workflow } from './'; | ||
private envGetter; | ||
private workflowGetter; | ||
private nodeGetter; | ||
getDataProxy(): IWorkflowDataProxyData; | ||
} |
@@ -62,3 +62,3 @@ "use strict"; | ||
name = name.toString(); | ||
if (['binary', 'data'].includes(name)) { | ||
if (['binary', 'data', 'json'].includes(name)) { | ||
let executionData; | ||
@@ -94,3 +94,3 @@ if (shortSyntax === false) { | ||
} | ||
if (name === 'data') { | ||
if (['data', 'json'].includes(name)) { | ||
return executionData[that.itemIndex].json; | ||
@@ -134,2 +134,18 @@ } | ||
} | ||
workflowGetter() { | ||
const allowedValues = [ | ||
'active', | ||
'id', | ||
'name', | ||
]; | ||
const that = this; | ||
return new Proxy({}, { | ||
get(target, name, receiver) { | ||
if (!allowedValues.includes(name.toString())) { | ||
throw new Error(`The key "${name.toString()}" is not supported!`); | ||
} | ||
return that.workflow[name.toString()]; | ||
} | ||
}); | ||
} | ||
nodeGetter() { | ||
@@ -153,9 +169,11 @@ const that = this; | ||
}, | ||
$json: {}, | ||
$node: this.nodeGetter(), | ||
$parameter: this.nodeParameterGetter(this.activeNodeName), | ||
$workflow: this.workflowGetter(), | ||
}; | ||
return new Proxy(base, { | ||
get(target, name, receiver) { | ||
if (name === '$data') { | ||
return that.nodeDataGetter(that.activeNodeName, true).data; | ||
if (['$data', '$json'].includes(name)) { | ||
return that.nodeDataGetter(that.activeNodeName, true).json; | ||
} | ||
@@ -162,0 +180,0 @@ else if (name === '$binary') { |
@@ -124,3 +124,3 @@ "use strict"; | ||
const nodeTypes = Helpers.NodeTypes(); | ||
const workflow = new src_1.Workflow(undefined, [], {}, false, nodeTypes); | ||
const workflow = new src_1.Workflow({ nodes: [], connections: {}, active: false, nodeTypes }); | ||
for (const testData of tests) { | ||
@@ -537,3 +537,3 @@ test(testData.description, () => { | ||
} | ||
workflow = new src_1.Workflow(undefined, executeNodes, testData.input.connections, false, nodeTypes); | ||
workflow = new src_1.Workflow({ nodes: executeNodes, connections: testData.input.connections, active: false, nodeTypes }); | ||
workflow.renameNode(testData.input.currentName, testData.input.newName); | ||
@@ -968,3 +968,3 @@ resultNodes = {}; | ||
}; | ||
const workflow = new src_1.Workflow(undefined, nodes, connections, false, nodeTypes); | ||
const workflow = new src_1.Workflow({ nodes, connections, active: false, nodeTypes }); | ||
const activeNodeName = testData.input.hasOwnProperty('Node3') ? 'Node3' : 'Node2'; | ||
@@ -1031,3 +1031,3 @@ const runExecutionData = { | ||
const connections = {}; | ||
const workflow = new src_1.Workflow(undefined, nodes, connections, false, nodeTypes); | ||
const workflow = new src_1.Workflow({ nodes, connections, active: false, nodeTypes }); | ||
const activeNodeName = 'Node1'; | ||
@@ -1034,0 +1034,0 @@ const runExecutionData = { |
{ | ||
"name": "n8n-workflow", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"description": "Workflow base code of n8n", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE.md", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
400796
6404