fix(core): Remove linting exceptions in nodes-base, @typescript-eslint/no-unsafe-argument (no-changelog)

This commit is contained in:
Michael Kret
2023-02-28 05:39:43 +02:00
committed by GitHub
parent 3172ea376e
commit bb4db58819
560 changed files with 2227 additions and 1919 deletions

View File

@@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request';
import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
import type { IDataObject, INodePropertyOptions } from 'n8n-workflow';
import type { IDataObject, INodePropertyOptions, JsonObject } from 'n8n-workflow';
import { LoggerProxy as Logger, NodeApiError } from 'n8n-workflow';
import moment from 'moment-timezone';
@@ -29,11 +29,10 @@ function getOptions(
json: true,
};
if (!Object.keys(options.body).length) {
if (!Object.keys(options.body as IDataObject).length) {
delete options.body;
}
//@ts-ignore
return options;
}
@@ -130,11 +129,11 @@ export async function salesforceApiRequest(
`Authentication for "Salesforce" node is using "OAuth2". Invoking URI ${options.uri}`,
);
Object.assign(options, option);
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, credentialsType, options);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
@@ -155,7 +154,7 @@ export async function salesforceApiRequestAllItems(
do {
responseData = await salesforceApiRequest.call(this, method, endpoint, body, query, uri);
uri = `${endpoint}/${responseData.nextRecordsUrl?.split('/')?.pop()}`;
returnData.push.apply(returnData, responseData[propertyName]);
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
} while (responseData.nextRecordsUrl !== undefined && responseData.nextRecordsUrl !== null);
return returnData;
@@ -178,7 +177,7 @@ export function sortOptions(options: INodePropertyOptions[]): void {
}
export function getValue(value: any) {
if (moment(value).isValid()) {
if (moment(value as string).isValid()) {
return value;
} else if (typeof value === 'string') {
return `'${value}'`;

View File

@@ -7,6 +7,7 @@ import type {
INodePropertyOptions,
INodeType,
INodeTypeDescription,
JsonObject,
} from 'n8n-workflow';
import { LoggerProxy as Logger, NodeApiError, NodeOperationError } from 'n8n-workflow';
@@ -1158,8 +1159,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -1271,8 +1271,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -1316,7 +1315,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Lead/delete-lead-id
@@ -1329,7 +1328,7 @@ export class Salesforce implements INodeType {
`/sobjects/lead/${leadId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Lead/get-lead
@@ -1482,8 +1481,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -1613,8 +1611,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -1662,7 +1659,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Contact/delete-contact-id
@@ -1675,7 +1672,7 @@ export class Salesforce implements INodeType {
`/sobjects/contact/${contactId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Contact/get-contact
@@ -1733,8 +1730,7 @@ export class Salesforce implements INodeType {
const customFields = customFieldsUi.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -1767,8 +1763,7 @@ export class Salesforce implements INodeType {
const customFields = customFieldsUi.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -1816,7 +1811,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
if (operation === 'delete') {
@@ -1829,7 +1824,7 @@ export class Salesforce implements INodeType {
`/sobjects/${customObject}/${recordId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
}
@@ -1942,8 +1937,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -2012,8 +2006,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -2061,7 +2054,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Opportunity/delete-opportunity-id
@@ -2074,7 +2067,7 @@ export class Salesforce implements INodeType {
`/sobjects/opportunity/${opportunityId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Opportunity/get-opportunity
@@ -2193,8 +2186,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -2302,8 +2294,7 @@ export class Salesforce implements INodeType {
.customFieldsValues as IDataObject[];
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -2351,7 +2342,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Account/delete-account-id
@@ -2364,7 +2355,7 @@ export class Salesforce implements INodeType {
`/sobjects/account/${accountId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Account/get-account
@@ -2454,7 +2445,7 @@ export class Salesforce implements INodeType {
if (customFields) {
for (const customField of customFields) {
//@ts-ignore
body[customField.fieldId] = customField.value;
body[customField.fieldId as string] = customField.value;
}
}
}
@@ -2566,7 +2557,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Case/delete-case-id
@@ -2579,7 +2570,7 @@ export class Salesforce implements INodeType {
`/sobjects/case/${caseId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Case/get-case
@@ -2829,7 +2820,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Task/delete-task-id
@@ -2842,7 +2833,7 @@ export class Salesforce implements INodeType {
`/sobjects/task/${taskId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Task/get-task
@@ -2961,7 +2952,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Attachment/delete-attachment-id
@@ -2974,7 +2965,7 @@ export class Salesforce implements INodeType {
`/sobjects/attachment/${attachmentId}`,
);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
//https://developer.salesforce.com/docs/api-explorer/sobject/Attachment/get-attachment-id
@@ -3016,7 +3007,7 @@ export class Salesforce implements INodeType {
);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
}
@@ -3084,7 +3075,7 @@ export class Salesforce implements INodeType {
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
this.helpers.returnJsonArray(responseData as IDataObject[]),
{ itemData: { item: i } },
);