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,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
@@ -10,10 +8,7 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
nasaApiRequest,
nasaApiRequestAllItems,
} from './GenericFunctions';
import { nasaApiRequest, nasaApiRequestAllItems } from './GenericFunctions';
import moment from 'moment';
@@ -125,9 +120,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'astronomyPictureOfTheDay',
],
resource: ['astronomyPictureOfTheDay'],
},
},
options: [
@@ -147,16 +140,15 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'asteroidNeoFeed',
],
resource: ['asteroidNeoFeed'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Retrieve a list of asteroids based on their closest approach date to Earth',
description:
'Retrieve a list of asteroids based on their closest approach date to Earth',
action: 'Get an asteroid neo feed',
},
],
@@ -169,9 +161,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'asteroidNeoLookup',
],
resource: ['asteroidNeoLookup'],
},
},
options: [
@@ -191,9 +181,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'asteroidNeoBrowse',
],
resource: ['asteroidNeoBrowse'],
},
},
options: [
@@ -213,9 +201,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiCoronalMassEjection',
],
resource: ['donkiCoronalMassEjection'],
},
},
options: [
@@ -235,9 +221,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiGeomagneticStorm',
],
resource: ['donkiGeomagneticStorm'],
},
},
options: [
@@ -257,9 +241,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiInterplanetaryShock',
],
resource: ['donkiInterplanetaryShock'],
},
},
options: [
@@ -279,9 +261,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiSolarFlare',
],
resource: ['donkiSolarFlare'],
},
},
options: [
@@ -301,9 +281,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiSolarEnergeticParticle',
],
resource: ['donkiSolarEnergeticParticle'],
},
},
options: [
@@ -323,9 +301,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiMagnetopauseCrossing',
],
resource: ['donkiMagnetopauseCrossing'],
},
},
options: [
@@ -345,9 +321,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiRadiationBeltEnhancement',
],
resource: ['donkiRadiationBeltEnhancement'],
},
},
options: [
@@ -367,9 +341,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiHighSpeedStream',
],
resource: ['donkiHighSpeedStream'],
},
},
options: [
@@ -389,9 +361,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiWsaEnlilSimulation',
],
resource: ['donkiWsaEnlilSimulation'],
},
},
options: [
@@ -411,9 +381,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'donkiNotifications',
],
resource: ['donkiNotifications'],
},
},
options: [
@@ -433,9 +401,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'earthImagery',
],
resource: ['earthImagery'],
},
},
options: [
@@ -455,9 +421,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'earthAssets',
],
resource: ['earthAssets'],
},
},
options: [
@@ -477,9 +441,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'inSightMarsWeatherService',
],
resource: ['inSightMarsWeatherService'],
},
},
options: [
@@ -499,9 +461,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'imageAndVideoLibrary',
],
resource: ['imageAndVideoLibrary'],
},
},
options: [
@@ -521,9 +481,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'techTransfer',
],
resource: ['techTransfer'],
},
},
options: [
@@ -543,9 +501,7 @@ export class Nasa implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'twoLineElementSet',
],
resource: ['twoLineElementSet'],
},
},
options: [
@@ -574,12 +530,8 @@ export class Nasa implements INodeType {
description: 'The ID of the asteroid to be returned',
displayOptions: {
show: {
resource: [
'asteroidNeoLookup',
],
operation: [
'get',
],
resource: ['asteroidNeoLookup'],
operation: ['get'],
},
},
},
@@ -591,12 +543,8 @@ export class Nasa implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'asteroidNeoLookup',
],
operation: [
'get',
],
resource: ['asteroidNeoLookup'],
operation: ['get'],
},
},
options: [
@@ -615,14 +563,13 @@ export class Nasa implements INodeType {
type: 'boolean',
displayOptions: {
show: {
resource: [
'astronomyPictureOfTheDay',
],
resource: ['astronomyPictureOfTheDay'],
},
},
default: true,
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description: 'By default just the URL of the image is returned. When set to true the image will be downloaded.',
description:
'By default just the URL of the image is returned. When set to true the image will be downloaded.',
},
{
displayName: 'Binary Property',
@@ -632,15 +579,9 @@ export class Nasa implements INodeType {
default: 'data',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'astronomyPictureOfTheDay',
],
download: [
true,
],
operation: ['get'],
resource: ['astronomyPictureOfTheDay'],
download: [true],
},
},
description: 'Name of the binary property to which to write to',
@@ -655,12 +596,8 @@ export class Nasa implements INodeType {
placeholder: 'Add field',
displayOptions: {
show: {
resource: [
'astronomyPictureOfTheDay',
],
operation: [
'get',
],
resource: ['astronomyPictureOfTheDay'],
operation: ['get'],
},
},
options: [
@@ -674,7 +611,6 @@ export class Nasa implements INodeType {
],
},
/* startDate and endDate for various resources */
{
displayName: 'Additional Fields',
@@ -696,9 +632,7 @@ export class Nasa implements INodeType {
'donkiWsaEnlilSimulation',
'donkiNotifications',
],
operation: [
'get',
],
operation: ['get'],
},
},
options: [
@@ -732,12 +666,8 @@ export class Nasa implements INodeType {
placeholder: 'Add field',
displayOptions: {
show: {
resource: [
'donkiInterplanetaryShock',
],
operation: [
'get',
],
resource: ['donkiInterplanetaryShock'],
operation: ['get'],
},
},
options: [
@@ -818,13 +748,8 @@ export class Nasa implements INodeType {
description: 'Latitude for the location of the image',
displayOptions: {
show: {
resource: [
'earthImagery',
'earthAssets',
],
operation: [
'get',
],
resource: ['earthImagery', 'earthAssets'],
operation: ['get'],
},
},
},
@@ -837,13 +762,8 @@ export class Nasa implements INodeType {
description: 'Longitude for the location of the image',
displayOptions: {
show: {
resource: [
'earthImagery',
'earthAssets',
],
operation: [
'get',
],
resource: ['earthImagery', 'earthAssets'],
operation: ['get'],
},
},
},
@@ -855,18 +775,13 @@ export class Nasa implements INodeType {
default: 'data',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'earthImagery',
],
operation: ['get'],
resource: ['earthImagery'],
},
},
description: 'Name of the binary property to which to write to',
},
//aqui
{
displayName: 'Additional Fields',
@@ -876,13 +791,8 @@ export class Nasa implements INodeType {
placeholder: 'Add field',
displayOptions: {
show: {
resource: [
'earthImagery',
'earthAssets',
],
operation: [
'get',
],
resource: ['earthImagery', 'earthAssets'],
operation: ['get'],
},
},
options: [
@@ -911,9 +821,7 @@ export class Nasa implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'getAll',
],
operation: ['getAll'],
},
},
default: false,
@@ -930,19 +838,14 @@ export class Nasa implements INodeType {
default: 20,
displayOptions: {
show: {
operation: [
'getAll',
],
returnAll: [
false,
],
operation: ['getAll'],
returnAll: [false],
},
},
},
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
@@ -957,7 +860,6 @@ export class Nasa implements INodeType {
let download = false;
for (let i = 0; i < items.length; i++) {
try {
let endpoint = '';
let includeCloseApproachData = false;
@@ -973,49 +875,45 @@ export class Nasa implements INodeType {
}
if (resource === 'astronomyPictureOfTheDay') {
if (operation === 'get') {
endpoint = '/planetary/apod';
qs.date = moment(additionalFields.date as string).format('YYYY-MM-DD') || moment().format('YYYY-MM-DD');
qs.date =
moment(additionalFields.date as string).format('YYYY-MM-DD') ||
moment().format('YYYY-MM-DD');
}
}
if (resource === 'asteroidNeoFeed') {
if (operation === 'get') {
endpoint = '/neo/rest/v1/feed';
propertyName = 'near_earth_objects';
// The range defaults to the current date to reduce the number of results.
const currentDate = moment().format('YYYY-MM-DD');
qs.start_date = moment(additionalFields.startDate as string).format('YYYY-MM-DD') || currentDate;
qs.end_date = moment(additionalFields.endDate as string).format('YYYY-MM-DD') || currentDate;
qs.start_date =
moment(additionalFields.startDate as string).format('YYYY-MM-DD') || currentDate;
qs.end_date =
moment(additionalFields.endDate as string).format('YYYY-MM-DD') || currentDate;
}
}
if (resource === 'asteroidNeoLookup') {
if (operation === 'get') {
const asteroidId = this.getNodeParameter('asteroidId', i) as IDataObject;
includeCloseApproachData = additionalFields.includeCloseApproachData as boolean;
endpoint = `/neo/rest/v1/neo/${asteroidId}`;
} else {
throw new NodeOperationError(this.getNode(), `The operation '${operation}' is unknown!`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`The operation '${operation}' is unknown!`,
{ itemIndex: i },
);
}
}
if (resource === 'asteroidNeoBrowse') {
if (operation === 'getAll') {
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
if (returnAll === false) {
@@ -1025,14 +923,15 @@ export class Nasa implements INodeType {
propertyName = 'near_earth_objects';
endpoint = `/neo/rest/v1/neo/browse`;
} else {
throw new NodeOperationError(this.getNode(), `The operation '${operation}' is unknown!`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`The operation '${operation}' is unknown!`,
{ itemIndex: i },
);
}
}
if (resource.startsWith('donki')) {
if (additionalFields.startDate) {
qs.startDate = moment(additionalFields.startDate as string).format('YYYY-MM-DD');
} else {
@@ -1046,101 +945,60 @@ export class Nasa implements INodeType {
}
if (resource === 'donkiCoronalMassEjection') {
if (operation === 'get') {
endpoint = '/DONKI/CME';
}
} else if (resource === 'donkiGeomagneticStorm') {
if (operation === 'get') {
endpoint = '/DONKI/GST';
}
} else if (resource === 'donkiInterplanetaryShock') {
if (operation === 'get') {
endpoint = '/DONKI/IPS';
qs.location = additionalFields.location as string || 'ALL'; // default per API
qs.catalog = additionalFields.catalog as string || 'ALL'; // default per API
qs.location = (additionalFields.location as string) || 'ALL'; // default per API
qs.catalog = (additionalFields.catalog as string) || 'ALL'; // default per API
}
} else if (resource === 'donkiSolarFlare') {
if (operation === 'get') {
endpoint = '/DONKI/FLR';
}
} else if (resource === 'donkiSolarEnergeticParticle') {
if (operation === 'get') {
endpoint = '/DONKI/SEP';
}
} else if (resource === 'donkiMagnetopauseCrossing') {
if (operation === 'get') {
endpoint = '/DONKI/MPC';
}
} else if (resource === 'donkiRadiationBeltEnhancement') {
if (operation === 'get') {
endpoint = '/DONKI/RBE';
}
} else if (resource === 'donkiHighSpeedStream') {
if (operation === 'get') {
endpoint = '/DONKI/HSS';
}
} else if (resource === 'donkiWsaEnlilSimulation') {
if (operation === 'get') {
endpoint = '/DONKI/WSAEnlilSimulations';
}
} else if (resource === 'donkiNotifications') {
if (operation === 'get') {
endpoint = '/DONKI/notifications';
qs.type = additionalFields.type as string || 'all'; // default per API
qs.type = (additionalFields.type as string) || 'all'; // default per API
}
}
}
if (resource === 'earthImagery') {
if (operation === 'get') {
endpoint = '/planetary/earth/imagery';
qs.lat = this.getNodeParameter('lat', i) as IDataObject;
qs.lon = this.getNodeParameter('lon', i) as IDataObject;
qs.dim = additionalFields.dim as string || 0.025; // default per API
qs.dim = (additionalFields.dim as string) || 0.025; // default per API
if (additionalFields.date) {
qs.date = moment(additionalFields.date as string).format('YYYY-MM-DD');
@@ -1148,18 +1006,15 @@ export class Nasa implements INodeType {
qs.date = moment().format('YYYY-MM-DD');
}
}
}
if (resource === 'earthAssets') {
if (operation === 'get') {
endpoint = '/planetary/earth/assets';
qs.lat = this.getNodeParameter('lat', i) as IDataObject;
qs.lon = this.getNodeParameter('lon', i) as IDataObject;
qs.dim = additionalFields.dim as string || 0.025; // default per API
qs.dim = (additionalFields.dim as string) || 0.025; // default per API
if (additionalFields.date) {
qs.date = moment(additionalFields.date as string).format('YYYY-MM-DD');
@@ -1167,13 +1022,11 @@ export class Nasa implements INodeType {
}
if (operation === 'get') {
endpoint = '/insight_weather/earth/imagery';
// Hardcoded because these are the only options available right now.
qs.feedtype = 'json';
qs.ver = '1.0';
}
}
@@ -1197,7 +1050,6 @@ export class Nasa implements INodeType {
}
if (resource === 'earthImagery') {
const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string;
const data = await nasaApiRequest.call(this, 'GET', endpoint, qs, { encoding: null });
@@ -1220,10 +1072,16 @@ export class Nasa implements INodeType {
download = this.getNodeParameter('download', 0) as boolean;
if (download === true) {
const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string;
const data = await nasaApiRequest.call(this, 'GET', endpoint, qs, { encoding: null }, responseData.hdurl);
const data = await nasaApiRequest.call(
this,
'GET',
endpoint,
qs,
{ encoding: null },
responseData.hdurl,
);
const filename = (responseData.hdurl as string).split('/');
@@ -1240,7 +1098,10 @@ export class Nasa implements INodeType {
items[i] = newItem;
items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data, filename[filename.length - 1]);
items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(
data,
filename[filename.length - 1],
);
}
}
@@ -1253,7 +1114,11 @@ export class Nasa implements INodeType {
if (this.continueOnFail()) {
if (resource === 'earthImagery' && operation === 'get') {
items[i].json = { error: error.message };
} else if (resource === 'astronomyPictureOfTheDay' && operation === 'get' && download === true) {
} else if (
resource === 'astronomyPictureOfTheDay' &&
operation === 'get' &&
download === true
) {
items[i].json = { error: error.message };
} else {
returnData.push({ error: error.message });
@@ -1266,7 +1131,11 @@ export class Nasa implements INodeType {
if (resource === 'earthImagery' && operation === 'get') {
return this.prepareOutputData(items);
} else if (resource === 'astronomyPictureOfTheDay' && operation === 'get' && download === true) {
} else if (
resource === 'astronomyPictureOfTheDay' &&
operation === 'get' &&
download === true
) {
return this.prepareOutputData(items);
} else {
return [this.helpers.returnJsonArray(returnData)];