fix(core): Handle versioned custom nodes correctly (#5313)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-02-10 18:33:04 +01:00 committed by GitHub
parent 309c995364
commit 59f5c4221e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 12 deletions

View file

@ -1,7 +1,7 @@
import * as path from 'path';
import { readFile } from 'fs/promises';
import glob from 'fast-glob';
import { jsonParse, LoggerProxy as Logger } from 'n8n-workflow';
import { jsonParse, getVersionedNodeTypeAll, LoggerProxy as Logger } from 'n8n-workflow';
import type {
CodexData,
DocumentationLink,
@ -133,7 +133,9 @@ export abstract class DirectoryLoader {
version: nodeVersion,
});
this.types.nodes.push(tempNode.description);
getVersionedNodeTypeAll(tempNode).forEach(({ description }) => {
this.types.nodes.push(description);
});
}
protected loadCredentialFromFile(credentialName: string, filePath: string): void {

View file

@ -1395,22 +1395,18 @@ export function getVersionedNodeType(
object: IVersionedNodeType | INodeType,
version?: number,
): INodeType {
if (isNodeTypeVersioned(object)) {
return (object as IVersionedNodeType).getNodeType(version);
if ('nodeVersions' in object) {
return object.getNodeType(version);
}
return object as INodeType;
return object;
}
export function getVersionedNodeTypeAll(object: IVersionedNodeType | INodeType): INodeType[] {
if (isNodeTypeVersioned(object)) {
return Object.values((object as IVersionedNodeType).nodeVersions).map((element) => {
if ('nodeVersions' in object) {
return Object.values(object.nodeVersions).map((element) => {
element.description.name = object.description.name;
return element;
});
}
return [object as INodeType];
}
export function isNodeTypeVersioned(object: IVersionedNodeType | INodeType): boolean {
return !!('getNodeType' in object);
return [object];
}

View file

@ -11,6 +11,7 @@ export * from './MessageEventBus';
export * from './Expression';
export * from './ExpressionError';
export * from './NodeErrors';
export * from './NodeHelpers';
export * from './RoutingNode';
export * from './Workflow';
export * from './WorkflowActivationError';