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

@@ -18,7 +18,6 @@ import {
WritingOptions,
} from 'xlsx';
/**
* Flattens an object with deep data
*
@@ -28,7 +27,7 @@ import {
function flattenObject(data: IDataObject) {
const returnData: IDataObject = {};
for (const key1 of Object.keys(data)) {
if (data[key1] !== null && (typeof data[key1]) === 'object') {
if (data[key1] !== null && typeof data[key1] === 'object') {
if (data[key1] instanceof Date) {
returnData[key1] = data[key1]?.toString();
continue;
@@ -47,7 +46,6 @@ function flattenObject(data: IDataObject) {
return returnData;
}
export class SpreadsheetFile implements INodeType {
description: INodeTypeDescription = {
displayName: 'Spreadsheet File',
@@ -96,14 +94,12 @@ export class SpreadsheetFile implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'fromFile',
],
operation: ['fromFile'],
},
},
placeholder: '',
description: 'Name of the binary property from which to read the binary data of the spreadsheet file',
description:
'Name of the binary property from which to read the binary data of the spreadsheet file',
},
// ----------------------------------
@@ -148,9 +144,7 @@ export class SpreadsheetFile implements INodeType {
default: 'xls',
displayOptions: {
show: {
operation: [
'toFile',
],
operation: ['toFile'],
},
},
description: 'The format of the file to save the data as',
@@ -163,13 +157,12 @@ export class SpreadsheetFile implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'toFile',
],
operation: ['toFile'],
},
},
placeholder: '',
description: 'Name of the binary property in which to save the binary data of the spreadsheet file',
description:
'Name of the binary property in which to save the binary data of the spreadsheet file',
},
{
@@ -185,13 +178,8 @@ export class SpreadsheetFile implements INodeType {
type: 'boolean',
displayOptions: {
show: {
'/operation': [
'toFile',
],
'/fileFormat': [
'xlsx',
'ods',
],
'/operation': ['toFile'],
'/fileFormat': ['xlsx', 'ods'],
},
},
default: false,
@@ -203,13 +191,12 @@ export class SpreadsheetFile implements INodeType {
type: 'string',
displayOptions: {
show: {
'/operation': [
'toFile',
],
'/operation': ['toFile'],
},
},
default: '',
description: 'File name to set in binary data. By default will "spreadsheet.<fileFormat>" be used.',
description:
'File name to set in binary data. By default will "spreadsheet.<fileFormat>" be used.',
},
{
displayName: 'Header Row',
@@ -217,10 +204,7 @@ export class SpreadsheetFile implements INodeType {
type: 'boolean',
displayOptions: {
show: {
'/operation': [
'fromFile',
'toFile',
],
'/operation': ['fromFile', 'toFile'],
},
},
default: true,
@@ -232,14 +216,13 @@ export class SpreadsheetFile implements INodeType {
type: 'boolean',
displayOptions: {
show: {
'/operation': [
'fromFile',
],
'/operation': ['fromFile'],
},
},
default: false,
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description: 'When reading from file the empty cells will be filled with an empty string in the JSON',
description:
'When reading from file the empty cells will be filled with an empty string in the JSON',
},
{
displayName: 'RAW Data',
@@ -247,9 +230,7 @@ export class SpreadsheetFile implements INodeType {
type: 'boolean',
displayOptions: {
show: {
'/operation': [
'fromFile',
],
'/operation': ['fromFile'],
},
},
default: false,
@@ -261,14 +242,13 @@ export class SpreadsheetFile implements INodeType {
type: 'boolean',
displayOptions: {
show: {
'/operation': [
'fromFile',
],
'/operation': ['fromFile'],
},
},
default: false,
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description: 'In some cases and file formats, it is necessary to read specifically as string else some special character get interpreted wrong',
description:
'In some cases and file formats, it is necessary to read specifically as string else some special character get interpreted wrong',
},
{
displayName: 'Range',
@@ -276,13 +256,12 @@ export class SpreadsheetFile implements INodeType {
type: 'string',
displayOptions: {
show: {
'/operation': [
'fromFile',
],
'/operation': ['fromFile'],
},
},
default: '',
description: 'The range to read from the table. If set to a number it will be the starting row. If set to string it will be used as A1-style bounded range.',
description:
'The range to read from the table. If set to a number it will be the starting row. If set to string it will be used as A1-style bounded range.',
},
{
displayName: 'Sheet Name',
@@ -290,13 +269,12 @@ export class SpreadsheetFile implements INodeType {
type: 'string',
displayOptions: {
show: {
'/operation': [
'fromFile',
],
'/operation': ['fromFile'],
},
},
default: 'Sheet',
description: 'Name of the sheet to read from in the spreadsheet (if supported). If not set, the first one gets chosen.',
description:
'Name of the sheet to read from in the spreadsheet (if supported). If not set, the first one gets chosen.',
},
{
displayName: 'Sheet Name',
@@ -304,14 +282,8 @@ export class SpreadsheetFile implements INodeType {
type: 'string',
displayOptions: {
show: {
'/operation': [
'toFile',
],
'/fileFormat': [
'ods',
'xls',
'xlsx',
],
'/operation': ['toFile'],
'/fileFormat': ['ods', 'xls', 'xlsx'],
},
},
default: 'Sheet',
@@ -322,9 +294,7 @@ export class SpreadsheetFile implements INodeType {
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const operation = this.getNodeParameter('operation', 0) as string;
@@ -336,8 +306,7 @@ export class SpreadsheetFile implements INodeType {
let item: INodeExecutionData;
for (let i = 0; i < items.length; i++) {
try{
try {
item = items[i];
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
@@ -352,19 +321,28 @@ export class SpreadsheetFile implements INodeType {
const binaryData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
let workbook;
if (options.readAsString === true) {
workbook = xlsxRead(binaryData.toString(), { type: 'string', raw: options.rawData as boolean });
workbook = xlsxRead(binaryData.toString(), {
type: 'string',
raw: options.rawData as boolean,
});
} else {
workbook = xlsxRead(binaryData, { raw: options.rawData as boolean });
}
if (workbook.SheetNames.length === 0) {
throw new NodeOperationError(this.getNode(), 'Spreadsheet does not have any sheets!', { itemIndex: i });
throw new NodeOperationError(this.getNode(), 'Spreadsheet does not have any sheets!', {
itemIndex: i,
});
}
let sheetName = workbook.SheetNames[0];
if (options.sheetName) {
if (!workbook.SheetNames.includes(options.sheetName as string)) {
throw new NodeOperationError(this.getNode(), `Spreadsheet does not contain sheet called "${options.sheetName}"!`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`Spreadsheet does not contain sheet called "${options.sheetName}"!`,
{ itemIndex: i },
);
}
sheetName = options.sheetName as string;
}
@@ -416,7 +394,6 @@ export class SpreadsheetFile implements INodeType {
} as INodeExecutionData);
}
}
} catch (error) {
if (this.continueOnFail()) {
newItems.push({
@@ -436,7 +413,6 @@ export class SpreadsheetFile implements INodeType {
return this.prepareOutputData(newItems);
} else if (operation === 'toFile') {
try {
// Write the workflow data to spreadsheet file
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
const fileFormat = this.getNodeParameter('fileFormat', 0) as string;
@@ -481,7 +457,7 @@ export class SpreadsheetFile implements INodeType {
}
// Convert the data in the correct format
const sheetName = options.sheetName as string || 'Sheet';
const sheetName = (options.sheetName as string) || 'Sheet';
const wb: WorkBook = {
SheetNames: [sheetName],
Sheets: {
@@ -523,9 +499,14 @@ export class SpreadsheetFile implements INodeType {
}
} else {
if (this.continueOnFail()) {
return this.prepareOutputData([{json:{ error: `The operation "${operation}" is not supported!` }}]);
}else{
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
return this.prepareOutputData([
{ json: { error: `The operation "${operation}" is not supported!` } },
]);
} else {
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
);
}
}
return this.prepareOutputData(newItems);