mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
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:
@@ -823,6 +823,7 @@ export interface INodeCredentials {
|
||||
}
|
||||
|
||||
export interface INode {
|
||||
id: string;
|
||||
name: string;
|
||||
typeVersion: number;
|
||||
type: string;
|
||||
@@ -1542,6 +1543,7 @@ export interface INoteGraphItem {
|
||||
}
|
||||
|
||||
export interface INodeGraphItem {
|
||||
id: string;
|
||||
type: string;
|
||||
resource?: string;
|
||||
operation?: string;
|
||||
@@ -1553,6 +1555,8 @@ export interface INodeGraphItem {
|
||||
credential_type?: string; // HTTP Request node v2
|
||||
credential_set?: boolean; // HTTP Request node v2
|
||||
method?: string; // HTTP Request node v2
|
||||
src_node_id?: string;
|
||||
src_instance_id?: string;
|
||||
}
|
||||
|
||||
export interface INodeNameIndex {
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ describe('Expression', () => {
|
||||
name: 'node',
|
||||
typeVersion: 1,
|
||||
type: 'test.set',
|
||||
id: 'uuid-1234',
|
||||
position: [0, 0],
|
||||
parameters: {}
|
||||
}
|
||||
|
||||
@@ -613,6 +613,7 @@ describe('RoutingNode', () => {
|
||||
name: 'test',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1234',
|
||||
position: [0, 0],
|
||||
};
|
||||
|
||||
@@ -1659,6 +1660,7 @@ describe('RoutingNode', () => {
|
||||
name: 'test',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1234',
|
||||
position: [0, 0],
|
||||
};
|
||||
|
||||
@@ -1831,6 +1833,7 @@ describe('RoutingNode', () => {
|
||||
name: 'test',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1234',
|
||||
position: [0, 0],
|
||||
};
|
||||
|
||||
|
||||
@@ -548,6 +548,7 @@ describe('Workflow', () => {
|
||||
parameters: stubData.parameters,
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1234',
|
||||
position: [100, 100],
|
||||
};
|
||||
}
|
||||
@@ -1008,6 +1009,7 @@ describe('Workflow', () => {
|
||||
parameters: testData.input.Node1.parameters,
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1',
|
||||
position: [100, 100],
|
||||
},
|
||||
{
|
||||
@@ -1015,6 +1017,7 @@ describe('Workflow', () => {
|
||||
parameters: testData.input.Node2.parameters,
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-2',
|
||||
position: [100, 200],
|
||||
},
|
||||
{
|
||||
@@ -1026,6 +1029,7 @@ describe('Workflow', () => {
|
||||
: {},
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-3',
|
||||
position: [100, 300],
|
||||
},
|
||||
{
|
||||
@@ -1037,6 +1041,7 @@ describe('Workflow', () => {
|
||||
: {},
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-4',
|
||||
position: [100, 400],
|
||||
},
|
||||
];
|
||||
@@ -1219,6 +1224,7 @@ describe('Workflow', () => {
|
||||
},
|
||||
type: 'test.setMulti',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1234',
|
||||
position: [100, 100],
|
||||
},
|
||||
];
|
||||
@@ -1296,6 +1302,7 @@ describe('Workflow', () => {
|
||||
name: 'Start',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1',
|
||||
position: [240, 300],
|
||||
},
|
||||
{
|
||||
@@ -1305,6 +1312,7 @@ describe('Workflow', () => {
|
||||
name: 'Set',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-2',
|
||||
position: [460, 300],
|
||||
},
|
||||
{
|
||||
@@ -1314,6 +1322,7 @@ describe('Workflow', () => {
|
||||
name: 'Set1',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-3',
|
||||
position: [680, 300],
|
||||
},
|
||||
],
|
||||
@@ -1353,6 +1362,7 @@ describe('Workflow', () => {
|
||||
name: 'Switch',
|
||||
type: 'test.switch',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1',
|
||||
position: [460, 300],
|
||||
},
|
||||
{
|
||||
@@ -1362,6 +1372,7 @@ describe('Workflow', () => {
|
||||
name: 'Set',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-2',
|
||||
position: [740, 300],
|
||||
},
|
||||
{
|
||||
@@ -1371,6 +1382,7 @@ describe('Workflow', () => {
|
||||
name: 'Set1',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-3',
|
||||
position: [780, 100],
|
||||
},
|
||||
{
|
||||
@@ -1380,6 +1392,7 @@ describe('Workflow', () => {
|
||||
name: 'Set2',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-4',
|
||||
position: [1040, 260],
|
||||
},
|
||||
],
|
||||
@@ -1443,6 +1456,7 @@ describe('Workflow', () => {
|
||||
name: 'Switch',
|
||||
type: 'test.switch',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1',
|
||||
position: [920, 340],
|
||||
},
|
||||
{
|
||||
@@ -1450,6 +1464,7 @@ describe('Workflow', () => {
|
||||
name: 'Start',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-2',
|
||||
position: [240, 300],
|
||||
},
|
||||
{
|
||||
@@ -1459,6 +1474,7 @@ describe('Workflow', () => {
|
||||
name: 'Set1',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-3',
|
||||
position: [700, 340],
|
||||
},
|
||||
{
|
||||
@@ -1468,6 +1484,7 @@ describe('Workflow', () => {
|
||||
name: 'Set',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-4',
|
||||
position: [1220, 300],
|
||||
},
|
||||
{
|
||||
@@ -1475,6 +1492,7 @@ describe('Workflow', () => {
|
||||
name: 'Switch',
|
||||
type: 'test.switch',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-5',
|
||||
position: [920, 340],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -10,6 +10,7 @@ describe('WorkflowDataProxy', () => {
|
||||
name: 'Start',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-1',
|
||||
position: [100, 200],
|
||||
},
|
||||
{
|
||||
@@ -20,6 +21,7 @@ describe('WorkflowDataProxy', () => {
|
||||
name: 'Function',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-2',
|
||||
position: [280, 200],
|
||||
},
|
||||
{
|
||||
@@ -36,6 +38,7 @@ describe('WorkflowDataProxy', () => {
|
||||
name: 'Rename',
|
||||
type: 'test.set',
|
||||
typeVersion: 1,
|
||||
id: 'uuid-3',
|
||||
position: [460, 200],
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user