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,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
@@ -24,10 +22,7 @@ import {
CollectionUpdateFields,
} from './descriptions/CollectionDescription';
import {
eventFields,
eventOperations,
} from './descriptions/EventDescription';
import { eventFields, eventOperations } from './descriptions/EventDescription';
import {
GroupCreationAdditionalFields,
@@ -43,10 +38,7 @@ import {
MemberUpdateFields,
} from './descriptions/MemberDescription';
import {
isEmpty,
partialRight,
} from 'lodash';
import { isEmpty, partialRight } from 'lodash';
export class Bitwarden implements INodeType {
description: INodeTypeDescription = {
@@ -131,15 +123,12 @@ export class Bitwarden implements INodeType {
const handleGetAll = partialRight(tokenlessHandleGetAll, token);
for (let i = 0; i < items.length; i++) {
if (resource === 'collection') {
// *********************************************************************
// collection
// *********************************************************************
if (operation === 'delete') {
// ----------------------------------
// collection: delete
// ----------------------------------
@@ -148,9 +137,7 @@ export class Bitwarden implements INodeType {
const endpoint = `/public/collections/${id}`;
responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {});
responseData = { success: true };
} else if (operation === 'get') {
// ----------------------------------
// collection: get
// ----------------------------------
@@ -158,18 +145,14 @@ export class Bitwarden implements INodeType {
const id = this.getNodeParameter('collectionId', i);
const endpoint = `/public/collections/${id}`;
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
} else if (operation === 'getAll') {
// ----------------------------------
// collection: getAll
// ----------------------------------
const endpoint = '/public/collections';
responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {});
} else if (operation === 'update') {
// ----------------------------------
// collection: update
// ----------------------------------
@@ -177,7 +160,11 @@ export class Bitwarden implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as CollectionUpdateFields;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`Please enter at least one field to update for the ${resource}.`,
{ itemIndex: i },
);
}
const { groups, externalId } = updateFields;
@@ -198,17 +185,13 @@ export class Bitwarden implements INodeType {
const id = this.getNodeParameter('collectionId', i);
const endpoint = `/public/collections/${id}`;
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
}
} else if (resource === 'event') {
// *********************************************************************
// event
// *********************************************************************
if (operation === 'getAll') {
// ----------------------------------
// event: getAll
// ----------------------------------
@@ -217,17 +200,13 @@ export class Bitwarden implements INodeType {
const qs = isEmpty(filters) ? {} : filters;
const endpoint = '/public/events';
responseData = await handleGetAll.call(this, i, 'GET', endpoint, qs, {});
}
} else if (resource === 'group') {
// *********************************************************************
// group
// *********************************************************************
if (operation === 'create') {
// ----------------------------------
// group: create
// ----------------------------------
@@ -237,10 +216,10 @@ export class Bitwarden implements INodeType {
AccessAll: this.getNodeParameter('accessAll', i),
} as IDataObject;
const {
collections,
externalId,
} = this.getNodeParameter('additionalFields', i) as GroupCreationAdditionalFields;
const { collections, externalId } = this.getNodeParameter(
'additionalFields',
i,
) as GroupCreationAdditionalFields;
if (collections) {
body.collections = collections.map((collectionId) => ({
@@ -255,9 +234,7 @@ export class Bitwarden implements INodeType {
const endpoint = '/public/groups';
responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body);
} else if (operation === 'delete') {
// ----------------------------------
// group: delete
// ----------------------------------
@@ -266,9 +243,7 @@ export class Bitwarden implements INodeType {
const endpoint = `/public/groups/${id}`;
responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {});
responseData = { success: true };
} else if (operation === 'get') {
// ----------------------------------
// group: get
// ----------------------------------
@@ -276,18 +251,14 @@ export class Bitwarden implements INodeType {
const id = this.getNodeParameter('groupId', i);
const endpoint = `/public/groups/${id}`;
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
} else if (operation === 'getAll') {
// ----------------------------------
// group: getAll
// ----------------------------------
const endpoint = '/public/groups';
responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {});
} else if (operation === 'getMembers') {
// ----------------------------------
// group: getMembers
// ----------------------------------
@@ -296,9 +267,7 @@ export class Bitwarden implements INodeType {
const endpoint = `/public/groups/${id}/member-ids`;
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
responseData = responseData.map((memberId: string) => ({ memberId }));
} else if (operation === 'update') {
// ----------------------------------
// group: update
// ----------------------------------
@@ -308,7 +277,11 @@ export class Bitwarden implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as GroupUpdateFields;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`Please enter at least one field to update for the ${resource}.`,
{ itemIndex: i },
);
}
// set defaults for `name` and `accessAll`, required by Bitwarden but optional in n8n
@@ -316,7 +289,13 @@ export class Bitwarden implements INodeType {
let { name, accessAll } = updateFields;
if (name === undefined) {
responseData = await bitwardenApiRequest.call(this, 'GET', `/public/groups/${groupId}`, {}, {}) as { name: string };
responseData = (await bitwardenApiRequest.call(
this,
'GET',
`/public/groups/${groupId}`,
{},
{},
)) as { name: string };
name = responseData.name;
}
@@ -344,9 +323,7 @@ export class Bitwarden implements INodeType {
const endpoint = `/public/groups/${groupId}`;
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
} else if (operation === 'updateMembers') {
// ----------------------------------
// group: updateMembers
// ----------------------------------
@@ -362,15 +339,12 @@ export class Bitwarden implements INodeType {
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
responseData = { success: true };
}
} else if (resource === 'member') {
// *********************************************************************
// member
// *********************************************************************
if (operation === 'create') {
// ----------------------------------
// member: create
// ----------------------------------
@@ -381,10 +355,10 @@ export class Bitwarden implements INodeType {
AccessAll: this.getNodeParameter('accessAll', i),
} as IDataObject;
const {
collections,
externalId,
} = this.getNodeParameter('additionalFields', i) as MemberCreationAdditionalFields;
const { collections, externalId } = this.getNodeParameter(
'additionalFields',
i,
) as MemberCreationAdditionalFields;
if (collections) {
body.collections = collections.map((collectionId) => ({
@@ -399,9 +373,7 @@ export class Bitwarden implements INodeType {
const endpoint = '/public/members/';
responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body);
} else if (operation === 'delete') {
// ----------------------------------
// member: delete
// ----------------------------------
@@ -410,9 +382,7 @@ export class Bitwarden implements INodeType {
const endpoint = `/public/members/${id}`;
responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {});
responseData = { success: true };
} else if (operation === 'get') {
// ----------------------------------
// member: get
// ----------------------------------
@@ -420,18 +390,14 @@ export class Bitwarden implements INodeType {
const id = this.getNodeParameter('memberId', i);
const endpoint = `/public/members/${id}`;
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
} else if (operation === 'getAll') {
// ----------------------------------
// member: getAll
// ----------------------------------
const endpoint = '/public/members';
responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {});
} else if (operation === 'getGroups') {
// ----------------------------------
// member: getGroups
// ----------------------------------
@@ -440,9 +406,7 @@ export class Bitwarden implements INodeType {
const endpoint = `/public/members/${id}/group-ids`;
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
responseData = responseData.map((groupId: string) => ({ groupId }));
} else if (operation === 'update') {
// ----------------------------------
// member: update
// ----------------------------------
@@ -452,7 +416,11 @@ export class Bitwarden implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as MemberUpdateFields;
if (isEmpty(updateFields)) {
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`Please enter at least one field to update for the ${resource}.`,
{ itemIndex: i },
);
}
const { accessAll, collections, externalId, type } = updateFields;
@@ -479,9 +447,7 @@ export class Bitwarden implements INodeType {
const id = this.getNodeParameter('memberId', i);
const endpoint = `/public/members/${id}`;
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
} else if (operation === 'updateGroups') {
// ----------------------------------
// member: updateGroups
// ----------------------------------