first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import type { IConnections, NodeConnectionType } from '../interfaces';
export declare function getChildNodes(connectionsBySourceNode: IConnections, nodeName: string, type?: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN', depth?: number): string[];
//# sourceMappingURL=get-child-nodes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-child-nodes.d.ts","sourceRoot":"","sources":["../../../src/common/get-child-nodes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtE,wBAAgB,aAAa,CAC5B,uBAAuB,EAAE,YAAY,EACrC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,kBAAkB,GAAG,KAAK,GAAG,cAAyC,EAC5E,KAAK,SAAK,GACR,MAAM,EAAE,CAEV"}

View File

@@ -0,0 +1,6 @@
import { getConnectedNodes } from './get-connected-nodes';
import { NodeConnectionTypes } from '../interfaces';
export function getChildNodes(connectionsBySourceNode, nodeName, type = NodeConnectionTypes.Main, depth = -1) {
return getConnectedNodes(connectionsBySourceNode, nodeName, type, depth);
}
//# sourceMappingURL=get-child-nodes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-child-nodes.js","sourceRoot":"","sources":["../../../src/common/get-child-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,MAAM,UAAU,aAAa,CAC5B,uBAAqC,EACrC,QAAgB,EAChB,OAAoD,mBAAmB,CAAC,IAAI,EAC5E,KAAK,GAAG,CAAC,CAAC;IAEV,OAAO,iBAAiB,CAAC,uBAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC"}

View File

@@ -0,0 +1,10 @@
import type { IConnections, NodeConnectionType } from '../interfaces';
/**
* Gets all the nodes which are connected nodes starting from
* the given one
*
* @param {NodeConnectionType} [type='main']
* @param {*} [depth=-1]
*/
export declare function getConnectedNodes(connections: IConnections, nodeName: string, connectionType?: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN', depth?: number, checkedNodesIncoming?: string[]): string[];
//# sourceMappingURL=get-connected-nodes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-connected-nodes.d.ts","sourceRoot":"","sources":["../../../src/common/get-connected-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,WAAW,EAAE,YAAY,EACzB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,kBAAkB,GAAG,KAAK,GAAG,cAAyC,EACtF,KAAK,SAAK,EACV,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAC7B,MAAM,EAAE,CAiFV"}

View File

@@ -0,0 +1,71 @@
import { NodeConnectionTypes } from '../interfaces';
/**
* Gets all the nodes which are connected nodes starting from
* the given one
*
* @param {NodeConnectionType} [type='main']
* @param {*} [depth=-1]
*/
export function getConnectedNodes(connections, nodeName, connectionType = NodeConnectionTypes.Main, depth = -1, checkedNodesIncoming) {
const newDepth = depth === -1 ? depth : depth - 1;
if (depth === 0) {
// Reached max depth
return [];
}
if (!connections.hasOwnProperty(nodeName)) {
// Node does not have incoming connections
return [];
}
let types;
if (connectionType === 'ALL') {
types = Object.keys(connections[nodeName]);
}
else if (connectionType === 'ALL_NON_MAIN') {
types = Object.keys(connections[nodeName]).filter((type) => type !== 'main');
}
else {
types = [connectionType];
}
let addNodes;
let nodeIndex;
let i;
let parentNodeName;
const returnNodes = [];
types.forEach((type) => {
if (!connections[nodeName].hasOwnProperty(type)) {
// Node does not have incoming connections of given type
return;
}
const checkedNodes = checkedNodesIncoming ? [...checkedNodesIncoming] : [];
if (checkedNodes.includes(nodeName)) {
// Node got checked already before
return;
}
checkedNodes.push(nodeName);
connections[nodeName][type].forEach((connectionsByIndex) => {
connectionsByIndex?.forEach((connection) => {
if (checkedNodes.includes(connection.node)) {
// Node got checked already before
return;
}
returnNodes.unshift(connection.node);
addNodes = getConnectedNodes(connections, connection.node, connectionType, newDepth, checkedNodes);
for (i = addNodes.length; i--; i > 0) {
// Because nodes can have multiple parents it is possible that
// parts of the tree is parent of both and to not add nodes
// twice check first if they already got added before.
parentNodeName = addNodes[i];
nodeIndex = returnNodes.indexOf(parentNodeName);
if (nodeIndex !== -1) {
// Node got found before so remove it from current location
// that node-order stays correct
returnNodes.splice(nodeIndex, 1);
}
returnNodes.unshift(parentNodeName);
}
});
});
});
return returnNodes;
}
//# sourceMappingURL=get-connected-nodes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-connected-nodes.js","sourceRoot":"","sources":["../../../src/common/get-connected-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAChC,WAAyB,EACzB,QAAgB,EAChB,iBAA8D,mBAAmB,CAAC,IAAI,EACtF,KAAK,GAAG,CAAC,CAAC,EACV,oBAA+B;IAE/B,MAAM,QAAQ,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IAClD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QACjB,oBAAoB;QACpB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3C,0CAA0C;QAC1C,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,KAA2B,CAAC;IAChC,IAAI,cAAc,KAAK,KAAK,EAAE,CAAC;QAC9B,KAAK,GA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IAAI,CAAC,CAAC;gBAErC,QAAQ,GAAG,iBAAiB,CAC3B,WAAW,EACX,UAAU,CAAC,IAAI,EACf,cAAc,EACd,QAAQ,EACR,YAAY,CACZ,CAAC;gBAEF,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;oBACtC,8DAA8D;oBAC9D,2DAA2D;oBAC3D,sDAAsD;oBACtD,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;oBAC7B,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;oBAEhD,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;wBACtB,2DAA2D;wBAC3D,gCAAgC;wBAChC,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;oBAClC,CAAC;oBAED,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBACrC,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACpB,CAAC"}

View File

@@ -0,0 +1,9 @@
import type { INode, INodes } from '../interfaces';
/**
* Returns the node with the given name if it exists else null
*
* @param {INodes} nodes Nodes to search in
* @param {string} name Name of the node to return
*/
export declare function getNodeByName(nodes: INodes | INode[], name: string): INode | null;
//# sourceMappingURL=get-node-by-name.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-node-by-name.d.ts","sourceRoot":"","sources":["../../../src/common/get-node-by-name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,gBAUlE"}

View File

@@ -0,0 +1,16 @@
/**
* Returns the node with the given name if it exists else null
*
* @param {INodes} nodes Nodes to search in
* @param {string} name Name of the node to return
*/
export function getNodeByName(nodes, name) {
if (Array.isArray(nodes)) {
return nodes.find((node) => node.name === name) || null;
}
if (nodes.hasOwnProperty(name)) {
return nodes[name];
}
return null;
}
//# sourceMappingURL=get-node-by-name.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-node-by-name.js","sourceRoot":"","sources":["../../../src/common/get-node-by-name.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAuB,EAAE,IAAY;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;IACzD,CAAC;IAED,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}

View File

@@ -0,0 +1,9 @@
import type { IConnections, NodeConnectionType } from '../interfaces';
/**
* Returns all the nodes before the given one
*
* @param {NodeConnectionType} [type='main']
* @param {*} [depth=-1]
*/
export declare function getParentNodes(connectionsByDestinationNode: IConnections, nodeName: string, type?: NodeConnectionType | 'ALL' | 'ALL_NON_MAIN', depth?: number): string[];
//# sourceMappingURL=get-parent-nodes.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-parent-nodes.d.ts","sourceRoot":"","sources":["../../../src/common/get-parent-nodes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,4BAA4B,EAAE,YAAY,EAC1C,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,kBAAkB,GAAG,KAAK,GAAG,cAAyC,EAC5E,KAAK,SAAK,GACR,MAAM,EAAE,CAEV"}

View File

@@ -0,0 +1,12 @@
import { getConnectedNodes } from './get-connected-nodes';
import { NodeConnectionTypes } from '../interfaces';
/**
* Returns all the nodes before the given one
*
* @param {NodeConnectionType} [type='main']
* @param {*} [depth=-1]
*/
export function getParentNodes(connectionsByDestinationNode, nodeName, type = NodeConnectionTypes.Main, depth = -1) {
return getConnectedNodes(connectionsByDestinationNode, nodeName, type, depth);
}
//# sourceMappingURL=get-parent-nodes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-parent-nodes.js","sourceRoot":"","sources":["../../../src/common/get-parent-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC7B,4BAA0C,EAC1C,QAAgB,EAChB,OAAoD,mBAAmB,CAAC,IAAI,EAC5E,KAAK,GAAG,CAAC,CAAC;IAEV,OAAO,iBAAiB,CAAC,4BAA4B,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/E,CAAC"}

6
node_modules/n8n-workflow/dist/esm/common/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export * from './get-child-nodes';
export * from './get-connected-nodes';
export * from './get-node-by-name';
export * from './get-parent-nodes';
export * from './map-connections-by-destination';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kCAAkC,CAAC"}

6
node_modules/n8n-workflow/dist/esm/common/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export * from './get-child-nodes';
export * from './get-connected-nodes';
export * from './get-node-by-name';
export * from './get-parent-nodes';
export * from './map-connections-by-destination';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kCAAkC,CAAC"}

View File

@@ -0,0 +1,3 @@
import type { IConnections } from '../interfaces';
export declare function mapConnectionsByDestination(connections: IConnections): IConnections;
//# sourceMappingURL=map-connections-by-destination.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"map-connections-by-destination.d.ts","sourceRoot":"","sources":["../../../src/common/map-connections-by-destination.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,eAAe,CAAC;AAEtE,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,YAAY,gBA4CpE"}

View File

@@ -0,0 +1,40 @@
/* eslint-disable @typescript-eslint/no-for-in-array */
export function mapConnectionsByDestination(connections) {
const returnConnection = {};
let connectionInfo;
let maxIndex;
for (const sourceNode in connections) {
if (!connections.hasOwnProperty(sourceNode)) {
continue;
}
for (const type of Object.keys(connections[sourceNode])) {
if (!connections[sourceNode].hasOwnProperty(type)) {
continue;
}
for (const inputIndex in connections[sourceNode][type]) {
if (!connections[sourceNode][type].hasOwnProperty(inputIndex)) {
continue;
}
for (connectionInfo of connections[sourceNode][type][inputIndex] ?? []) {
if (!returnConnection.hasOwnProperty(connectionInfo.node)) {
returnConnection[connectionInfo.node] = {};
}
if (!returnConnection[connectionInfo.node].hasOwnProperty(connectionInfo.type)) {
returnConnection[connectionInfo.node][connectionInfo.type] = [];
}
maxIndex = returnConnection[connectionInfo.node][connectionInfo.type].length - 1;
for (let j = maxIndex; j < connectionInfo.index; j++) {
returnConnection[connectionInfo.node][connectionInfo.type].push([]);
}
returnConnection[connectionInfo.node][connectionInfo.type][connectionInfo.index]?.push({
node: sourceNode,
type,
index: parseInt(inputIndex, 10),
});
}
}
}
}
return returnConnection;
}
//# sourceMappingURL=map-connections-by-destination.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"map-connections-by-destination.js","sourceRoot":"","sources":["../../../src/common/map-connections-by-destination.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAIvD,MAAM,UAAU,2BAA2B,CAAC,WAAyB;IACpE,MAAM,gBAAgB,GAAiB,EAAE,CAAC;IAE1C,IAAI,cAAc,CAAC;IACnB,IAAI,QAAgB,CAAC;IACrB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACtC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7C,SAAS;QACV,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAyB,EAAE,CAAC;YACjF,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnD,SAAS;YACV,CAAC;YAED,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxD,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC/D,SAAS;gBACV,CAAC;gBAED,KAAK,cAAc,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;oBACxE,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC3D,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;oBAC5C,CAA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