mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
⚡ Change credentials structure (#2139)
* ✨ change FE to handle new object type * 🚸 improve UX of handling invalid credentials * 🚧 WIP * 🎨 fix typescript issues * 🐘 add migrations for all supported dbs * ✏️ add description to migrations * ⚡ add credential update on import * ⚡ resolve after merge issues * 👕 fix lint issues * ⚡ check credentials on workflow create/update * update interface * 👕 fix ts issues * ⚡ adaption to new credentials UI * 🐛 intialize cache on BE for credentials check * 🐛 fix undefined oldCredentials * 🐛 fix deleting credential * 🐛 fix check for undefined keys * 🐛 fix disabling edit in execution * 🎨 just show credential name on execution view * ✏️ remove TODO * ⚡ implement review suggestions * ⚡ add cache to getCredentialsByType * ⏪ use getter instead of cache * ✏️ fix variable name typo * 🐘 include waiting nodes to migrations * 🐛 fix reverting migrations command * ⚡ update typeorm command * ✨ create db:revert command * 👕 fix lint error Co-authored-by: Mutasem <mutdmour@gmail.com>
This commit is contained in:
@@ -52,10 +52,12 @@ export type ExecutionError = WorkflowOperationError | NodeOperationError | NodeA
|
||||
|
||||
// Get used to gives nodes access to credentials
|
||||
export interface IGetCredentials {
|
||||
get(type: string, name: string): Promise<ICredentialsEncrypted>;
|
||||
get(type: string, id: string | null): Promise<ICredentialsEncrypted>;
|
||||
}
|
||||
|
||||
export abstract class ICredentials {
|
||||
id?: string;
|
||||
|
||||
name: string;
|
||||
|
||||
type: string;
|
||||
@@ -64,8 +66,15 @@ export abstract class ICredentials {
|
||||
|
||||
nodesAccess: ICredentialNodeAccess[];
|
||||
|
||||
constructor(name: string, type: string, nodesAccess: ICredentialNodeAccess[], data?: string) {
|
||||
this.name = name;
|
||||
constructor(
|
||||
nodeCredentials: INodeCredentialsDetails,
|
||||
type: string,
|
||||
nodesAccess: ICredentialNodeAccess[],
|
||||
data?: string,
|
||||
) {
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
this.id = nodeCredentials.id || undefined;
|
||||
this.name = nodeCredentials.name;
|
||||
this.type = type;
|
||||
this.nodesAccess = nodesAccess;
|
||||
this.data = data;
|
||||
@@ -93,6 +102,7 @@ export interface ICredentialNodeAccess {
|
||||
}
|
||||
|
||||
export interface ICredentialsDecrypted {
|
||||
id: string | number;
|
||||
name: string;
|
||||
type: string;
|
||||
nodesAccess: ICredentialNodeAccess[];
|
||||
@@ -100,6 +110,7 @@ export interface ICredentialsDecrypted {
|
||||
}
|
||||
|
||||
export interface ICredentialsEncrypted {
|
||||
id?: string | number;
|
||||
name: string;
|
||||
type: string;
|
||||
nodesAccess: ICredentialNodeAccess[];
|
||||
@@ -122,10 +133,13 @@ export abstract class ICredentialsHelper {
|
||||
this.encryptionKey = encryptionKey;
|
||||
}
|
||||
|
||||
abstract getCredentials(name: string, type: string): Promise<ICredentials>;
|
||||
abstract getCredentials(
|
||||
nodeCredentials: INodeCredentialsDetails,
|
||||
type: string,
|
||||
): Promise<ICredentials>;
|
||||
|
||||
abstract getDecrypted(
|
||||
name: string,
|
||||
nodeCredentials: INodeCredentialsDetails,
|
||||
type: string,
|
||||
mode: WorkflowExecuteMode,
|
||||
raw?: boolean,
|
||||
@@ -133,7 +147,7 @@ export abstract class ICredentialsHelper {
|
||||
): Promise<ICredentialDataDecryptedObject>;
|
||||
|
||||
abstract updateCredentials(
|
||||
name: string,
|
||||
nodeCredentials: INodeCredentialsDetails,
|
||||
type: string,
|
||||
data: ICredentialDataDecryptedObject,
|
||||
): Promise<void>;
|
||||
@@ -160,6 +174,7 @@ export interface ICredentialTypes {
|
||||
|
||||
// The way the credentials get saved in the database (data encrypted)
|
||||
export interface ICredentialData {
|
||||
id?: string;
|
||||
name: string;
|
||||
data: string; // Contains the access data as encrypted JSON string
|
||||
nodesAccess: ICredentialNodeAccess[];
|
||||
@@ -356,7 +371,7 @@ export interface IExecuteFunctions {
|
||||
outputIndex?: number,
|
||||
): Promise<INodeExecutionData[][]>;
|
||||
putExecutionToWait(waitTill: Date): Promise<void>;
|
||||
sendMessageToUI(message: any): void; // tslint:disable-line:no-any
|
||||
sendMessageToUI(message: any): void;
|
||||
helpers: {
|
||||
httpRequest(
|
||||
requestOptions: IHttpRequestOptions,
|
||||
@@ -529,8 +544,13 @@ export interface IWebhookFunctions {
|
||||
};
|
||||
}
|
||||
|
||||
export interface INodeCredentialsDetails {
|
||||
id: string | null;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface INodeCredentials {
|
||||
[key: string]: string;
|
||||
[key: string]: INodeCredentialsDetails;
|
||||
}
|
||||
|
||||
export interface INode {
|
||||
@@ -942,10 +962,8 @@ export interface IWorkflowBase {
|
||||
}
|
||||
|
||||
export interface IWorkflowCredentials {
|
||||
// Credential type
|
||||
[key: string]: {
|
||||
// Name
|
||||
[key: string]: ICredentialsEncrypted;
|
||||
[credentialType: string]: {
|
||||
[id: string]: ICredentialsEncrypted;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user