refactor: Add node IDs (#3788)

* update type

* add id to new nodes

* update paste/import behavior

* update duplicate/copy

* update duplicate workflow

* update import functions + templates

* add instance id on copy

* on download add instance id

* simplify for testing

* update telemetry events

* add ids to nodegraph

* not if same instance

* update spacing

* fix tests

* update tests

* add uuid

* fix tests

update tests

add uuid

fix ts issue

* fix telemetry event

* update workflow import

* update public api

* add sqlit migration

* on workflow update

* add psql migration

* add mysql migration

* revert to title

* fix telemetry bug

* remove console log

* remove migration logs

* fix copy/paste bug

* replace node index with node id

* remove console log

* address PR feedback

* address comment

* fix type issue

* fix select

* update schema

* fix ts issue

* update tel helpers

* fix eslint issues
This commit is contained in:
Mutasem Aldmour
2022-08-03 13:06:53 +02:00
committed by GitHub
parent b5ea666ecf
commit 679a443a0c
40 changed files with 602 additions and 157 deletions

View File

@@ -22,10 +22,10 @@ export function isNumber(value: unknown): value is number {
}
function getStickyDimensions(note: INode, stickyType: INodeType | undefined) {
const heightProperty = stickyType?.description.properties.find(
const heightProperty = stickyType?.description?.properties.find(
(property) => property.name === 'height',
);
const widthProperty = stickyType?.description.properties.find(
const widthProperty = stickyType?.description?.properties.find(
(property) => property.name === 'width',
);
@@ -114,6 +114,10 @@ export function getDomainPath(raw: string, urlParts = URL_PARTS_REGEX): string {
export function generateNodesGraph(
workflow: IWorkflowBase,
nodeTypes: INodeTypes,
options?: {
sourceInstanceId?: string;
nodeIdMap?: { [curr: string]: string };
},
): INodesGraphResult {
const nodesGraph: INodesGraph = {
node_types: [],
@@ -149,10 +153,19 @@ export function generateNodesGraph(
otherNodes.forEach((node: INode, index: number) => {
nodesGraph.node_types.push(node.type);
const nodeItem: INodeGraphItem = {
id: node.id,
type: node.type,
position: node.position,
};
if (options?.sourceInstanceId) {
nodeItem.src_instance_id = options.sourceInstanceId;
}
if (node.id && options?.nodeIdMap && options.nodeIdMap[node.id]) {
nodeItem.src_node_id = options.nodeIdMap[node.id];
}
if (node.type === 'n8n-nodes-base.httpRequest' && node.typeVersion === 1) {
try {
nodeItem.domain = new URL(node.parameters.url as string).hostname;
@@ -182,7 +195,7 @@ export function generateNodesGraph(
} else {
const nodeType = nodeTypes.getByNameAndVersion(node.type);
nodeType?.description.properties.forEach((property) => {
nodeType?.description?.properties?.forEach((property) => {
if (
property.name === 'operation' ||
property.name === 'resource' ||
@@ -212,7 +225,7 @@ export function generateNodesGraph(
});
});
});
} catch (_) {
} catch (e) {
return { nodeGraph: nodesGraph, nameIndices: nodeNameAndIndex, webhookNodeNames };
}