refactor: Format nodes-base package (A-F) (#3800)

* 🔨 prettier formated nodes - A

* 🔨 prettier formated nodes - B

*  prettier formated nodes - C

*  prettier formated nodes - D

*  prettier formated nodes - E-F

* 🎨 Adjust nodes-base formatting command (#3805)

* Format additional files in nodes A-F (#3811)

*  fixes

* 🎨 Add Mindee to ignored dirs

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Michael Kret
2022-08-01 23:47:55 +03:00
committed by GitHub
parent 2c17e6f3ca
commit 0ecbb4a19d
411 changed files with 12906 additions and 20148 deletions

View File

@@ -1,23 +1,12 @@
import {
URL,
} from 'url';
import { URL } from 'url';
import {
Request,
sign,
} from 'aws4';
import { Request, sign } from 'aws4';
import {
get,
} from 'lodash';
import { get } from 'lodash';
import {
OptionsWithUri,
} from 'request';
import { OptionsWithUri } from 'request';
import {
parseString,
} from 'xml2js';
import { parseString } from 'xml2js';
import {
IExecuteFunctions,
@@ -26,27 +15,39 @@ import {
IWebhookFunctions,
} from 'n8n-core';
import {
IDataObject,
NodeApiError,
NodeOperationError,
} from 'n8n-workflow';
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
import {
pascalCase,
} from 'change-case';
import { pascalCase } from 'change-case';
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer | IDataObject, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
export async function awsApiRequest(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
service: string,
method: string,
path: string,
body?: string | Buffer | IDataObject,
query: IDataObject = {},
headers?: object,
option: IDataObject = {},
region?: string,
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = await this.getCredentials('aws');
const endpoint = new URL(((credentials.rekognitionEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
const endpoint = new URL(
(((credentials.rekognitionEndpoint as string) || '').replace(
'{region}',
credentials.region as string,
) || `https://${service}.${credentials.region}.amazonaws.com`) + path,
);
// Sign AWS API request with the user credentials
const signOpts = {headers: headers || {}, host: endpoint.host, method, path, body} as Request;
const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request;
const securityHeaders = {
accessKeyId: `${credentials.accessKeyId}`.trim(),
secretAccessKey: `${credentials.secretAccessKey}`.trim(),
sessionToken: credentials.temporaryCredentials ? `${credentials.sessionToken}`.trim() : undefined,
sessionToken: credentials.temporaryCredentials
? `${credentials.sessionToken}`.trim()
: undefined,
};
sign(signOpts, securityHeaders);
@@ -68,8 +69,29 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
}
}
export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, query: IDataObject = {}, headers?: object, options: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
const response = await awsApiRequest.call(this, service, method, path, body, query, headers, options, region);
export async function awsApiRequestREST(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
service: string,
method: string,
path: string,
body?: string,
query: IDataObject = {},
headers?: object,
options: IDataObject = {},
region?: string,
// tslint:disable-next-line:no-any
): Promise<any> {
const response = await awsApiRequest.call(
this,
service,
method,
path,
body,
query,
headers,
options,
region,
);
try {
return JSON.parse(response);
} catch (error) {
@@ -77,8 +99,29 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions
}
}
export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer | IDataObject, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
const response = await awsApiRequest.call(this, service, method, path, body, query, headers, option, region);
export async function awsApiRequestSOAP(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
service: string,
method: string,
path: string,
body?: string | Buffer | IDataObject,
query: IDataObject = {},
headers?: object,
option: IDataObject = {},
region?: string,
// tslint:disable-next-line:no-any
): Promise<any> {
const response = await awsApiRequest.call(
this,
service,
method,
path,
body,
query,
headers,
option,
region,
);
try {
return await new Promise((resolve, reject) => {
parseString(response, { explicitArray: false }, (err, data) => {
@@ -93,18 +136,42 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions
}
}
export async function awsApiRequestSOAPAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, method: string, path: string, body?: string, query: IDataObject = {}, headers: IDataObject = {}, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
export async function awsApiRequestSOAPAllItems(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
propertyName: string,
service: string,
method: string,
path: string,
body?: string,
query: IDataObject = {},
headers: IDataObject = {},
option: IDataObject = {},
region?: string,
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
do {
responseData = await awsApiRequestSOAP.call(this, service, method, path, body, query, headers, option, region);
responseData = await awsApiRequestSOAP.call(
this,
service,
method,
path,
body,
query,
headers,
option,
region,
);
//https://forums.aws.amazon.com/thread.jspa?threadID=55746
if (get(responseData, `${propertyName.split('.')[0]}.NextContinuationToken`)) {
query['continuation-token'] = get(responseData, `${propertyName.split('.')[0]}.NextContinuationToken`);
query['continuation-token'] = get(
responseData,
`${propertyName.split('.')[0]}.NextContinuationToken`,
);
}
if (get(responseData, propertyName)) {
if (Array.isArray(get(responseData, propertyName))) {
@@ -125,7 +192,9 @@ export async function awsApiRequestSOAPAllItems(this: IHookFunctions | IExecuteF
}
function queryToString(params: IDataObject) {
return Object.keys(params).map(key => key + '=' + params[key]).join('&');
return Object.keys(params)
.map((key) => key + '=' + params[key])
.join('&');
}
export function keysTPascalCase(object: IDataObject) {