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,21 +1,13 @@
import {
IExecuteFunctions,
ILoadOptionsFunctions
} from 'n8n-core';
import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core';
import {
IDataObject,
IHookFunctions,
IWebhookFunctions,
NodeOperationError,
} from 'n8n-workflow';
import { IDataObject, IHookFunctions, IWebhookFunctions, NodeOperationError } from 'n8n-workflow';
import {
beeminderApiRequest,
beeminderApiRequestAllItems,
} from './GenericFunctions';
import { beeminderApiRequest, beeminderApiRequestAllItems } from './GenericFunctions';
export async function createDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
export async function createDatapoint(
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
data: IDataObject,
) {
const credentials = await this.getCredentials('beeminderApi');
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
@@ -23,7 +15,10 @@ export async function createDatapoint(this: IExecuteFunctions | IWebhookFunction
return await beeminderApiRequest.call(this, 'POST', endpoint, data);
}
export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
export async function getAllDatapoints(
this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions,
data: IDataObject,
) {
const credentials = await this.getCredentials('beeminderApi');
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
@@ -35,7 +30,10 @@ export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions
return await beeminderApiRequestAllItems.call(this, 'GET', endpoint, {}, data);
}
export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
export async function updateDatapoint(
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
data: IDataObject,
) {
const credentials = await this.getCredentials('beeminderApi');
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
@@ -43,11 +41,13 @@ export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunction
return await beeminderApiRequest.call(this, 'PUT', endpoint, data);
}
export async function deleteDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
export async function deleteDatapoint(
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
data: IDataObject,
) {
const credentials = await this.getCredentials('beeminderApi');
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
return await beeminderApiRequest.call(this, 'DELETE', endpoint);
}

View File

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
@@ -17,12 +15,10 @@ import {
createDatapoint,
deleteDatapoint,
getAllDatapoints,
updateDatapoint
updateDatapoint,
} from './Beeminder.node.functions';
import {
beeminderApiRequest,
} from './GenericFunctions';
import { beeminderApiRequest } from './GenericFunctions';
import moment from 'moment-timezone';
@@ -105,13 +101,12 @@ export class Beeminder implements INodeType {
},
displayOptions: {
show: {
resource: [
'datapoint',
],
resource: ['datapoint'],
},
},
default: '',
description: 'The name of the goal. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The name of the goal. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
required: true,
},
{
@@ -120,12 +115,8 @@ export class Beeminder implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'datapoint',
],
operation: ['getAll'],
resource: ['datapoint'],
},
},
default: false,
@@ -137,15 +128,9 @@ export class Beeminder implements INodeType {
type: 'number',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'datapoint',
],
returnAll: [
false,
],
operation: ['getAll'],
resource: ['datapoint'],
returnAll: [false],
},
},
typeOptions: {
@@ -164,12 +149,8 @@ export class Beeminder implements INodeType {
description: 'Datapoint value to send',
displayOptions: {
show: {
resource: [
'datapoint',
],
operation: [
'create',
],
resource: ['datapoint'],
operation: ['create'],
},
},
required: true,
@@ -181,10 +162,7 @@ export class Beeminder implements INodeType {
default: '',
displayOptions: {
show: {
operation: [
'update',
'delete',
],
operation: ['update', 'delete'],
},
},
required: true,
@@ -197,12 +175,8 @@ export class Beeminder implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'datapoint',
],
operation: [
'create',
],
resource: ['datapoint'],
operation: ['create'],
},
},
options: [
@@ -218,7 +192,8 @@ export class Beeminder implements INodeType {
type: 'dateTime',
default: '',
placeholder: '',
description: 'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created',
description:
'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created',
},
{
displayName: 'Request ID',
@@ -238,12 +213,8 @@ export class Beeminder implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'datapoint',
],
operation: [
'getAll',
],
resource: ['datapoint'],
operation: ['getAll'],
},
},
options: [
@@ -265,12 +236,8 @@ export class Beeminder implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'datapoint',
],
operation: [
'update',
],
resource: ['datapoint'],
operation: ['update'],
},
},
options: [
@@ -294,7 +261,8 @@ export class Beeminder implements INodeType {
type: 'dateTime',
default: '',
placeholder: '',
description: 'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created',
description:
'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created',
},
],
},
@@ -306,7 +274,6 @@ export class Beeminder implements INodeType {
// Get all the available groups to display them to user so that he can
// select them easily
async getGoals(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const credentials = await this.getCredentials('beeminderApi');
const endpoint = `/users/${credentials.user}/goals.json`;
@@ -325,7 +292,6 @@ export class Beeminder implements INodeType {
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const length = items.length;
@@ -335,7 +301,6 @@ export class Beeminder implements INodeType {
const operation = this.getNodeParameter('operation', 0) as string;
let results;
for (let i = 0; i < length; i++) {
try {
if (resource === 'datapoint') {
@@ -353,8 +318,7 @@ export class Beeminder implements INodeType {
data.timestamp = moment.tz(data.timestamp, timezone).unix();
}
results = await createDatapoint.call(this, data);
}
else if (operation === 'getAll') {
} else if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const options = this.getNodeParameter('options', i) as INodeParameters;
const data: IDataObject = {
@@ -367,8 +331,7 @@ export class Beeminder implements INodeType {
}
results = await getAllDatapoints.call(this, data);
}
else if (operation === 'update') {
} else if (operation === 'update') {
const datapointId = this.getNodeParameter('datapointId', i) as string;
const options = this.getNodeParameter('updateFields', i) as INodeParameters;
const data: IDataObject = {
@@ -380,8 +343,7 @@ export class Beeminder implements INodeType {
data.timestamp = moment.tz(data.timestamp, timezone).unix();
}
results = await updateDatapoint.call(this, data);
}
else if (operation === 'delete') {
} else if (operation === 'delete') {
const datapointId = this.getNodeParameter('datapointId', i) as string;
const data: IDataObject = {
goalName,
@@ -407,4 +369,3 @@ export class Beeminder implements INodeType {
return [this.helpers.returnJsonArray(returnData)];
}
}

View File

@@ -1,24 +1,21 @@
import {
OptionsWithUri,
} from 'request';
import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core';
import {
IDataObject,
IHookFunctions,
IWebhookFunctions,
NodeApiError,
} from 'n8n-workflow';
import { IDataObject, IHookFunctions, IWebhookFunctions, NodeApiError } from 'n8n-workflow';
const BEEMINDER_URI = 'https://www.beeminder.com/api/v1';
export async function beeminderApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('beeminderApi') as IDataObject;
export async function beeminderApiRequest(
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = (await this.getCredentials('beeminderApi')) as IDataObject;
Object.assign(body, { auth_token: credentials.authToken });
@@ -45,8 +42,15 @@ export async function beeminderApiRequest(this: IExecuteFunctions | IWebhookFunc
}
}
export async function beeminderApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function beeminderApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
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;
@@ -55,9 +59,7 @@ export async function beeminderApiRequestAllItems(this: IExecuteFunctions | ILoa
responseData = await beeminderApiRequest.call(this, method, endpoint, body, query);
query.page++;
returnData.push.apply(returnData, responseData);
} while (
responseData.length !== 0
);
} while (responseData.length !== 0);
return returnData;
}