mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
fix(core): Handle versioned custom nodes correctly (#5313)
This commit is contained in:
parent
309c995364
commit
59f5c4221e
|
@ -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 {
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue