mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core): Lazy-load nodes and credentials to reduce baseline memory usage (#4577)
This commit is contained in:
committed by
GitHub
parent
f63cd3b89e
commit
b6c57e19fc
@@ -31,7 +31,7 @@
|
||||
"format": "prettier --write . --ignore-path ../../.prettierignore",
|
||||
"lint": "eslint .",
|
||||
"lintfix": "eslint . --fix",
|
||||
"watch": "tsc --watch",
|
||||
"watch": "tsc -p tsconfig.build.json --watch",
|
||||
"test": "jest",
|
||||
"test:dev": "jest --watch"
|
||||
},
|
||||
@@ -42,6 +42,7 @@
|
||||
"@types/express": "^4.17.6",
|
||||
"@types/jmespath": "^0.15.0",
|
||||
"@types/lodash.get": "^4.4.6",
|
||||
"@types/lodash.isequal": "^4.5.6",
|
||||
"@types/lodash.merge": "^4.6.6",
|
||||
"@types/lodash.set": "^4.3.6",
|
||||
"@types/luxon": "^2.0.9",
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
// eslint-disable-next-line max-classes-per-file
|
||||
import * as express from 'express';
|
||||
import * as FormData from 'form-data';
|
||||
import type * as express from 'express';
|
||||
import type * as FormData from 'form-data';
|
||||
import type { IncomingHttpHeaders } from 'http';
|
||||
import type { URLSearchParams } from 'url';
|
||||
import type { IDeferredPromise } from './DeferredPromise';
|
||||
@@ -311,6 +309,7 @@ export interface ICredentialType {
|
||||
name: string;
|
||||
displayName: string;
|
||||
icon?: string;
|
||||
iconUrl?: string;
|
||||
extends?: string[];
|
||||
properties: INodeProperties[];
|
||||
documentationUrl?: string;
|
||||
@@ -325,9 +324,7 @@ export interface ICredentialType {
|
||||
}
|
||||
|
||||
export interface ICredentialTypes {
|
||||
credentialTypes?: ICredentialTypeData;
|
||||
init(credentialTypes?: ICredentialTypeData): Promise<void>;
|
||||
getAll(): ICredentialType[];
|
||||
recognizes(credentialType: string): boolean;
|
||||
getByName(credentialType: string): ICredentialType;
|
||||
}
|
||||
|
||||
@@ -1257,6 +1254,7 @@ export interface INodeTypeBaseDescription {
|
||||
displayName: string;
|
||||
name: string;
|
||||
icon?: string;
|
||||
iconUrl?: string;
|
||||
group: string[];
|
||||
description: string;
|
||||
documentationUrl?: string;
|
||||
@@ -1473,24 +1471,37 @@ export type WebhookResponseData = 'allEntries' | 'firstEntryJson' | 'firstEntryB
|
||||
export type WebhookResponseMode = 'onReceived' | 'lastNode';
|
||||
|
||||
export interface INodeTypes {
|
||||
nodeTypes: INodeTypeData;
|
||||
init(nodeTypes?: INodeTypeData): Promise<void>;
|
||||
getAll(): Array<INodeType | IVersionedNodeType>;
|
||||
getByNameAndVersion(nodeType: string, version?: number): INodeType | undefined;
|
||||
}
|
||||
|
||||
export interface ICredentialTypeData {
|
||||
[key: string]: {
|
||||
type: ICredentialType;
|
||||
sourcePath: string;
|
||||
};
|
||||
export type LoadingDetails = {
|
||||
className: string;
|
||||
sourcePath: string;
|
||||
};
|
||||
|
||||
export type KnownNodesAndCredentials = {
|
||||
nodes: Record<string, LoadingDetails>;
|
||||
credentials: Record<string, LoadingDetails>;
|
||||
};
|
||||
|
||||
export interface LoadedClass<T> {
|
||||
sourcePath: string;
|
||||
type: T;
|
||||
}
|
||||
|
||||
export interface INodeTypeData {
|
||||
[key: string]: {
|
||||
type: INodeType | IVersionedNodeType;
|
||||
sourcePath: string;
|
||||
};
|
||||
type LoadedData<T> = Record<string, LoadedClass<T>>;
|
||||
export type ICredentialTypeData = LoadedData<ICredentialType>;
|
||||
export type INodeTypeData = LoadedData<INodeType | IVersionedNodeType>;
|
||||
|
||||
export type LoadedNodesAndCredentials = {
|
||||
nodes: INodeTypeData;
|
||||
credentials: ICredentialTypeData;
|
||||
};
|
||||
|
||||
export interface INodesAndCredentials {
|
||||
known: KnownNodesAndCredentials;
|
||||
loaded: LoadedNodesAndCredentials;
|
||||
}
|
||||
|
||||
export interface IRun {
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
/* eslint-disable prefer-spread */
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { get, isEqual } from 'lodash';
|
||||
import get from 'lodash.get';
|
||||
import isEqual from 'lodash.isequal';
|
||||
|
||||
import {
|
||||
IContextObject,
|
||||
@@ -423,9 +423,7 @@ export function getContext(
|
||||
* Returns which parameters are dependent on which
|
||||
*
|
||||
*/
|
||||
export function getParamterDependencies(
|
||||
nodePropertiesArray: INodeProperties[],
|
||||
): IParameterDependencies {
|
||||
function getParameterDependencies(nodePropertiesArray: INodeProperties[]): IParameterDependencies {
|
||||
const dependencies: IParameterDependencies = {};
|
||||
|
||||
for (const nodeProperties of nodePropertiesArray) {
|
||||
@@ -548,7 +546,7 @@ export function getNodeParameters(
|
||||
parameterDependencies?: IParameterDependencies,
|
||||
): INodeParameters | null {
|
||||
if (parameterDependencies === undefined) {
|
||||
parameterDependencies = getParamterDependencies(nodePropertiesArray);
|
||||
parameterDependencies = getParameterDependencies(nodePropertiesArray);
|
||||
}
|
||||
|
||||
// Get the parameter names which get used multiple times as for this
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
import { IDataObject, IObservableObject } from './Interfaces';
|
||||
|
||||
export interface IObservableOptions {
|
||||
interface IObservableOptions {
|
||||
ignoreEmptyOnFirstChild?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -673,8 +673,6 @@ class NodeTypesClass implements INodeTypes {
|
||||
},
|
||||
};
|
||||
|
||||
async init(nodeTypes: INodeTypeData): Promise<void> {}
|
||||
|
||||
getAll(): INodeType[] {
|
||||
return Object.values(this.nodeTypes).map((data) => NodeHelpers.getVersionedNodeType(data.type));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user