mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Load credentials from the database (#1741)
* Changes to types so that credentials can be always loaded from DB This first commit changes all return types from the execute functions and calls to get credentials to be async so we can use await. This is a first step as previously credentials were loaded in memory and always available. We will now be loading them from the DB which requires turning the whole call chain async. * Fix updated files * Removed unnecessary credential loading to improve performance * Fix typo * ⚡ Fix issue * Updated new nodes to load credentials async * ⚡ Remove not needed comment Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -95,15 +95,13 @@ export interface ICredentialsExpressionResolveValues {
|
||||
|
||||
export abstract class ICredentialsHelper {
|
||||
encryptionKey: string;
|
||||
workflowCredentials: IWorkflowCredentials;
|
||||
|
||||
constructor(workflowCredentials: IWorkflowCredentials, encryptionKey: string) {
|
||||
constructor(encryptionKey: string) {
|
||||
this.encryptionKey = encryptionKey;
|
||||
this.workflowCredentials = workflowCredentials;
|
||||
}
|
||||
|
||||
abstract getCredentials(name: string, type: string): ICredentials;
|
||||
abstract getDecrypted(name: string, type: string, mode: WorkflowExecuteMode, raw?: boolean, expressionResolveValues?: ICredentialsExpressionResolveValues): ICredentialDataDecryptedObject;
|
||||
abstract getCredentials(name: string, type: string): Promise<ICredentials>;
|
||||
abstract getDecrypted(name: string, type: string, mode: WorkflowExecuteMode, raw?: boolean, expressionResolveValues?: ICredentialsExpressionResolveValues): Promise<ICredentialDataDecryptedObject>;
|
||||
abstract updateCredentials(name: string, type: string, data: ICredentialDataDecryptedObject): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -212,7 +210,7 @@ export interface IExecuteFunctions {
|
||||
evaluateExpression(expression: string, itemIndex: number): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[];
|
||||
executeWorkflow(workflowInfo: IExecuteWorkflowInfo, inputData?: INodeExecutionData[]): Promise<any>; // tslint:disable-line:no-any
|
||||
getContext(type: string): IContextObject;
|
||||
getCredentials(type: string, itemIndex?: number): ICredentialDataDecryptedObject | undefined;
|
||||
getCredentials(type: string, itemIndex?: number): Promise<ICredentialDataDecryptedObject | undefined>;
|
||||
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData[];
|
||||
getMode(): WorkflowExecuteMode;
|
||||
getNode(): INode;
|
||||
@@ -234,7 +232,7 @@ export interface IExecuteSingleFunctions {
|
||||
continueOnFail(): boolean;
|
||||
evaluateExpression(expression: string, itemIndex: number | undefined): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[];
|
||||
getContext(type: string): IContextObject;
|
||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
|
||||
getInputData(inputIndex?: number, inputName?: string): INodeExecutionData;
|
||||
getMode(): WorkflowExecuteMode;
|
||||
getNode(): INode;
|
||||
@@ -255,7 +253,7 @@ export interface IExecuteWorkflowInfo {
|
||||
}
|
||||
|
||||
export interface ILoadOptionsFunctions {
|
||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
|
||||
getNode(): INode;
|
||||
getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; //tslint:disable-line:no-any
|
||||
getCurrentNodeParameter(parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined;
|
||||
@@ -268,7 +266,7 @@ export interface ILoadOptionsFunctions {
|
||||
}
|
||||
|
||||
export interface IHookFunctions {
|
||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
|
||||
getMode(): WorkflowExecuteMode;
|
||||
getActivationMode(): WorkflowActivateMode;
|
||||
getNode(): INode;
|
||||
@@ -286,7 +284,7 @@ export interface IHookFunctions {
|
||||
|
||||
export interface IPollFunctions {
|
||||
__emit(data: INodeExecutionData[][]): void;
|
||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
|
||||
getMode(): WorkflowExecuteMode;
|
||||
getActivationMode(): WorkflowActivateMode;
|
||||
getNode(): INode;
|
||||
@@ -302,7 +300,7 @@ export interface IPollFunctions {
|
||||
|
||||
export interface ITriggerFunctions {
|
||||
emit(data: INodeExecutionData[][]): void;
|
||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
|
||||
getMode(): WorkflowExecuteMode;
|
||||
getActivationMode(): WorkflowActivateMode;
|
||||
getNode(): INode;
|
||||
@@ -318,7 +316,7 @@ export interface ITriggerFunctions {
|
||||
|
||||
export interface IWebhookFunctions {
|
||||
getBodyData(): IDataObject;
|
||||
getCredentials(type: string): ICredentialDataDecryptedObject | undefined;
|
||||
getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
|
||||
getHeaderData(): object;
|
||||
getMode(): WorkflowExecuteMode;
|
||||
getNode(): INode;
|
||||
@@ -739,7 +737,6 @@ export interface IWorkflowExecuteHooks {
|
||||
}
|
||||
|
||||
export interface IWorkflowExecuteAdditionalData {
|
||||
credentials: IWorkflowCredentials;
|
||||
credentialsHelper: ICredentialsHelper;
|
||||
encryptionKey: string;
|
||||
executeWorkflow: (workflowInfo: IExecuteWorkflowInfo, additionalData: IWorkflowExecuteAdditionalData, inputData?: INodeExecutionData[], parentExecutionId?: string, loadedWorkflowData?: IWorkflowBase, loadedRunData?: any) => Promise<any>; // tslint:disable-line:no-any
|
||||
|
||||
Reference in New Issue
Block a user