n8n-3867-progressively-apply-prettier-to-all (#3873)

* 🔨 formatting nodes with prettier
This commit is contained in:
Michael Kret
2022-08-17 18:50:24 +03:00
committed by GitHub
parent f2d326c7f0
commit 91d7e16c81
1072 changed files with 42357 additions and 59109 deletions

View File

@@ -1,7 +1,4 @@
import {
OptionsWithUrl,
} from 'request';
import { OptionsWithUrl } from 'request';
import {
IExecuteFunctions,
@@ -10,23 +7,28 @@ import {
ILoadOptionsFunctions,
} from 'n8n-core';
import {
IDataObject, NodeApiError, NodeOperationError,
} from 'n8n-workflow';
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
import {
createHmac,
} from 'crypto';
import { createHmac } from 'crypto';
import qs from 'qs';
export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, query: IDataObject = {}, pageNumber?: number, headers?: object): Promise<any> { // tslint:disable-line:no-any
export async function unleashedApiRequest(
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
method: string,
path: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
pageNumber?: number,
headers?: object,
// tslint:disable-next-line:no-any
): Promise<any> {
const paginatedPath = pageNumber ? `/${path}/${pageNumber}` : `/${path}`;
const options: OptionsWithUrl = {
headers: {
'Accept': 'application/json',
Accept: 'application/json',
'Content-Type': 'application/json',
},
method,
@@ -42,7 +44,7 @@ export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctio
const credentials = await this.getCredentials('unleashedSoftwareApi');
const signature = createHmac('sha256', (credentials.apiKey as string))
const signature = createHmac('sha256', credentials.apiKey as string)
.update(qs.stringify(query))
.digest('base64');
@@ -58,8 +60,16 @@ export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctio
}
}
export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function unleashedApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions,
propertyName: string,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
let pageNumber = 1;
@@ -70,9 +80,9 @@ export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoa
responseData = await unleashedApiRequest.call(this, method, endpoint, body, query, pageNumber);
returnData.push.apply(returnData, responseData[propertyName]);
pageNumber++;
} while (
(responseData.Pagination.PageNumber as number) < (responseData.Pagination.NumberOfPages as number)
(responseData.Pagination.PageNumber as number) <
(responseData.Pagination.NumberOfPages as number)
);
return returnData;
}
@@ -80,8 +90,9 @@ export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoa
//.NET code is serializing dates in the following format: "/Date(1586833770780)/"
//which is useless on JS side and could not treated as a date for other nodes
//so we need to convert all of the fields that has it.
export function convertNETDates(item: { [key: string]: any }) { // tslint:disable-line:no-any
Object.keys(item).forEach(path => {
// tslint:disable-next-line:no-any
export function convertNETDates(item: { [key: string]: any }) {
Object.keys(item).forEach((path) => {
const type = typeof item[path] as string;
if (type === 'string') {
const value = item[path] as string;
@@ -89,7 +100,8 @@ export function convertNETDates(item: { [key: string]: any }) { // tslint:disabl
if (a) {
item[path] = new Date(+a[1]);
}
} if (type === 'object' && item[path]) {
}
if (type === 'object' && item[path]) {
convertNETDates(item[path]);
}
});