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,20 +1,8 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
INodeExecutionData,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
import {
connect,
copyInputItems,
destroy,
execute,
} from './GenericFunctions';
import { connect, copyInputItems, destroy, execute } from './GenericFunctions';
import snowflake from 'snowflake-sdk';
@@ -78,9 +66,7 @@ export class Snowflake implements INodeType {
},
displayOptions: {
show: {
operation: [
'executeQuery',
],
operation: ['executeQuery'],
},
},
default: '',
@@ -89,7 +75,6 @@ export class Snowflake implements INodeType {
description: 'The SQL query to execute',
},
// ----------------------------------
// insert
// ----------------------------------
@@ -99,9 +84,7 @@ export class Snowflake implements INodeType {
type: 'string',
displayOptions: {
show: {
operation: [
'insert',
],
operation: ['insert'],
},
},
default: '',
@@ -114,17 +97,15 @@ export class Snowflake implements INodeType {
type: 'string',
displayOptions: {
show: {
operation: [
'insert',
],
operation: ['insert'],
},
},
default: '',
placeholder: 'id,name,description',
description: 'Comma-separated list of the properties which should used as columns for the new rows',
description:
'Comma-separated list of the properties which should used as columns for the new rows',
},
// ----------------------------------
// update
// ----------------------------------
@@ -134,9 +115,7 @@ export class Snowflake implements INodeType {
type: 'string',
displayOptions: {
show: {
operation: [
'update',
],
operation: ['update'],
},
},
default: '',
@@ -149,15 +128,14 @@ export class Snowflake implements INodeType {
type: 'string',
displayOptions: {
show: {
operation: [
'update',
],
operation: ['update'],
},
},
default: 'id',
required: true,
// eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id
description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".',
description:
'Name of the property which decides which rows in the database should be updated. Normally that would be "id".',
},
{
displayName: 'Columns',
@@ -165,21 +143,21 @@ export class Snowflake implements INodeType {
type: 'string',
displayOptions: {
show: {
operation: [
'update',
],
operation: ['update'],
},
},
default: '',
placeholder: 'name,description',
description: 'Comma-separated list of the properties which should used as columns for rows to update',
description:
'Comma-separated list of the properties which should used as columns for rows to update',
},
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const credentials = await this.getCredentials('snowflake') as unknown as snowflake.ConnectionOptions;
const credentials = (await this.getCredentials(
'snowflake',
)) as unknown as snowflake.ConnectionOptions;
const returnData: IDataObject[] = [];
let responseData;
@@ -209,10 +187,12 @@ export class Snowflake implements INodeType {
const table = this.getNodeParameter('table', 0) as string;
const columnString = this.getNodeParameter('columns', 0) as string;
const columns = columnString.split(',').map(column => column.trim());
const query = `INSERT INTO ${table}(${columns.join(',')}) VALUES (${columns.map(column => '?').join(',')})`;
const columns = columnString.split(',').map((column) => column.trim());
const query = `INSERT INTO ${table}(${columns.join(',')}) VALUES (${columns
.map((column) => '?')
.join(',')})`;
const data = copyInputItems(items, columns);
const binds = data.map((element => Object.values(element)));
const binds = data.map((element) => Object.values(element));
await execute(connection, query, binds as unknown as snowflake.InsertBinds);
returnData.push.apply(returnData, data);
}
@@ -225,15 +205,17 @@ export class Snowflake implements INodeType {
const table = this.getNodeParameter('table', 0) as string;
const updateKey = this.getNodeParameter('updateKey', 0) as string;
const columnString = this.getNodeParameter('columns', 0) as string;
const columns = columnString.split(',').map(column => column.trim());
const columns = columnString.split(',').map((column) => column.trim());
if (!columns.includes(updateKey)) {
columns.unshift(updateKey);
}
const query = `UPDATE ${table} SET ${columns.map(column => `${column} = ?`).join(',')} WHERE ${updateKey} = ?;`;
const query = `UPDATE ${table} SET ${columns
.map((column) => `${column} = ?`)
.join(',')} WHERE ${updateKey} = ?;`;
const data = copyInputItems(items, columns);
const binds = data.map((element => Object.values(element).concat(element[updateKey])));
const binds = data.map((element) => Object.values(element).concat(element[updateKey]));
for (let i = 0; i < binds.length; i++) {
await execute(connection, query, binds[i] as unknown as snowflake.InsertBinds);
}