mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
refactor: rename NodeVersionedType to VersionedNodeType and move it to the workflow package (#4443)
This commit is contained in:
parent
adef6d7083
commit
5c9b40117a
|
@ -9,7 +9,6 @@
|
||||||
import { Credentials, NodeExecuteFunctions } from 'n8n-core';
|
import { Credentials, NodeExecuteFunctions } from 'n8n-core';
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { NodeVersionedType } from 'n8n-nodes-base';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICredentialDataDecryptedObject,
|
ICredentialDataDecryptedObject,
|
||||||
|
@ -28,7 +27,8 @@ import {
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeData,
|
INodeTypeData,
|
||||||
INodeTypes,
|
INodeTypes,
|
||||||
INodeVersionedType,
|
IVersionedNodeType,
|
||||||
|
VersionedNodeType,
|
||||||
IRequestOptionsSimplified,
|
IRequestOptionsSimplified,
|
||||||
IRunExecutionData,
|
IRunExecutionData,
|
||||||
IWorkflowDataProxyAdditionalKeys,
|
IWorkflowDataProxyAdditionalKeys,
|
||||||
|
@ -60,7 +60,7 @@ const mockNodeTypes: INodeTypes = {
|
||||||
nodeTypes: {} as INodeTypeData,
|
nodeTypes: {} as INodeTypeData,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
init: async (nodeTypes?: INodeTypeData): Promise<void> => {},
|
init: async (nodeTypes?: INodeTypeData): Promise<void> => {},
|
||||||
getAll(): Array<INodeType | INodeVersionedType> {
|
getAll(): Array<INodeType | IVersionedNodeType> {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return Object.values(this.nodeTypes).map((data) => data.type);
|
return Object.values(this.nodeTypes).map((data) => data.type);
|
||||||
},
|
},
|
||||||
|
@ -484,9 +484,9 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
// Always set to an array even if node is not versioned to not having
|
// Always set to an array even if node is not versioned to not having
|
||||||
// to duplicate the logic
|
// to duplicate the logic
|
||||||
const allNodeTypes: INodeType[] = [];
|
const allNodeTypes: INodeType[] = [];
|
||||||
if (node instanceof NodeVersionedType) {
|
if (node instanceof VersionedNodeType) {
|
||||||
// Node is versioned
|
// Node is versioned
|
||||||
allNodeTypes.push(...Object.values((node as INodeVersionedType).nodeVersions));
|
allNodeTypes.push(...Object.values((node as IVersionedNodeType).nodeVersions));
|
||||||
} else {
|
} else {
|
||||||
// Node is not versioned
|
// Node is not versioned
|
||||||
allNodeTypes.push(node as INodeType);
|
allNodeTypes.push(node as INodeType);
|
||||||
|
@ -501,11 +501,11 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
if (Object.prototype.hasOwnProperty.call(node, 'nodeVersions')) {
|
if (Object.prototype.hasOwnProperty.call(node, 'nodeVersions')) {
|
||||||
// The node is versioned. So check all versions for test function
|
// The node is versioned. So check all versions for test function
|
||||||
// starting with the latest
|
// starting with the latest
|
||||||
const versions = Object.keys((node as INodeVersionedType).nodeVersions)
|
const versions = Object.keys((node as IVersionedNodeType).nodeVersions)
|
||||||
.sort()
|
.sort()
|
||||||
.reverse();
|
.reverse();
|
||||||
for (const version of versions) {
|
for (const version of versions) {
|
||||||
const versionedNode = (node as INodeVersionedType).nodeVersions[
|
const versionedNode = (node as IVersionedNodeType).nodeVersions[
|
||||||
parseInt(version, 10)
|
parseInt(version, 10)
|
||||||
];
|
];
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeData,
|
INodeTypeData,
|
||||||
INodeTypeNameVersion,
|
INodeTypeNameVersion,
|
||||||
INodeVersionedType,
|
IVersionedNodeType,
|
||||||
LoggerProxy,
|
LoggerProxy,
|
||||||
jsonParse,
|
jsonParse,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
@ -351,7 +351,7 @@ class LoadNodesAndCredentialsClass {
|
||||||
nodeName: string,
|
nodeName: string,
|
||||||
filePath: string,
|
filePath: string,
|
||||||
): INodeTypeNameVersion | undefined {
|
): INodeTypeNameVersion | undefined {
|
||||||
let tempNode: INodeType | INodeVersionedType;
|
let tempNode: INodeType | IVersionedNodeType;
|
||||||
let nodeVersion = 1;
|
let nodeVersion = 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -375,9 +375,9 @@ class LoadNodesAndCredentialsClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempNode.hasOwnProperty('nodeVersions')) {
|
if (tempNode.hasOwnProperty('nodeVersions')) {
|
||||||
const versionedNodeType = (tempNode as INodeVersionedType).getNodeType();
|
const versionedNodeType = (tempNode as IVersionedNodeType).getNodeType();
|
||||||
this.addCodex({ node: versionedNodeType, filePath, isCustom: packageName === 'CUSTOM' });
|
this.addCodex({ node: versionedNodeType, filePath, isCustom: packageName === 'CUSTOM' });
|
||||||
nodeVersion = (tempNode as INodeVersionedType).currentVersion;
|
nodeVersion = (tempNode as IVersionedNodeType).currentVersion;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
versionedNodeType.description.icon !== undefined &&
|
versionedNodeType.description.icon !== undefined &&
|
||||||
|
@ -459,7 +459,7 @@ class LoadNodesAndCredentialsClass {
|
||||||
filePath,
|
filePath,
|
||||||
isCustom,
|
isCustom,
|
||||||
}: {
|
}: {
|
||||||
node: INodeType | INodeVersionedType;
|
node: INodeType | IVersionedNodeType;
|
||||||
filePath: string;
|
filePath: string;
|
||||||
isCustom: boolean;
|
isCustom: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
INodeTypeData,
|
INodeTypeData,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
INodeTypes,
|
INodeTypes,
|
||||||
INodeVersionedType,
|
IVersionedNodeType,
|
||||||
NodeHelpers,
|
NodeHelpers,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class NodeTypesClass implements INodeTypes {
|
||||||
this.nodeTypes = nodeTypes;
|
this.nodeTypes = nodeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(): Array<INodeType | INodeVersionedType> {
|
getAll(): Array<INodeType | IVersionedNodeType> {
|
||||||
return Object.values(this.nodeTypes).map((data) => data.type);
|
return Object.values(this.nodeTypes).map((data) => data.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class NodeTypesClass implements INodeTypes {
|
||||||
|
|
||||||
attachNodeType(
|
attachNodeType(
|
||||||
nodeTypeName: string,
|
nodeTypeName: string,
|
||||||
nodeType: INodeType | INodeVersionedType,
|
nodeType: INodeType | IVersionedNodeType,
|
||||||
sourcePath: string,
|
sourcePath: string,
|
||||||
): void {
|
): void {
|
||||||
this.nodeTypes[nodeTypeName] = {
|
this.nodeTypes[nodeTypeName] = {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {
|
||||||
INodeTypes,
|
INodeTypes,
|
||||||
INodeTypeData,
|
INodeTypeData,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
INodeVersionedType,
|
IVersionedNodeType,
|
||||||
IPinData,
|
IPinData,
|
||||||
IRunData,
|
IRunData,
|
||||||
IRunExecutionData,
|
IRunExecutionData,
|
||||||
|
@ -313,7 +313,7 @@ export const workflowHelpers = mixins(
|
||||||
const nodeTypes: INodeTypes = {
|
const nodeTypes: INodeTypes = {
|
||||||
nodeTypes: {},
|
nodeTypes: {},
|
||||||
init: async (nodeTypes?: INodeTypeData): Promise<void> => { },
|
init: async (nodeTypes?: INodeTypeData): Promise<void> => { },
|
||||||
getAll: (): Array<INodeType | INodeVersionedType> => {
|
getAll: (): Array<INodeType | IVersionedNodeType> => {
|
||||||
// Does not get used in Workflow so no need to return it
|
// Does not get used in Workflow so no need to return it
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import { INodeTypeBaseDescription, IVersionedNodeType, VersionedNodeType } from 'n8n-workflow';
|
||||||
import { NodeVersionedType } from '../../src/NodeVersionedType';
|
|
||||||
import { EmailReadImapV1 } from './v1/EmailReadImapV1.node';
|
import { EmailReadImapV1 } from './v1/EmailReadImapV1.node';
|
||||||
import { EmailReadImapV2 } from './v2/EmailReadImapV2.node';
|
import { EmailReadImapV2 } from './v2/EmailReadImapV2.node';
|
||||||
|
|
||||||
export class EmailReadImap extends NodeVersionedType {
|
export class EmailReadImap extends VersionedNodeType {
|
||||||
constructor() {
|
constructor() {
|
||||||
const baseDescription: INodeTypeBaseDescription = {
|
const baseDescription: INodeTypeBaseDescription = {
|
||||||
displayName: 'Email Trigger (IMAP)',
|
displayName: 'Email Trigger (IMAP)',
|
||||||
|
@ -14,7 +14,7 @@ export class EmailReadImap extends NodeVersionedType {
|
||||||
defaultVersion: 2,
|
defaultVersion: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: INodeVersionedType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new EmailReadImapV1(baseDescription),
|
1: new EmailReadImapV1(baseDescription),
|
||||||
2: new EmailReadImapV2(baseDescription),
|
2: new EmailReadImapV2(baseDescription),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import { INodeTypeBaseDescription, IVersionedNodeType, VersionedNodeType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { NodeVersionedType } from '../../../src/NodeVersionedType';
|
|
||||||
|
|
||||||
import { GmailV1 } from './v1/GmailV1.node';
|
import { GmailV1 } from './v1/GmailV1.node';
|
||||||
|
|
||||||
import { GmailV2 } from './v2/GmailV2.node';
|
import { GmailV2 } from './v2/GmailV2.node';
|
||||||
|
|
||||||
export class Gmail extends NodeVersionedType {
|
export class Gmail extends VersionedNodeType {
|
||||||
constructor() {
|
constructor() {
|
||||||
const baseDescription: INodeTypeBaseDescription = {
|
const baseDescription: INodeTypeBaseDescription = {
|
||||||
displayName: 'Gmail',
|
displayName: 'Gmail',
|
||||||
|
@ -18,7 +15,7 @@ export class Gmail extends NodeVersionedType {
|
||||||
defaultVersion: 2,
|
defaultVersion: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: INodeVersionedType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new GmailV1(baseDescription),
|
1: new GmailV1(baseDescription),
|
||||||
2: new GmailV2(baseDescription),
|
2: new GmailV2(baseDescription),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import { INodeTypeBaseDescription, IVersionedNodeType, VersionedNodeType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { HttpRequestV1 } from './V1/HttpRequestV1.node';
|
import { HttpRequestV1 } from './V1/HttpRequestV1.node';
|
||||||
|
|
||||||
import { HttpRequestV2 } from './V2/HttpRequestV2.node';
|
import { HttpRequestV2 } from './V2/HttpRequestV2.node';
|
||||||
|
|
||||||
import { HttpRequestV3 } from './V3/HttpRequestV3.node';
|
import { HttpRequestV3 } from './V3/HttpRequestV3.node';
|
||||||
|
|
||||||
import { NodeVersionedType } from '../../src/NodeVersionedType';
|
export class HttpRequest extends VersionedNodeType {
|
||||||
|
|
||||||
export class HttpRequest extends NodeVersionedType {
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const baseDescription: INodeTypeBaseDescription = {
|
const baseDescription: INodeTypeBaseDescription = {
|
||||||
displayName: 'HTTP Request',
|
displayName: 'HTTP Request',
|
||||||
|
@ -20,7 +16,7 @@ export class HttpRequest extends NodeVersionedType {
|
||||||
defaultVersion: 3,
|
defaultVersion: 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: INodeVersionedType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new HttpRequestV1(baseDescription),
|
1: new HttpRequestV1(baseDescription),
|
||||||
2: new HttpRequestV2(baseDescription),
|
2: new HttpRequestV2(baseDescription),
|
||||||
3: new HttpRequestV3(baseDescription),
|
3: new HttpRequestV3(baseDescription),
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import { INodeTypeBaseDescription, IVersionedNodeType, VersionedNodeType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { MattermostV1 } from './v1/MattermostV1.node';
|
import { MattermostV1 } from './v1/MattermostV1.node';
|
||||||
import { NodeVersionedType } from '../../src/NodeVersionedType';
|
|
||||||
|
|
||||||
export class Mattermost extends NodeVersionedType {
|
export class Mattermost extends VersionedNodeType {
|
||||||
constructor() {
|
constructor() {
|
||||||
const baseDescription: INodeTypeBaseDescription = {
|
const baseDescription: INodeTypeBaseDescription = {
|
||||||
displayName: 'Mattermost',
|
displayName: 'Mattermost',
|
||||||
|
@ -15,7 +14,7 @@ export class Mattermost extends NodeVersionedType {
|
||||||
defaultVersion: 1,
|
defaultVersion: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: INodeVersionedType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new MattermostV1(baseDescription),
|
1: new MattermostV1(baseDescription),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import { INodeTypeBaseDescription, IVersionedNodeType, VersionedNodeType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { NodeVersionedType } from '../../src/NodeVersionedType';
|
|
||||||
|
|
||||||
import { MergeV1 } from './v1/MergeV1.node';
|
import { MergeV1 } from './v1/MergeV1.node';
|
||||||
|
|
||||||
import { MergeV2 } from './v2/MergeV2.node';
|
import { MergeV2 } from './v2/MergeV2.node';
|
||||||
|
|
||||||
export class Merge extends NodeVersionedType {
|
export class Merge extends VersionedNodeType {
|
||||||
constructor() {
|
constructor() {
|
||||||
const baseDescription: INodeTypeBaseDescription = {
|
const baseDescription: INodeTypeBaseDescription = {
|
||||||
displayName: 'Merge',
|
displayName: 'Merge',
|
||||||
|
@ -18,7 +15,7 @@ export class Merge extends NodeVersionedType {
|
||||||
defaultVersion: 2,
|
defaultVersion: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: INodeVersionedType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new MergeV1(baseDescription),
|
1: new MergeV1(baseDescription),
|
||||||
2: new MergeV2(baseDescription),
|
2: new MergeV2(baseDescription),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import { INodeTypeBaseDescription, IVersionedNodeType, VersionedNodeType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { NotionV1 } from './v1/NotionV1.node';
|
import { NotionV1 } from './v1/NotionV1.node';
|
||||||
|
|
||||||
import { NotionV2 } from './v2/NotionV2.node';
|
import { NotionV2 } from './v2/NotionV2.node';
|
||||||
|
|
||||||
import { NodeVersionedType } from '../../src/NodeVersionedType';
|
export class Notion extends VersionedNodeType {
|
||||||
|
|
||||||
export class Notion extends NodeVersionedType {
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const baseDescription: INodeTypeBaseDescription = {
|
const baseDescription: INodeTypeBaseDescription = {
|
||||||
displayName: 'Notion (Beta)',
|
displayName: 'Notion (Beta)',
|
||||||
|
@ -18,7 +15,7 @@ export class Notion extends NodeVersionedType {
|
||||||
defaultVersion: 2,
|
defaultVersion: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: INodeVersionedType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new NotionV1(baseDescription),
|
1: new NotionV1(baseDescription),
|
||||||
2: new NotionV2(baseDescription),
|
2: new NotionV2(baseDescription),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import { INodeTypeBaseDescription, IVersionedNodeType, VersionedNodeType } from 'n8n-workflow';
|
||||||
|
|
||||||
import { NodeVersionedType } from '../../src/NodeVersionedType';
|
|
||||||
|
|
||||||
import { SyncroMspV1 } from './v1/SyncroMspV1.node';
|
import { SyncroMspV1 } from './v1/SyncroMspV1.node';
|
||||||
|
|
||||||
export class SyncroMsp extends NodeVersionedType {
|
export class SyncroMsp extends VersionedNodeType {
|
||||||
constructor() {
|
constructor() {
|
||||||
const baseDescription: INodeTypeBaseDescription = {
|
const baseDescription: INodeTypeBaseDescription = {
|
||||||
displayName: 'SyncroMSP',
|
displayName: 'SyncroMSP',
|
||||||
|
@ -17,7 +15,7 @@ export class SyncroMsp extends NodeVersionedType {
|
||||||
defaultVersion: 1,
|
defaultVersion: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: INodeVersionedType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new SyncroMspV1(baseDescription),
|
1: new SyncroMspV1(baseDescription),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,13 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/n8n-io/n8n.git"
|
"url": "git+https://github.com/n8n-io/n8n.git"
|
||||||
},
|
},
|
||||||
"main": "dist/src/index",
|
|
||||||
"types": "dist/src/index.d.ts",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run watch",
|
"dev": "npm run watch",
|
||||||
"build": "tsc && gulp build:icons && gulp build:translations",
|
"build": "tsc && gulp build:icons && gulp build:translations",
|
||||||
"build:translations": "gulp build:translations",
|
"build:translations": "gulp build:translations",
|
||||||
"format": "cd ../.. && node_modules/prettier/bin-prettier.js --write \"packages/nodes-base/**/*.{ts,json}\"",
|
"format": "cd ../.. && node_modules/prettier/bin-prettier.js --write \"packages/nodes-base/**/*.{ts,json}\"",
|
||||||
"lint": "tslint -p tsconfig.json -c tslint.json && eslint nodes credentials src",
|
"lint": "tslint -p tsconfig.json -c tslint.json && eslint nodes credentials",
|
||||||
"lintfix": "tslint --fix -p tsconfig.json -c tslint.json && eslint nodes credentials src --fix",
|
"lintfix": "tslint --fix -p tsconfig.json -c tslint.json && eslint nodes credentials --fix",
|
||||||
"watch": "tsc --watch",
|
"watch": "tsc --watch",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
import { NodeVersionedType } from './NodeVersionedType';
|
|
||||||
|
|
||||||
export { NodeVersionedType };
|
|
|
@ -11,7 +11,6 @@
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"credentials/**/*.ts",
|
"credentials/**/*.ts",
|
||||||
"src/**/*.ts",
|
|
||||||
"nodes/**/*.ts",
|
"nodes/**/*.ts",
|
||||||
"nodes/**/*.json",
|
"nodes/**/*.json",
|
||||||
"credentials/translations/**/*.json"
|
"credentials/translations/**/*.json"
|
||||||
|
|
|
@ -1144,7 +1144,7 @@ export interface INodeType {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INodeVersionedType {
|
export interface IVersionedNodeType {
|
||||||
nodeVersions: {
|
nodeVersions: {
|
||||||
[key: number]: INodeType;
|
[key: number]: INodeType;
|
||||||
};
|
};
|
||||||
|
@ -1423,7 +1423,7 @@ export type WebhookResponseMode = 'onReceived' | 'lastNode';
|
||||||
export interface INodeTypes {
|
export interface INodeTypes {
|
||||||
nodeTypes: INodeTypeData;
|
nodeTypes: INodeTypeData;
|
||||||
init(nodeTypes?: INodeTypeData): Promise<void>;
|
init(nodeTypes?: INodeTypeData): Promise<void>;
|
||||||
getAll(): Array<INodeType | INodeVersionedType>;
|
getAll(): Array<INodeType | IVersionedNodeType>;
|
||||||
getByNameAndVersion(nodeType: string, version?: number): INodeType | undefined;
|
getByNameAndVersion(nodeType: string, version?: number): INodeType | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,7 +1436,7 @@ export interface ICredentialTypeData {
|
||||||
|
|
||||||
export interface INodeTypeData {
|
export interface INodeTypeData {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
type: INodeType | INodeVersionedType;
|
type: INodeType | IVersionedNodeType;
|
||||||
sourcePath: string;
|
sourcePath: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import {
|
||||||
INodePropertyModeValidation,
|
INodePropertyModeValidation,
|
||||||
INodePropertyRegexValidation,
|
INodePropertyRegexValidation,
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeVersionedType,
|
IVersionedNodeType,
|
||||||
IParameterDependencies,
|
IParameterDependencies,
|
||||||
IRunExecutionData,
|
IRunExecutionData,
|
||||||
IWebhookData,
|
IWebhookData,
|
||||||
|
@ -1379,18 +1379,18 @@ export function mergeNodeProperties(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVersionedNodeType(
|
export function getVersionedNodeType(
|
||||||
object: INodeVersionedType | INodeType,
|
object: IVersionedNodeType | INodeType,
|
||||||
version?: number,
|
version?: number,
|
||||||
): INodeType {
|
): INodeType {
|
||||||
if (isNodeTypeVersioned(object)) {
|
if (isNodeTypeVersioned(object)) {
|
||||||
return (object as INodeVersionedType).getNodeType(version);
|
return (object as IVersionedNodeType).getNodeType(version);
|
||||||
}
|
}
|
||||||
return object as INodeType;
|
return object as INodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVersionedNodeTypeAll(object: INodeVersionedType | INodeType): INodeType[] {
|
export function getVersionedNodeTypeAll(object: IVersionedNodeType | INodeType): INodeType[] {
|
||||||
if (isNodeTypeVersioned(object)) {
|
if (isNodeTypeVersioned(object)) {
|
||||||
return Object.values((object as INodeVersionedType).nodeVersions).map((element) => {
|
return Object.values((object as IVersionedNodeType).nodeVersions).map((element) => {
|
||||||
element.description.name = object.description.name;
|
element.description.name = object.description.name;
|
||||||
return element;
|
return element;
|
||||||
});
|
});
|
||||||
|
@ -1398,6 +1398,6 @@ export function getVersionedNodeTypeAll(object: INodeVersionedType | INodeType):
|
||||||
return [object as INodeType];
|
return [object as INodeType];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNodeTypeVersioned(object: INodeVersionedType | INodeType): boolean {
|
export function isNodeTypeVersioned(object: IVersionedNodeType | INodeType): boolean {
|
||||||
return !!('getNodeType' in object);
|
return !!('getNodeType' in object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import { INodeType, INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow';
|
import type { INodeTypeBaseDescription, IVersionedNodeType, INodeType } from './Interfaces';
|
||||||
|
|
||||||
export class NodeVersionedType implements INodeVersionedType {
|
export class VersionedNodeType implements IVersionedNodeType {
|
||||||
currentVersion: number;
|
currentVersion: number;
|
||||||
nodeVersions: INodeVersionedType['nodeVersions'];
|
|
||||||
|
nodeVersions: IVersionedNodeType['nodeVersions'];
|
||||||
|
|
||||||
description: INodeTypeBaseDescription;
|
description: INodeTypeBaseDescription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
nodeVersions: INodeVersionedType['nodeVersions'],
|
nodeVersions: IVersionedNodeType['nodeVersions'],
|
||||||
description: INodeTypeBaseDescription,
|
description: INodeTypeBaseDescription,
|
||||||
) {
|
) {
|
||||||
this.nodeVersions = nodeVersions;
|
this.nodeVersions = nodeVersions;
|
|
@ -15,6 +15,7 @@ export * from './WorkflowActivationError';
|
||||||
export * from './WorkflowDataProxy';
|
export * from './WorkflowDataProxy';
|
||||||
export * from './WorkflowErrors';
|
export * from './WorkflowErrors';
|
||||||
export * from './WorkflowHooks';
|
export * from './WorkflowHooks';
|
||||||
|
export * from './VersionedNodeType';
|
||||||
export { LoggerProxy, NodeHelpers, ObservableObject, TelemetryHelpers };
|
export { LoggerProxy, NodeHelpers, ObservableObject, TelemetryHelpers };
|
||||||
export { deepCopy, jsonParse } from './utils';
|
export { deepCopy, jsonParse } from './utils';
|
||||||
export {
|
export {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import {
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeData,
|
INodeTypeData,
|
||||||
INodeTypes,
|
INodeTypes,
|
||||||
INodeVersionedType,
|
IVersionedNodeType,
|
||||||
IRunExecutionData,
|
IRunExecutionData,
|
||||||
ITaskDataConnections,
|
ITaskDataConnections,
|
||||||
IWorkflowBase,
|
IWorkflowBase,
|
||||||
|
@ -680,7 +680,7 @@ class NodeTypesClass implements INodeTypes {
|
||||||
return Object.values(this.nodeTypes).map((data) => NodeHelpers.getVersionedNodeType(data.type));
|
return Object.values(this.nodeTypes).map((data) => NodeHelpers.getVersionedNodeType(data.type));
|
||||||
}
|
}
|
||||||
|
|
||||||
getByName(nodeType: string): INodeType | INodeVersionedType | undefined {
|
getByName(nodeType: string): INodeType | IVersionedNodeType | undefined {
|
||||||
return this.getByNameAndVersion(nodeType);
|
return this.getByNameAndVersion(nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue