Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

n8n-workflow

Package Overview
Dependencies
Maintainers
1
Versions
284
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n8n-workflow - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

11

dist/src/Interfaces.d.ts

@@ -125,2 +125,3 @@ import { Workflow } from './Workflow';

getWebhookDescription(name: string): IWebhookDescription | undefined;
getWebhookName(): string;
getWorkflowStaticData(type: string): IDataObject;

@@ -148,2 +149,3 @@ helpers: {

getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
getNodeWebhookUrl: (name: string) => string | undefined;
getQueryData(): object;

@@ -153,2 +155,3 @@ getRequestObject(): express.Request;

getTimezone(): string;
getWebhookName(): string;
getWorkflowStaticData(type: string): IDataObject;

@@ -192,4 +195,4 @@ prepareOutputData(outputData: INodeExecutionData[], outputIndex?: number): Promise<INodeExecutionData[][]>;

getExecuteSingleFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, itemIndex: number, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteSingleFunctions;
getExecuteHookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, isTest?: boolean): IHookFunctions;
getExecuteWebhookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IWebhookFunctions;
getExecuteHookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, isTest?: boolean, webhookData?: IWebhookData): IHookFunctions;
getExecuteWebhookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, webhookData: IWebhookData): IWebhookFunctions;
}

@@ -246,2 +249,5 @@ export declare type NodeParameterValue = string | number | boolean;

}
export interface IParameterDependencies {
[key: string]: string[];
}
export interface ITriggerResponse {

@@ -315,2 +321,3 @@ closeFunction?: () => Promise<void>;

maxNodes?: number;
subtitle?: string;
hooks?: {

@@ -317,0 +324,0 @@ [key: string]: INodeHookDescription[] | undefined;

8

dist/src/NodeHelpers.d.ts

@@ -1,2 +0,2 @@

import { IContextObject, INodeCredentialDescription, INode, INodeExecutionData, INodeIssues, INodeParameters, INodeProperties, IRunExecutionData, IWebhookData, NodeParameterValue, IWorkflowExecuteAdditionalData } from './Interfaces';
import { IContextObject, INodeCredentialDescription, INode, INodeExecutionData, INodeIssues, INodeParameters, INodeProperties, IParameterDependencies, IRunExecutionData, IWebhookData, IWorkflowExecuteAdditionalData, NodeParameterValue } from './Interfaces';
import { Workflow } from './Workflow';

@@ -6,3 +6,5 @@ export declare function displayParameter(nodeValues: INodeParameters, parameter: INodeProperties | INodeCredentialDescription, nodeValuesRoot?: INodeParameters): boolean;

export declare function getContext(runExecutionData: IRunExecutionData, type: string, node?: INode): IContextObject;
export declare function getNodeParameters(nodePropertiesArray: INodeProperties[], nodeValues: INodeParameters, returnDefaults: boolean, returnNoneDisplayed: boolean, onlySimpleTypes?: boolean, dataIsResolved?: boolean, nodeValuesRoot?: INodeParameters, parentType?: string): INodeParameters | null;
export declare function getParamterDependencies(nodePropertiesArray: INodeProperties[]): IParameterDependencies;
export declare function getParamterResolveOrder(nodePropertiesArray: INodeProperties[], parameterDependencies: IParameterDependencies): number[];
export declare function getNodeParameters(nodePropertiesArray: INodeProperties[], nodeValues: INodeParameters, returnDefaults: boolean, returnNoneDisplayed: boolean, onlySimpleTypes?: boolean, dataIsResolved?: boolean, nodeValuesRoot?: INodeParameters, parentType?: string, parameterDependencies?: IParameterDependencies): INodeParameters | null;
export declare function prepareOutputData(outputData: INodeExecutionData[], outputIndex?: number): Promise<INodeExecutionData[][]>;

@@ -15,4 +17,4 @@ export declare function getNodeWebhooks(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData): IWebhookData[];

export declare function addToIssuesIfMissing(foundIssues: INodeIssues, nodeProperties: INodeProperties, value: NodeParameterValue): void;
export declare function getParameterValueByPath(nodeValues: INodeParameters, parameterName: string, path: string): string | number | boolean | INodeParameters | NodeParameterValue[] | INodeParameters[];
export declare function getParameterValueByPath(nodeValues: INodeParameters, parameterName: string, path: string): string | number | boolean | INodeParameters | (string | number | boolean)[] | INodeParameters[];
export declare function getParameterIssues(nodeProperties: INodeProperties, nodeValues: INodeParameters, path: string): INodeIssues;
export declare function mergeIssues(destination: INodeIssues, source: INodeIssues | null): void;

@@ -75,10 +75,90 @@ "use strict";

exports.getContext = getContext;
function getNodeParameters(nodePropertiesArray, nodeValues, returnDefaults, returnNoneDisplayed, onlySimpleTypes = false, dataIsResolved = false, nodeValuesRoot, parentType) {
function getParamterDependencies(nodePropertiesArray) {
const dependencies = {};
let displayRule;
let parameterName;
for (const nodeProperties of nodePropertiesArray) {
if (dependencies[nodeProperties.name] === undefined) {
dependencies[nodeProperties.name] = [];
}
if (nodeProperties.displayOptions === undefined) {
continue;
}
for (displayRule of Object.keys(nodeProperties.displayOptions)) {
for (parameterName of Object.keys(nodeProperties.displayOptions[displayRule])) {
if (!dependencies[nodeProperties.name].includes(parameterName)) {
dependencies[nodeProperties.name].push(parameterName);
}
}
}
}
return dependencies;
}
exports.getParamterDependencies = getParamterDependencies;
function getParamterResolveOrder(nodePropertiesArray, parameterDependencies) {
const executionOrder = [];
const indexToResolve = Array.from({ length: nodePropertiesArray.length }, (v, k) => k);
const resolvedParamters = [];
let index;
let property;
let lastIndexLength = indexToResolve.length;
let lastIndexReduction = -1;
let itterations = 0;
while (indexToResolve.length !== 0) {
itterations += 1;
index = indexToResolve.shift();
property = nodePropertiesArray[index];
if (parameterDependencies[property.name].length === 0) {
executionOrder.push(index);
resolvedParamters.push(property.name);
continue;
}
for (const dependency of parameterDependencies[property.name]) {
if (!resolvedParamters.includes(dependency)) {
if (dependency.charAt(0) === '/') {
continue;
}
indexToResolve.push(index);
continue;
}
}
executionOrder.push(index);
resolvedParamters.push(property.name);
if (indexToResolve.length < lastIndexLength) {
lastIndexReduction = itterations;
}
if (itterations > lastIndexReduction + nodePropertiesArray.length) {
throw new Error('Could not resolve parameter depenencies!');
}
lastIndexLength = indexToResolve.length;
}
return executionOrder;
}
exports.getParamterResolveOrder = getParamterResolveOrder;
function getNodeParameters(nodePropertiesArray, nodeValues, returnDefaults, returnNoneDisplayed, onlySimpleTypes = false, dataIsResolved = false, nodeValuesRoot, parentType, parameterDependencies) {
if (parameterDependencies === undefined) {
parameterDependencies = getParamterDependencies(nodePropertiesArray);
}
const duplicateParameterNames = [];
const parameterNames = [];
for (const nodeProperties of nodePropertiesArray) {
if (parameterNames.includes(nodeProperties.name)) {
if (!duplicateParameterNames.includes(nodeProperties.name)) {
duplicateParameterNames.push(nodeProperties.name);
}
}
else {
parameterNames.push(nodeProperties.name);
}
}
const nodeParameters = {};
let nodeValuesDisplayCheck = nodeValues;
const nodeParametersFull = {};
let nodeValuesDisplayCheck = nodeParametersFull;
if (dataIsResolved !== true && returnNoneDisplayed === false) {
nodeValuesDisplayCheck = getNodeParameters(nodePropertiesArray, nodeValues, true, true, true, true, nodeValuesRoot, parentType);
nodeValuesDisplayCheck = getNodeParameters(nodePropertiesArray, nodeValues, true, true, true, true, nodeValuesRoot, parentType, parameterDependencies);
}
nodeValuesRoot = nodeValuesRoot || nodeValuesDisplayCheck;
for (const nodeProperties of nodePropertiesArray) {
const parameterItterationOrderIndex = getParamterResolveOrder(nodePropertiesArray, parameterDependencies);
for (const parameterIndex of parameterItterationOrderIndex) {
const nodeProperties = nodePropertiesArray[parameterIndex];
if (nodeValues[nodeProperties.name] === undefined && (returnDefaults === false || parentType === 'collection')) {

@@ -96,2 +176,7 @@ continue;

if (!['collection', 'fixedCollection'].includes(nodeProperties.type)) {
if (duplicateParameterNames.includes(nodeProperties.name)) {
if (!displayParameter(nodeValuesDisplayCheck, nodeProperties, nodeValuesRoot)) {
continue;
}
}
if (returnDefaults === true) {

@@ -104,5 +189,7 @@ if (['boolean', 'number'].includes(nodeProperties.type)) {

}
nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name];
}
else if (nodeValues[nodeProperties.name] !== nodeProperties.default || (nodeValues[nodeProperties.name] !== undefined && parentType === 'collection')) {
nodeParameters[nodeProperties.name] = nodeValues[nodeProperties.name];
nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name];
continue;

@@ -123,2 +210,3 @@ }

}
nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name];
}

@@ -130,2 +218,3 @@ else {

nodeParameters[nodeProperties.name] = tempNodeParameters;
nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name];
}

@@ -135,2 +224,3 @@ }

nodeParameters[nodeProperties.name] = JSON.parse(JSON.stringify(nodeProperties.default));
nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name];
}

@@ -189,5 +279,7 @@ }

}
nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name];
}
else if (collectionValues !== nodeProperties.default) {
nodeParameters[nodeProperties.name] = collectionValues;
nodeParametersFull[nodeProperties.name] = nodeParameters[nodeProperties.name];
}

@@ -222,3 +314,3 @@ }

for (const webhookDescription of nodeType.description.webhooks) {
let nodeWebhookPath = workflow.getWebhookParameterValue(node, webhookDescription, 'path', 'GET');
let nodeWebhookPath = workflow.getSimpleParameterValue(node, webhookDescription['path'], 'GET');
if (nodeWebhookPath === undefined) {

@@ -232,3 +324,3 @@ console.error(`No webhook path could be found for node "${node.name}" in workflow "${workflow.id}".`);

const path = getNodeWebhookPath(workflow.id, node, nodeWebhookPath);
const httpMethod = workflow.getWebhookParameterValue(node, webhookDescription, 'httpMethod', 'GET');
const httpMethod = workflow.getSimpleParameterValue(node, webhookDescription['httpMethod'], 'GET');
if (httpMethod === undefined) {

@@ -235,0 +327,0 @@ console.error(`The webhook "${path}" for node "${node.name}" in workflow "${workflow.id}" could not be added because the httpMethod is not defined.`);

@@ -1,2 +0,2 @@

import { IConnections, INode, INodes, INodeExecuteFunctions, INodeExecutionData, INodeParameters, NodeParameterValue, INodeTypes, IRunExecutionData, ITaskDataConnections, ITriggerResponse, IWebhookData, IWebhookDescription, IWebhookResonseData, WebhookSetupMethodNames, IWorfklowIssues, IWorkflowExecuteAdditionalData, WorkflowExecuteMode, IWorkflowSettings } from './';
import { IConnections, INode, INodes, INodeExecuteFunctions, INodeExecutionData, INodeParameters, NodeParameterValue, INodeTypes, IRunExecutionData, ITaskDataConnections, ITriggerResponse, IWebhookData, IWebhookResonseData, WebhookSetupMethodNames, IWorfklowIssues, IWorkflowExecuteAdditionalData, WorkflowExecuteMode, IWorkflowSettings } from './';
import { IDataObject } from './Interfaces';

@@ -25,3 +25,3 @@ export declare class Workflow {

getNodeConnectionOutputIndex(nodeName: string, parentNodeName: string, type?: string, depth?: number, checkedNodes?: string[]): number | undefined;
getWebhookParameterValue(node: INode, webhookDescription: IWebhookDescription, parameterName: string, defaultValue?: string): string | undefined;
getSimpleParameterValue(node: INode, parameterValue: string | undefined, defaultValue?: string): string | undefined;
getStartNodes(destinationNode?: string): INode[];

@@ -33,4 +33,4 @@ getParameterValue(parameterValue: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[], runExecutionData: IRunExecutionData | null, runIndex: number, itemIndex: number, activeNodeName: string, connectionInputData: INodeExecutionData[], returnObjectAsString?: boolean): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[];

runTrigger(node: INode, nodeExecuteFunctions: INodeExecuteFunctions, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): Promise<ITriggerResponse | undefined>;
runWebhook(node: INode, additionalData: IWorkflowExecuteAdditionalData, nodeExecuteFunctions: INodeExecuteFunctions, mode: WorkflowExecuteMode): Promise<IWebhookResonseData>;
runWebhook(webhookData: IWebhookData, node: INode, additionalData: IWorkflowExecuteAdditionalData, nodeExecuteFunctions: INodeExecuteFunctions, mode: WorkflowExecuteMode): Promise<IWebhookResonseData>;
runNode(node: INode, inputData: ITaskDataConnections, runExecutionData: IRunExecutionData, runIndex: number, additionalData: IWorkflowExecuteAdditionalData, nodeExecuteFunctions: INodeExecuteFunctions, mode: WorkflowExecuteMode): Promise<INodeExecutionData[][] | null>;
}

@@ -329,4 +329,3 @@ "use strict";

}
getWebhookParameterValue(node, webhookDescription, parameterName, defaultValue) {
const parameterValue = webhookDescription[parameterName];
getSimpleParameterValue(node, parameterValue, defaultValue) {
if (parameterValue === undefined) {

@@ -452,3 +451,3 @@ return defaultValue;

}
const thisArgs = nodeExecuteFunctions.getExecuteHookFunctions(this, node, webhookData.workflowExecuteAdditionalData, mode, isTest);
const thisArgs = nodeExecuteFunctions.getExecuteHookFunctions(this, node, webhookData.workflowExecuteAdditionalData, mode, isTest, webhookData);
return nodeType.webhookMethods[webhookData.webhookDescription.name][method].call(thisArgs);

@@ -478,3 +477,3 @@ }

}
async runWebhook(node, additionalData, nodeExecuteFunctions, mode) {
async runWebhook(webhookData, node, additionalData, nodeExecuteFunctions, mode) {
const nodeType = this.nodeTypes.getByName(node.type);

@@ -487,3 +486,3 @@ if (nodeType === undefined) {

}
const thisArgs = nodeExecuteFunctions.getExecuteWebhookFunctions(this, node, additionalData, mode);
const thisArgs = nodeExecuteFunctions.getExecuteWebhookFunctions(this, node, additionalData, mode, webhookData);
return nodeType.webhook.call(thisArgs);

@@ -490,0 +489,0 @@ }

{
"name": "n8n-workflow",
"version": "0.3.0",
"version": "0.4.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 too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc