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,9 +1,6 @@
import { OptionsWithUri } from 'request';
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
import {
ICredentialsDecrypted,
@@ -17,10 +14,7 @@ import {
IWebhookResponseData,
} from 'n8n-workflow';
import {
bitbucketApiRequest,
bitbucketApiRequestAllItems,
} from './GenericFunctions';
import { bitbucketApiRequest, bitbucketApiRequestAllItems } from './GenericFunctions';
export class BitbucketTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -75,10 +69,7 @@ export class BitbucketTrigger implements INodeType {
type: 'options',
displayOptions: {
show: {
resource: [
'workspace',
'repository',
],
resource: ['workspace', 'repository'],
},
},
typeOptions: {
@@ -86,7 +77,8 @@ export class BitbucketTrigger implements INodeType {
},
required: true,
default: '',
description: 'The repository of which to listen to the events. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The repository of which to listen to the events. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Event Names or IDs',
@@ -94,9 +86,7 @@ export class BitbucketTrigger implements INodeType {
type: 'multiOptions',
displayOptions: {
show: {
resource: [
'workspace',
],
resource: ['workspace'],
},
},
typeOptions: {
@@ -105,7 +95,8 @@ export class BitbucketTrigger implements INodeType {
options: [],
required: true,
default: [],
description: 'The events to listen to. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The events to listen to. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Repository Name or ID',
@@ -113,20 +104,17 @@ export class BitbucketTrigger implements INodeType {
type: 'options',
displayOptions: {
show: {
resource: [
'repository',
],
resource: ['repository'],
},
},
typeOptions: {
loadOptionsMethod: 'getRepositories',
loadOptionsDependsOn: [
'workspace',
],
loadOptionsDependsOn: ['workspace'],
},
required: true,
default: '',
description: 'The repository of which to listen to the events. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The repository of which to listen to the events. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Event Names or IDs',
@@ -134,9 +122,7 @@ export class BitbucketTrigger implements INodeType {
type: 'multiOptions',
displayOptions: {
show: {
resource: [
'repository',
],
resource: ['repository'],
},
},
typeOptions: {
@@ -145,15 +131,18 @@ export class BitbucketTrigger implements INodeType {
options: [],
required: true,
default: [],
description: 'The events to listen to. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The events to listen to. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
],
};
methods = {
credentialTest: {
async bitbucketApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
async bitbucketApiTest(
this: ICredentialTestFunctions,
credential: ICredentialsDecrypted,
): Promise<INodeCredentialTestResult> {
const credentials = credential.data;
const options: OptionsWithUri = {
@@ -190,7 +179,12 @@ export class BitbucketTrigger implements INodeType {
loadOptions: {
async getWorkspaceEvents(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const events = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', '/hook_events/workspace');
const events = await bitbucketApiRequestAllItems.call(
this,
'values',
'GET',
'/hook_events/workspace',
);
for (const event of events) {
returnData.push({
name: event.event,
@@ -202,7 +196,12 @@ export class BitbucketTrigger implements INodeType {
},
async getRepositoriesEvents(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const events = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', '/hook_events/repository');
const events = await bitbucketApiRequestAllItems.call(
this,
'values',
'GET',
'/hook_events/repository',
);
for (const event of events) {
returnData.push({
name: event.event,
@@ -215,7 +214,12 @@ export class BitbucketTrigger implements INodeType {
async getRepositories(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const workspace = this.getCurrentNodeParameter('workspace') as string;
const repositories = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', `/repositories/${workspace}`);
const repositories = await bitbucketApiRequestAllItems.call(
this,
'values',
'GET',
`/repositories/${workspace}`,
);
for (const repository of repositories) {
returnData.push({
name: repository.slug,
@@ -227,7 +231,12 @@ export class BitbucketTrigger implements INodeType {
},
async getWorkspaces(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const workspaces = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', `/workspaces`);
const workspaces = await bitbucketApiRequestAllItems.call(
this,
'values',
'GET',
`/workspaces`,
);
for (const workspace of workspaces) {
returnData.push({
name: workspace.name,
@@ -320,9 +329,7 @@ export class BitbucketTrigger implements INodeType {
return {};
}
return {
workflowData: [
this.helpers.returnJsonArray(req.body),
],
workflowData: [this.helpers.returnJsonArray(req.body)],
};
}
}

View File

@@ -5,9 +5,19 @@ import {
IHookFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function bitbucketApiRequest(
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
method: string,
resource: string,
// tslint:disable-next-line:no-any
body: any = {},
qs: IDataObject = {},
uri?: string,
option: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = await this.getCredentials('bitbucketApi');
let options: OptionsWithUri = {
method,
@@ -17,7 +27,7 @@ export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctio
},
qs,
body,
uri: uri ||`https://api.bitbucket.org/2.0${resource}`,
uri: uri || `https://api.bitbucket.org/2.0${resource}`,
json: true,
};
options = Object.assign({}, options, option);
@@ -36,8 +46,16 @@ export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctio
* Make an API request to paginated flow endpoint
* and return all results
*/
export async function bitbucketApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function bitbucketApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
propertyName: string,
method: string,
resource: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
@@ -48,9 +66,7 @@ export async function bitbucketApiRequestAllItems(this: IHookFunctions | IExecut
responseData = await bitbucketApiRequest.call(this, method, resource, body, query, uri);
uri = responseData.next;
returnData.push.apply(returnData, responseData[propertyName]);
} while (
responseData.next !== undefined
);
} while (responseData.next !== undefined);
return returnData;
}