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,11 +1,6 @@
import {
IExecuteFunctions,
IHookFunctions,
} from 'n8n-core';
import { IExecuteFunctions, IHookFunctions } from 'n8n-core';
import {
IDataObject, NodeApiError, NodeOperationError,
} from 'n8n-workflow';
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
import { OptionsWithUri } from 'request';
/**
@@ -17,7 +12,15 @@ import { OptionsWithUri } from 'request';
* @param {object} body
* @returns {Promise<any>}
*/
export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function gitlabApiRequest(
this: IHookFunctions | IExecuteFunctions,
method: string,
endpoint: string,
body: object,
query?: object,
option: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const options: OptionsWithUri = {
method,
headers: {},
@@ -53,8 +56,15 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
}
}
export async function gitlabApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function gitlabApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions,
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;
@@ -63,11 +73,11 @@ export async function gitlabApiRequestAllItems(this: IHookFunctions | IExecuteFu
query.page = 1;
do {
responseData = await gitlabApiRequest.call(this, method, endpoint, body, query, { resolveWithFullResponse: true });
responseData = await gitlabApiRequest.call(this, method, endpoint, body, query, {
resolveWithFullResponse: true,
});
query.page++;
returnData.push.apply(returnData, responseData.body);
} while (
responseData.headers.link && responseData.headers.link.includes('next')
);
} while (responseData.headers.link && responseData.headers.link.includes('next'));
return returnData;
}

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 {
gitlabApiRequest,
gitlabApiRequestAllItems,
} from './GenericFunctions';
import { gitlabApiRequest, gitlabApiRequestAllItems } from './GenericFunctions';
export class Gitlab implements INodeType {
description: INodeTypeDescription = {
@@ -35,9 +30,7 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'accessToken',
],
authentication: ['accessToken'],
},
},
},
@@ -46,9 +39,7 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -96,8 +87,6 @@ export class Gitlab implements INodeType {
default: 'issue',
},
// ----------------------------------
// operations
// ----------------------------------
@@ -108,9 +97,7 @@ export class Gitlab implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'issue',
],
resource: ['issue'],
},
},
options: [
@@ -155,9 +142,7 @@ export class Gitlab implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'repository',
],
resource: ['repository'],
},
},
options: [
@@ -184,9 +169,7 @@ export class Gitlab implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'user',
],
resource: ['user'],
},
},
options: [
@@ -194,7 +177,7 @@ export class Gitlab implements INodeType {
name: 'Get Repositories',
value: 'getRepositories',
description: 'Returns the repositories of a user',
action: 'Get a user\'s repositories',
action: "Get a user's repositories",
},
],
default: 'getRepositories',
@@ -207,9 +190,7 @@ export class Gitlab implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'release',
],
resource: ['release'],
},
},
options: [
@@ -247,8 +228,6 @@ export class Gitlab implements INodeType {
default: 'create',
},
// ----------------------------------
// shared
// ----------------------------------
@@ -269,12 +248,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
hide: {
resource: [
'user',
],
operation: [
'getRepositories',
],
resource: ['user'],
operation: ['getRepositories'],
},
},
placeholder: 'n8n',
@@ -296,12 +271,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'issue',
],
operation: ['create'],
resource: ['issue'],
},
},
description: 'The title of the issue',
@@ -316,12 +287,8 @@ export class Gitlab implements INodeType {
default: '',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'issue',
],
operation: ['create'],
resource: ['issue'],
},
},
description: 'The body of the issue',
@@ -332,12 +299,8 @@ export class Gitlab implements INodeType {
type: 'dateTime',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'issue',
],
operation: ['create'],
resource: ['issue'],
},
},
default: '',
@@ -353,15 +316,11 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'issue',
],
operation: ['create'],
resource: ['issue'],
},
},
default: { 'label': '' },
default: { label: '' },
options: [
{
displayName: 'Label',
@@ -382,15 +341,11 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'issue',
],
operation: ['create'],
resource: ['issue'],
},
},
default: { 'assignee': '' },
default: { assignee: '' },
options: [
{
displayName: 'Assignee',
@@ -402,7 +357,6 @@ export class Gitlab implements INodeType {
],
},
// ----------------------------------
// issue:createComment
// ----------------------------------
@@ -414,12 +368,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'createComment',
],
resource: [
'issue',
],
operation: ['createComment'],
resource: ['issue'],
},
},
description: 'The number of the issue on which to create the comment on',
@@ -433,12 +383,8 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'createComment',
],
resource: [
'issue',
],
operation: ['createComment'],
resource: ['issue'],
},
},
default: '',
@@ -456,12 +402,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'edit',
],
resource: [
'issue',
],
operation: ['edit'],
resource: ['issue'],
},
},
description: 'The number of the issue edit',
@@ -475,12 +417,8 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'edit',
],
resource: [
'issue',
],
operation: ['edit'],
resource: ['issue'],
},
},
default: {},
@@ -529,7 +467,7 @@ export class Gitlab implements INodeType {
multipleValues: true,
multipleValueButtonText: 'Add Label',
},
default: { 'label': '' },
default: { label: '' },
options: [
{
displayName: 'Label',
@@ -548,7 +486,7 @@ export class Gitlab implements INodeType {
multipleValues: true,
multipleValueButtonText: 'Add Assignee',
},
default: { 'assignee': '' },
default: { assignee: '' },
options: [
{
displayName: 'Assignees',
@@ -580,12 +518,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'issue',
],
operation: ['get'],
resource: ['issue'],
},
},
description: 'The number of the issue get data of',
@@ -602,12 +536,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'lock',
],
resource: [
'issue',
],
operation: ['lock'],
resource: ['issue'],
},
},
description: 'The number of the issue to lock',
@@ -618,12 +548,8 @@ export class Gitlab implements INodeType {
type: 'options',
displayOptions: {
show: {
operation: [
'lock',
],
resource: [
'issue',
],
operation: ['lock'],
resource: ['issue'],
},
},
options: [
@@ -652,8 +578,6 @@ export class Gitlab implements INodeType {
description: 'The reason to lock the issue',
},
// ----------------------------------
// release
// ----------------------------------
@@ -669,12 +593,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'release',
],
operation: ['create'],
resource: ['release'],
},
},
description: 'The tag of the release',
@@ -688,12 +608,8 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'release',
],
operation: ['create'],
resource: ['release'],
},
},
default: {},
@@ -720,7 +636,8 @@ export class Gitlab implements INodeType {
name: 'ref',
type: 'string',
default: '',
description: 'If Tag doesnt exist, the release will be created from Ref. It can be a commit SHA, another tag name, or a branch name.',
description:
'If Tag doesnt exist, the release will be created from Ref. It can be a commit SHA, another tag name, or a branch name.',
},
],
},
@@ -736,13 +653,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'delete',
'get',
],
resource: [
'release',
],
operation: ['delete', 'get'],
resource: ['release'],
},
},
description: 'The ID or URL-encoded path of the project',
@@ -755,13 +667,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'delete',
'get',
],
resource: [
'release',
],
operation: ['delete', 'get'],
resource: ['release'],
},
},
description: 'The Git tag the release is associated with',
@@ -778,12 +685,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'release',
],
operation: ['getAll'],
resource: ['release'],
},
},
description: 'The ID or URL-encoded path of the project',
@@ -794,12 +697,8 @@ export class Gitlab implements INodeType {
type: 'boolean',
displayOptions: {
show: {
resource: [
'release',
],
operation: [
'getAll',
],
resource: ['release'],
operation: ['getAll'],
},
},
default: false,
@@ -811,15 +710,9 @@ export class Gitlab implements INodeType {
type: 'number',
displayOptions: {
show: {
resource: [
'release',
],
operation: [
'getAll',
],
returnAll: [
false,
],
resource: ['release'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
@@ -838,12 +731,8 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'release',
],
operation: ['getAll'],
resource: ['release'],
},
},
default: {},
@@ -896,12 +785,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'release',
],
operation: ['update'],
resource: ['release'],
},
},
description: 'The ID or URL-encoded path of the project',
@@ -914,12 +799,8 @@ export class Gitlab implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'release',
],
operation: ['update'],
resource: ['release'],
},
},
description: 'The Git tag the release is associated with',
@@ -933,12 +814,8 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'release',
],
operation: ['update'],
resource: ['release'],
},
},
default: {},
@@ -962,7 +839,8 @@ export class Gitlab implements INodeType {
name: 'milestones',
type: 'string',
default: '',
description: 'The title of each milestone to associate with the release (provide a titles list spearated with comma)',
description:
'The title of each milestone to associate with the release (provide a titles list spearated with comma)',
},
{
displayName: 'Released At',
@@ -989,12 +867,8 @@ export class Gitlab implements INodeType {
},
displayOptions: {
show: {
operation: [
'getIssues',
],
resource: [
'repository',
],
operation: ['getIssues'],
resource: ['repository'],
},
},
default: {},
@@ -1018,7 +892,8 @@ export class Gitlab implements INodeType {
name: 'labels',
type: 'string',
default: '',
description: 'Return only issues with the given labels. Multiple lables can be separated by comma.',
description:
'Return only issues with the given labels. Multiple lables can be separated by comma.',
},
{
displayName: 'Updated After',
@@ -1094,14 +969,11 @@ export class Gitlab implements INodeType {
default: 'desc',
description: 'The sort order',
},
],
},
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
@@ -1223,7 +1095,9 @@ export class Gitlab implements INodeType {
body.labels = (body.labels as IDataObject[]).map((data) => data['label']).join(',');
}
if (body.assignee_ids !== undefined) {
body.assignee_ids = (body.assignee_ids as IDataObject[]).map((data) => data['assignee']);
body.assignee_ids = (body.assignee_ids as IDataObject[]).map(
(data) => data['assignee'],
);
}
endpoint = `${baseEndpoint}/issues/${issueNumber}`;
@@ -1321,7 +1195,7 @@ export class Gitlab implements INodeType {
const tagName = this.getNodeParameter('tag_name', i) as string;
body = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
if(body.milestones){
if (body.milestones) {
body.milestones = (body.milestones as string).split(',');
}
@@ -1362,7 +1236,13 @@ export class Gitlab implements INodeType {
}
if (returnAll === true) {
responseData = await gitlabApiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
responseData = await gitlabApiRequestAllItems.call(
this,
requestMethod,
endpoint,
body,
qs,
);
} else {
responseData = await gitlabApiRequest.call(this, requestMethod, endpoint, body, qs);
}
@@ -1374,7 +1254,10 @@ export class Gitlab implements INodeType {
}
} catch (error) {
if (this.continueOnFail()) {
if (overwriteDataOperations.includes(fullOperation) || overwriteDataOperationsArray.includes(fullOperation)) {
if (
overwriteDataOperations.includes(fullOperation) ||
overwriteDataOperationsArray.includes(fullOperation)
) {
returnData.push({ error: error.message });
} else {
items[i].json = { error: error.message };
@@ -1385,13 +1268,15 @@ export class Gitlab implements INodeType {
}
}
if (overwriteDataOperations.includes(fullOperation) || overwriteDataOperationsArray.includes(fullOperation)) {
if (
overwriteDataOperations.includes(fullOperation) ||
overwriteDataOperationsArray.includes(fullOperation)
) {
// Return data gets replaced
return [this.helpers.returnJsonArray(returnData)];
} else {
// For all other ones simply return the unchanged items
return this.prepareOutputData(items);
}
}
}

View File

@@ -1,7 +1,4 @@
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
import {
IDataObject,
@@ -12,20 +9,19 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
gitlabApiRequest,
} from './GenericFunctions';
import { gitlabApiRequest } from './GenericFunctions';
const GITLAB_EVENTS = [
{
name: 'Comment',
value: 'note',
description: 'Triggered when a new comment is made on commits, merge requests, issues, and code snippets',
description:
'Triggered when a new comment is made on commits, merge requests, issues, and code snippets',
},
{
name: 'Confidential Issues',
value: 'confidential_issues',
description: 'Triggered on confidential issues\' events',
description: "Triggered on confidential issues' events",
},
{
name: 'Confidential Comments',
@@ -40,7 +36,8 @@ const GITLAB_EVENTS = [
{
name: 'Issue',
value: 'issues',
description: 'Triggered when a new issue is created or an existing issue was updated/closed/reopened',
description:
'Triggered when a new issue is created or an existing issue was updated/closed/reopened',
},
{
name: 'Job',
@@ -50,7 +47,8 @@ const GITLAB_EVENTS = [
{
name: 'Merge Request',
value: 'merge_requests',
description: 'Triggered when a new merge request is created, an existing merge request was updated/merged/closed or a commit is added in the source branch',
description:
'Triggered when a new merge request is created, an existing merge request was updated/merged/closed or a commit is added in the source branch',
},
{
name: 'Pipeline',
@@ -86,7 +84,8 @@ export class GitlabTrigger implements INodeType {
icon: 'file:gitlab.svg',
group: ['trigger'],
version: 1,
subtitle: '={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}',
subtitle:
'={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}',
description: 'Starts the workflow when GitLab events occur',
defaults: {
name: 'Gitlab Trigger',
@@ -99,9 +98,7 @@ export class GitlabTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'accessToken',
],
authentication: ['accessToken'],
},
},
},
@@ -110,9 +107,7 @@ export class GitlabTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -194,7 +189,7 @@ export class GitlabTrigger implements INodeType {
const owner = this.getNodeParameter('owner') as string;
const repository = this.getNodeParameter('repository') as string;
const path = (`${owner}/${repository}`).replace(/\//g, '%2F');
const path = `${owner}/${repository}`.replace(/\//g, '%2F');
const endpoint = `/projects/${path}/hooks/${webhookData.webhookId}`;
@@ -228,7 +223,7 @@ export class GitlabTrigger implements INodeType {
let eventsArray = this.getNodeParameter('events', []) as string[];
if (eventsArray.includes('*')) {
eventsArray = GITLAB_EVENTS.map(e => e.value);
eventsArray = GITLAB_EVENTS.map((e) => e.value);
}
const events: { [key: string]: boolean } = {};
@@ -242,7 +237,7 @@ export class GitlabTrigger implements INodeType {
events['push_events'] = false;
}
const path = (`${owner}/${repository}`).replace(/\//g, '%2F');
const path = `${owner}/${repository}`.replace(/\//g, '%2F');
const endpoint = `/projects/${path}/hooks`;
@@ -261,7 +256,9 @@ export class GitlabTrigger implements INodeType {
if (responseData.id === undefined) {
// Required data is missing so was not successful
throw new NodeApiError(this.getNode(), responseData, { message: 'GitLab webhook creation response did not contain the expected data.' });
throw new NodeApiError(this.getNode(), responseData, {
message: 'GitLab webhook creation response did not contain the expected data.',
});
}
const webhookData = this.getWorkflowStaticData('node');
@@ -277,7 +274,7 @@ export class GitlabTrigger implements INodeType {
const owner = this.getNodeParameter('owner') as string;
const repository = this.getNodeParameter('repository') as string;
const path = (`${owner}/${repository}`).replace(/\//g, '%2F');
const path = `${owner}/${repository}`.replace(/\//g, '%2F');
const endpoint = `/projects/${path}/hooks/${webhookData.webhookId}`;
const body = {};
@@ -299,25 +296,19 @@ export class GitlabTrigger implements INodeType {
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const bodyData = this.getBodyData();
const returnData: IDataObject[] = [];
returnData.push(
{
body: bodyData,
headers: this.getHeaderData(),
query: this.getQueryData(),
},
);
returnData.push({
body: bodyData,
headers: this.getHeaderData(),
query: this.getQueryData(),
});
return {
workflowData: [
this.helpers.returnJsonArray(returnData),
],
workflowData: [this.helpers.returnJsonArray(returnData)],
};
}
}