n8n-workflow
Advanced tools
Comparing version 0.87.0 to 0.88.0
@@ -795,3 +795,2 @@ /// <reference types="node" /> | ||
getAll(): Array<INodeType | INodeVersionedType>; | ||
getByName(nodeType: string): INodeType | INodeVersionedType | undefined; | ||
getByNameAndVersion(nodeType: string, version?: number): INodeType | undefined; | ||
@@ -798,0 +797,0 @@ } |
@@ -6,2 +6,3 @@ "use strict"; | ||
const ERROR_MESSAGE_PROPERTIES = [ | ||
'cause', | ||
'error', | ||
@@ -8,0 +9,0 @@ 'message', |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateNodesGraph = exports.getNodeTypeForName = void 0; | ||
const LoggerProxy_1 = require("./LoggerProxy"); | ||
function getNodeTypeForName(workflow, nodeName) { | ||
@@ -9,2 +10,3 @@ return workflow.nodes.find((node) => node.name === nodeName); | ||
function generateNodesGraph(workflow, nodeTypes) { | ||
var _a; | ||
const nodesGraph = { | ||
@@ -16,44 +18,52 @@ node_types: [], | ||
const nodeNameAndIndex = {}; | ||
workflow.nodes.forEach((node, index) => { | ||
var _a, _b, _c, _d, _e, _f; | ||
nodesGraph.node_types.push(node.type); | ||
const nodeItem = { | ||
type: node.type, | ||
position: node.position, | ||
}; | ||
if (node.type === 'n8n-nodes-base.httpRequest') { | ||
try { | ||
nodeItem.domain = new URL(node.parameters.url).hostname; | ||
try { | ||
workflow.nodes.forEach((node, index) => { | ||
var _a, _b, _c, _d, _e, _f; | ||
nodesGraph.node_types.push(node.type); | ||
const nodeItem = { | ||
type: node.type, | ||
position: node.position, | ||
}; | ||
if (node.type === 'n8n-nodes-base.httpRequest') { | ||
try { | ||
nodeItem.domain = new URL(node.parameters.url).hostname; | ||
} | ||
catch (e) { | ||
nodeItem.domain = node.parameters.url; | ||
} | ||
} | ||
catch (e) { | ||
nodeItem.domain = node.parameters.url; | ||
else { | ||
const nodeType = nodeTypes.getByNameAndVersion(node.type); | ||
nodeType === null || nodeType === void 0 ? void 0 : nodeType.description.properties.forEach((property) => { | ||
if (property.name === 'operation' || | ||
property.name === 'resource' || | ||
property.name === 'mode') { | ||
nodeItem[property.name] = property.default ? property.default.toString() : undefined; | ||
} | ||
}); | ||
nodeItem.operation = (_b = (_a = node.parameters.operation) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : nodeItem.operation; | ||
nodeItem.resource = (_d = (_c = node.parameters.resource) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : nodeItem.resource; | ||
nodeItem.mode = (_f = (_e = node.parameters.mode) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : nodeItem.mode; | ||
} | ||
} | ||
else { | ||
const nodeType = nodeTypes.getByName(node.type); | ||
nodeType.description.properties.forEach((property) => { | ||
if (property.name === 'operation' || | ||
property.name === 'resource' || | ||
property.name === 'mode') { | ||
nodeItem[property.name] = property.default ? property.default.toString() : undefined; | ||
} | ||
nodesGraph.nodes[`${index}`] = nodeItem; | ||
nodeNameAndIndex[node.name] = index.toString(); | ||
}); | ||
const getGraphConnectionItem = (startNode, connectionItem) => { | ||
return { start: nodeNameAndIndex[startNode], end: nodeNameAndIndex[connectionItem.node] }; | ||
}; | ||
Object.keys(workflow.connections).forEach((nodeName) => { | ||
const connections = workflow.connections[nodeName]; | ||
connections.main.forEach((element) => { | ||
element.forEach((element2) => { | ||
nodesGraph.node_connections.push(getGraphConnectionItem(nodeName, element2)); | ||
}); | ||
}); | ||
nodeItem.operation = (_b = (_a = node.parameters.operation) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : nodeItem.operation; | ||
nodeItem.resource = (_d = (_c = node.parameters.resource) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : nodeItem.resource; | ||
nodeItem.mode = (_f = (_e = node.parameters.mode) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : nodeItem.mode; | ||
} | ||
nodesGraph.nodes[`${index}`] = nodeItem; | ||
nodeNameAndIndex[node.name] = index.toString(); | ||
}); | ||
const getGraphConnectionItem = (startNode, connectionItem) => { | ||
return { start: nodeNameAndIndex[startNode], end: nodeNameAndIndex[connectionItem.node] }; | ||
}; | ||
Object.keys(workflow.connections).forEach((nodeName) => { | ||
const connections = workflow.connections[nodeName]; | ||
connections.main.forEach((element) => { | ||
element.forEach((element2) => { | ||
nodesGraph.node_connections.push(getGraphConnectionItem(nodeName, element2)); | ||
}); | ||
}); | ||
}); | ||
} | ||
catch (e) { | ||
const logger = LoggerProxy_1.getInstance(); | ||
logger.warn(`Failed to generate nodes graph for workflowId: ${workflow.id}`); | ||
logger.warn(e.message); | ||
logger.warn((_a = e.stack) !== null && _a !== void 0 ? _a : ''); | ||
} | ||
return { nodeGraph: nodesGraph, nameIndices: nodeNameAndIndex }; | ||
@@ -60,0 +70,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { CredentialInformation, ICredentialDataDecryptedObject, ICredentials, ICredentialsEncrypted, ICredentialsHelper, IExecuteFunctions, IExecuteSingleFunctions, IHttpRequestOptions, INode, INodeCredentialsDetails, INodeExecutionData, INodeParameters, INodeType, INodeTypeData, INodeTypes, IRunExecutionData, ITaskDataConnections, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, NodeParameterValue, Workflow, WorkflowExecuteMode } from '../src'; | ||
import { CredentialInformation, ICredentialDataDecryptedObject, ICredentials, ICredentialsEncrypted, ICredentialsHelper, IExecuteFunctions, IExecuteSingleFunctions, IHttpRequestOptions, INode, INodeCredentialsDetails, INodeExecutionData, INodeParameters, INodeType, INodeTypeData, INodeTypes, INodeVersionedType, IRunExecutionData, ITaskDataConnections, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, NodeParameterValue, Workflow, WorkflowExecuteMode } from '../src'; | ||
export interface INodeTypesObject { | ||
@@ -27,3 +27,3 @@ [key: string]: INodeType; | ||
getAll(): INodeType[]; | ||
getByName(nodeType: string): INodeType; | ||
getByName(nodeType: string): INodeType | INodeVersionedType | undefined; | ||
getByNameAndVersion(nodeType: string, version?: number): INodeType; | ||
@@ -30,0 +30,0 @@ } |
{ | ||
"name": "n8n-workflow", | ||
"version": "0.87.0", | ||
"version": "0.88.0", | ||
"description": "Workflow base code of n8n", | ||
@@ -34,2 +34,3 @@ "license": "SEE LICENSE IN LICENSE.md", | ||
"@types/lodash.merge": "^4.6.6", | ||
"@types/lodash.set": "^4.3.6", | ||
"@types/node": "14.17.27", | ||
@@ -36,0 +37,0 @@ "@types/xml2js": "^0.4.3", |
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
Sorry, the diff of this file is too big to display
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
656169
10142
19