fix: Lazy load nodes for credentials testing (#4760)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-11-30 10:28:18 +01:00
committed by GitHub
parent 3d67df490c
commit 0a7a2f3e41
16 changed files with 132 additions and 123 deletions

View File

@@ -181,11 +181,7 @@ export interface IHttpRequestHelper {
helpers: { httpRequest: IAllExecuteFunctions['helpers']['httpRequest'] };
}
export abstract class ICredentialsHelper {
encryptionKey: string;
constructor(encryptionKey: string) {
this.encryptionKey = encryptionKey;
}
constructor(readonly encryptionKey: string) {}
abstract getParentTypes(name: string): string[];
@@ -329,6 +325,7 @@ export interface ICredentialType {
export interface ICredentialTypes {
recognizes(credentialType: string): boolean;
getByName(credentialType: string): ICredentialType;
getNodeTypesToTestWith(type: string): string[];
}
// The way the credentials get saved in the database (data encrypted)
@@ -1209,7 +1206,6 @@ export interface INodeCredentialTestResult {
}
export interface INodeCredentialTestRequest {
nodeToTestWith?: string; // node name i.e. slack
credentials: ICredentialsDecrypted;
}
@@ -1474,18 +1470,24 @@ export type WebhookResponseData = 'allEntries' | 'firstEntryJson' | 'firstEntryB
export type WebhookResponseMode = 'onReceived' | 'lastNode';
export interface INodeTypes {
getAll(): Array<INodeType | IVersionedNodeType>;
getByNameAndVersion(nodeType: string, version?: number): INodeType | undefined;
getByName(nodeType: string): INodeType | IVersionedNodeType;
getByNameAndVersion(nodeType: string, version?: number): INodeType;
}
export type LoadingDetails = {
type LoadingDetails = {
className: string;
sourcePath: string;
};
export type CredentialLoadingDetails = LoadingDetails & {
nodesToTestWith?: string[];
};
export type NodeLoadingDetails = LoadingDetails;
export type KnownNodesAndCredentials = {
nodes: Record<string, LoadingDetails>;
credentials: Record<string, LoadingDetails>;
nodes: Record<string, NodeLoadingDetails>;
credentials: Record<string, CredentialLoadingDetails>;
};
export interface LoadedClass<T> {

View File

@@ -673,12 +673,8 @@ class NodeTypesClass implements INodeTypes {
},
};
getAll(): INodeType[] {
return Object.values(this.nodeTypes).map((data) => NodeHelpers.getVersionedNodeType(data.type));
}
getByName(nodeType: string): INodeType | IVersionedNodeType | undefined {
return this.getByNameAndVersion(nodeType);
getByName(nodeType: string): INodeType | IVersionedNodeType {
return this.nodeTypes[nodeType].type;
}
getByNameAndVersion(nodeType: string, version?: number): INodeType {