🎨 Centralize error throwing for encryption keys and credentials (#3105)

* Centralized error throwing for encryption key

* Unifying the error message used by cli and core packages

* Improvements to error messages to make it more DRY

* Removed unnecessary throw

* Throwing error when credential does not exist to simplify node behavior (#3112)

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Omar Ajoue
2022-04-15 08:00:47 +02:00
committed by GitHub
parent 17b0cd8f76
commit d3fecb9f6d
227 changed files with 348 additions and 848 deletions

View File

@@ -12,7 +12,7 @@ import {
NodeApiError,
} from 'n8n-workflow';
import {
import {
IContactUpdate,
} from './ContactInterface';
@@ -31,11 +31,11 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
'Accept': 'application/json',
},
auth: {
username: credentials!.email as string,
password: credentials!.apiKey as string,
username: credentials.email as string,
password: credentials.apiKey as string,
},
qs: query,
uri: uri || `https://${credentials!.subdomain}.agilecrm.com/dev/${endpoint}`,
uri: uri || `https://${credentials.subdomain}.agilecrm.com/dev/${endpoint}`,
json: true,
};
@@ -83,7 +83,7 @@ export async function agileCrmApiRequestAllItems(this: IHookFunctions | ILoadOpt
export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('agileCrmApi');
const baseUri = `https://${credentials!.subdomain}.agilecrm.com/dev/`;
const baseUri = `https://${credentials.subdomain}.agilecrm.com/dev/`;
const options: OptionsWithUri = {
method,
headers: {
@@ -91,8 +91,8 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
},
body: { id: body.id },
auth: {
username: credentials!.email as string,
password: credentials!.apiKey as string,
username: credentials.email as string,
password: credentials.apiKey as string,
},
uri: uri || baseUri,
json: true,