mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Remove linting exceptions in nodes-base (#4794)
* ⚡ enabled array-type * ⚡ await-thenable on * ⚡ ban-types on * ⚡ default-param-last on * ⚡ dot-notation on * ⚡ member-delimiter-style on * ⚡ no-duplicate-imports on * ⚡ no-empty-interface on * ⚡ no-floating-promises on * ⚡ no-for-in-array on * ⚡ no-invalid-void-type on * ⚡ no-loop-func on * ⚡ no-shadow on * ⚡ ban-ts-comment re enabled * ⚡ @typescript-eslint/lines-between-class-members on * address my own comment * @typescript-eslint/return-await on * @typescript-eslint/promise-function-async on * @typescript-eslint/no-unnecessary-boolean-literal-compare on * @typescript-eslint/no-unnecessary-type-assertion on * prefer-const on * @typescript-eslint/prefer-optional-chain on Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IBinaryData,
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
@@ -688,9 +687,9 @@ export class HttpRequestV2 implements INodeType {
|
||||
const requestPromises = [];
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
const requestMethod = this.getNodeParameter('requestMethod', itemIndex) as string;
|
||||
const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex) as boolean;
|
||||
const parametersAreJson = this.getNodeParameter('jsonParameters', itemIndex);
|
||||
|
||||
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||
const options = this.getNodeParameter('options', itemIndex, {});
|
||||
const url = this.getNodeParameter('url', itemIndex) as string;
|
||||
|
||||
if (
|
||||
@@ -706,21 +705,17 @@ export class HttpRequestV2 implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
const fullResponse = !!options.fullResponse as boolean;
|
||||
const fullResponse = !!options.fullResponse;
|
||||
|
||||
requestOptions = {
|
||||
headers: {},
|
||||
method: requestMethod,
|
||||
uri: url,
|
||||
gzip: true,
|
||||
rejectUnauthorized: !this.getNodeParameter(
|
||||
'allowUnauthorizedCerts',
|
||||
itemIndex,
|
||||
false,
|
||||
) as boolean,
|
||||
rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false),
|
||||
};
|
||||
|
||||
if (fullResponse === true) {
|
||||
if (fullResponse) {
|
||||
// @ts-ignore
|
||||
requestOptions.resolveWithFullResponse = true;
|
||||
}
|
||||
@@ -750,11 +745,11 @@ export class HttpRequestV2 implements INodeType {
|
||||
requestOptions.useQuerystring = true;
|
||||
}
|
||||
|
||||
if (parametersAreJson === true) {
|
||||
if (parametersAreJson) {
|
||||
// Parameters are defined as JSON
|
||||
let optionData: OptionData;
|
||||
for (const parameterName of Object.keys(jsonParameters)) {
|
||||
optionData = jsonParameters[parameterName] as OptionData;
|
||||
optionData = jsonParameters[parameterName];
|
||||
const tempValue = this.getNodeParameter(parameterName, itemIndex, '') as string | object;
|
||||
const sendBinaryData = this.getNodeParameter(
|
||||
'sendBinaryData',
|
||||
@@ -762,8 +757,8 @@ export class HttpRequestV2 implements INodeType {
|
||||
false,
|
||||
) as boolean;
|
||||
|
||||
if (optionData.name === 'body' && parametersAreJson === true) {
|
||||
if (sendBinaryData === true) {
|
||||
if (optionData.name === 'body' && parametersAreJson) {
|
||||
if (sendBinaryData) {
|
||||
const contentTypesAllowed = ['raw', 'multipart-form-data'];
|
||||
|
||||
if (!contentTypesAllowed.includes(options.bodyContentType as string)) {
|
||||
@@ -834,7 +829,7 @@ export class HttpRequestV2 implements INodeType {
|
||||
);
|
||||
}
|
||||
|
||||
const binaryProperty = item.binary[binaryPropertyName] as IBinaryData;
|
||||
const binaryProperty = item.binary[binaryPropertyName];
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
||||
itemIndex,
|
||||
binaryPropertyName,
|
||||
@@ -889,8 +884,8 @@ export class HttpRequestV2 implements INodeType {
|
||||
// @ts-ignore
|
||||
requestOptions[optionName] = {};
|
||||
for (const parameterData of setUiParameter!.parameter as IDataObject[]) {
|
||||
const parameterDataName = parameterData!.name as string;
|
||||
const newValue = parameterData!.value;
|
||||
const parameterDataName = parameterData.name as string;
|
||||
const newValue = parameterData.value;
|
||||
if (optionName === 'qs') {
|
||||
const computeNewValue = (oldValue: unknown) => {
|
||||
if (typeof oldValue === 'string') {
|
||||
@@ -967,7 +962,7 @@ export class HttpRequestV2 implements INodeType {
|
||||
if (!requestOptions.qs) {
|
||||
requestOptions.qs = {};
|
||||
}
|
||||
requestOptions.qs![httpQueryAuth.name as string] = httpQueryAuth.value;
|
||||
requestOptions.qs[httpQueryAuth.name as string] = httpQueryAuth.value;
|
||||
}
|
||||
if (httpDigestAuth !== undefined) {
|
||||
requestOptions.auth = {
|
||||
@@ -977,14 +972,14 @@ export class HttpRequestV2 implements INodeType {
|
||||
};
|
||||
}
|
||||
|
||||
if (requestOptions.headers!['accept'] === undefined) {
|
||||
if (requestOptions.headers!.accept === undefined) {
|
||||
if (responseFormat === 'json') {
|
||||
requestOptions.headers!['accept'] = 'application/json,text/*;q=0.99';
|
||||
requestOptions.headers!.accept = 'application/json,text/*;q=0.99';
|
||||
} else if (responseFormat === 'string') {
|
||||
requestOptions.headers!['accept'] =
|
||||
requestOptions.headers!.accept =
|
||||
'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1';
|
||||
} else {
|
||||
requestOptions.headers!['accept'] =
|
||||
requestOptions.headers!.accept =
|
||||
'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7';
|
||||
}
|
||||
}
|
||||
@@ -1042,7 +1037,7 @@ export class HttpRequestV2 implements INodeType {
|
||||
response = promisesResponses.shift();
|
||||
|
||||
if (response!.status !== 'fulfilled') {
|
||||
if (this.continueOnFail() !== true) {
|
||||
if (!this.continueOnFail()) {
|
||||
// throw error;
|
||||
throw new NodeApiError(this.getNode(), response);
|
||||
} else {
|
||||
@@ -1061,10 +1056,10 @@ export class HttpRequestV2 implements INodeType {
|
||||
|
||||
response = response.value;
|
||||
|
||||
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||
const options = this.getNodeParameter('options', itemIndex, {});
|
||||
const url = this.getNodeParameter('url', itemIndex) as string;
|
||||
|
||||
const fullResponse = !!options.fullResponse as boolean;
|
||||
const fullResponse = !!options.fullResponse;
|
||||
|
||||
if (responseFormat === 'file') {
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string;
|
||||
@@ -1087,7 +1082,7 @@ export class HttpRequestV2 implements INodeType {
|
||||
|
||||
const fileName = url.split('/').pop();
|
||||
|
||||
if (fullResponse === true) {
|
||||
if (fullResponse) {
|
||||
const returnItem: IDataObject = {};
|
||||
for (const property of fullReponseProperties) {
|
||||
if (property === 'body') {
|
||||
@@ -1115,7 +1110,7 @@ export class HttpRequestV2 implements INodeType {
|
||||
} else if (responseFormat === 'string') {
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string;
|
||||
|
||||
if (fullResponse === true) {
|
||||
if (fullResponse) {
|
||||
const returnItem: IDataObject = {};
|
||||
for (const property of fullReponseProperties) {
|
||||
if (property === 'body') {
|
||||
@@ -1143,7 +1138,7 @@ export class HttpRequestV2 implements INodeType {
|
||||
}
|
||||
} else {
|
||||
// responseFormat: 'json'
|
||||
if (fullResponse === true) {
|
||||
if (fullResponse) {
|
||||
const returnItem: IDataObject = {};
|
||||
for (const property of fullReponseProperties) {
|
||||
returnItem[property] = response![property];
|
||||
@@ -1181,6 +1176,7 @@ export class HttpRequestV2 implements INodeType {
|
||||
}
|
||||
|
||||
if (options.splitIntoItems === true && Array.isArray(response)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
||||
response.forEach((item) =>
|
||||
returnItems.push({
|
||||
json: item,
|
||||
|
||||
Reference in New Issue
Block a user