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

@@ -7,7 +7,7 @@ import type {
ILoadOptionsFunctions,
} from 'n8n-core';
import type { IDataObject } from 'n8n-workflow';
import type { IDataObject, JsonObject } from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
import { createHmac } from 'crypto';
@@ -18,12 +18,11 @@ export async function unleashedApiRequest(
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
method: string,
path: string,
body: any = {},
body: IDataObject = {},
query: IDataObject = {},
pageNumber?: number,
headers?: object,
): Promise<any> {
) {
const paginatedPath = pageNumber ? `/${path}/${pageNumber}` : `/${path}`;
const options: OptionsWithUrl = {
@@ -56,7 +55,7 @@ export async function unleashedApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
@@ -65,10 +64,9 @@ export async function unleashedApiRequestAllItems(
propertyName: string,
method: string,
endpoint: string,
body: any = {},
body: IDataObject = {},
query: IDataObject = {},
): Promise<any> {
) {
const returnData: IDataObject[] = [];
let responseData;
let pageNumber = 1;
@@ -77,7 +75,7 @@ export async function unleashedApiRequestAllItems(
do {
responseData = await unleashedApiRequest.call(this, method, endpoint, body, query, pageNumber);
returnData.push.apply(returnData, responseData[propertyName]);
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
pageNumber++;
} while (
(responseData.Pagination.PageNumber as number) <
@@ -101,7 +99,7 @@ export function convertNETDates(item: { [key: string]: any }) {
}
}
if (type === 'object' && item[path]) {
convertNETDates(item[path]);
convertNETDates(item[path] as IDataObject);
}
});
}

View File

@@ -71,7 +71,7 @@ export class UnleashedSoftware implements INodeType {
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
let responseData: IDataObject | IDataObject[] = [];
for (let i = 0; i < length; i++) {
const resource = this.getNodeParameter('resource', 0);
@@ -113,8 +113,15 @@ export class UnleashedSoftware implements INodeType {
} else {
const limit = this.getNodeParameter('limit', i);
qs.pageSize = limit;
responseData = await unleashedApiRequest.call(this, 'GET', '/SalesOrders', {}, qs, 1);
responseData = responseData.Items;
responseData = (await unleashedApiRequest.call(
this,
'GET',
'/SalesOrders',
{},
qs,
1,
)) as IDataObject;
responseData = responseData.Items as IDataObject[];
}
convertNETDates(responseData);
responseData = this.helpers.constructExecutionMetaData(
@@ -157,8 +164,15 @@ export class UnleashedSoftware implements INodeType {
} else {
const limit = this.getNodeParameter('limit', i);
qs.pageSize = limit;
responseData = await unleashedApiRequest.call(this, 'GET', '/StockOnHand', {}, qs, 1);
responseData = responseData.Items;
responseData = (await unleashedApiRequest.call(
this,
'GET',
'/StockOnHand',
{},
qs,
1,
)) as IDataObject;
responseData = responseData.Items as IDataObject[];
}
convertNETDates(responseData);