mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
@@ -19,11 +14,15 @@ import {
|
||||
|
||||
import get from 'lodash.get';
|
||||
|
||||
import {
|
||||
query,
|
||||
} from './Queries';
|
||||
import { query } from './Queries';
|
||||
|
||||
export async function linearApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, body: any = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function linearApiRequest(
|
||||
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
option: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('linearApi');
|
||||
|
||||
const endpoint = 'https://api.linear.app/graphql';
|
||||
@@ -41,7 +40,6 @@ export async function linearApiRequest(this: IExecuteFunctions | IWebhookFunctio
|
||||
options = Object.assign({}, options, option);
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
@@ -51,8 +49,13 @@ export function capitalizeFirstLetter(data: string) {
|
||||
return data.charAt(0).toUpperCase() + data.slice(1);
|
||||
}
|
||||
|
||||
export async function linearApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, body: any = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function linearApiRequestAllItems(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -63,13 +66,15 @@ export async function linearApiRequestAllItems(this: IHookFunctions | IExecuteFu
|
||||
responseData = await linearApiRequest.call(this, body);
|
||||
returnData.push.apply(returnData, get(responseData, `${propertyName}.nodes`));
|
||||
body.variables.after = get(responseData, `${propertyName}.pageInfo.endCursor`);
|
||||
} while (
|
||||
get(responseData, `${propertyName}.pageInfo.hasNextPage`)
|
||||
);
|
||||
} while (get(responseData, `${propertyName}.pageInfo.hasNextPage`));
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function validateCredentials(this: ICredentialTestFunctions, decryptedCredentials: ICredentialDataDecryptedObject): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function validateCredentials(
|
||||
this: ICredentialTestFunctions,
|
||||
decryptedCredentials: ICredentialDataDecryptedObject,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = decryptedCredentials;
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
@@ -93,7 +98,11 @@ export async function validateCredentials(this: ICredentialTestFunctions, decryp
|
||||
|
||||
//@ts-ignore
|
||||
export const sort = (a, b) => {
|
||||
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; }
|
||||
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; }
|
||||
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const issueOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const issueOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
resource: ['issue'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -52,7 +48,6 @@ export const issueOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const issueFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* issue:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -60,16 +55,13 @@ export const issueFields: INodeProperties[] = [
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -84,12 +76,8 @@ export const issueFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -102,12 +90,8 @@ export const issueFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -115,7 +99,8 @@ export const issueFields: INodeProperties[] = [
|
||||
displayName: 'Assignee Name or ID',
|
||||
name: 'assigneeId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getUsers',
|
||||
},
|
||||
@@ -163,7 +148,8 @@ export const issueFields: INodeProperties[] = [
|
||||
displayName: 'State Name or ID',
|
||||
name: 'stateId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getStates',
|
||||
},
|
||||
@@ -181,13 +167,8 @@ export const issueFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'delete',
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['get', 'delete'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -202,12 +183,8 @@ export const issueFields: INodeProperties[] = [
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
@@ -223,15 +200,9 @@ export const issueFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
description: 'Max number of results to return',
|
||||
@@ -246,12 +217,8 @@ export const issueFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -264,12 +231,8 @@ export const issueFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['issue'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -277,7 +240,8 @@ export const issueFields: INodeProperties[] = [
|
||||
displayName: 'Assignee Name or ID',
|
||||
name: 'assigneeId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getUsers',
|
||||
},
|
||||
@@ -325,7 +289,8 @@ export const issueFields: INodeProperties[] = [
|
||||
displayName: 'State Name or ID',
|
||||
name: 'stateId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getStates',
|
||||
},
|
||||
@@ -335,7 +300,8 @@ export const issueFields: INodeProperties[] = [
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
@@ -23,14 +21,9 @@ import {
|
||||
validateCredentials,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
issueFields,
|
||||
issueOperations,
|
||||
} from './IssueDescription';
|
||||
import { issueFields, issueOperations } from './IssueDescription';
|
||||
|
||||
import {
|
||||
query,
|
||||
} from './Queries';
|
||||
import { query } from './Queries';
|
||||
interface IGraphqlBody {
|
||||
query: string;
|
||||
variables: IDataObject;
|
||||
@@ -77,13 +70,18 @@ export class Linear implements INodeType {
|
||||
|
||||
methods = {
|
||||
credentialTest: {
|
||||
async linearApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
|
||||
async linearApiTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
try {
|
||||
await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject);
|
||||
} catch (error) {
|
||||
const { error: err } = error as JsonObject;
|
||||
const errors = (err as IDataObject).errors as [{ extensions: { code: string } }];
|
||||
const authenticationError = Boolean(errors.filter(e => e.extensions.code === 'AUTHENTICATION_ERROR').length);
|
||||
const authenticationError = Boolean(
|
||||
errors.filter((e) => e.extensions.code === 'AUTHENTICATION_ERROR').length,
|
||||
);
|
||||
if (authenticationError) {
|
||||
return {
|
||||
status: 'Error',
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
ILoadOptionsFunctions,
|
||||
@@ -11,10 +8,7 @@ import {
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
capitalizeFirstLetter,
|
||||
linearApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { capitalizeFirstLetter, linearApiRequest } from './GenericFunctions';
|
||||
|
||||
export class LinearTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -51,7 +45,8 @@ export class LinearTrigger implements INodeType {
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
@@ -91,7 +86,6 @@ export class LinearTrigger implements INodeType {
|
||||
name: 'Project',
|
||||
value: 'project',
|
||||
},
|
||||
|
||||
],
|
||||
default: [],
|
||||
required: true,
|
||||
@@ -104,8 +98,7 @@ export class LinearTrigger implements INodeType {
|
||||
async getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const body = {
|
||||
query:
|
||||
`query Teams {
|
||||
query: `query Teams {
|
||||
teams {
|
||||
nodes {
|
||||
id
|
||||
@@ -114,7 +107,11 @@ export class LinearTrigger implements INodeType {
|
||||
}
|
||||
}`,
|
||||
};
|
||||
const { data: { teams: { nodes } } } = await linearApiRequest.call(this, body);
|
||||
const {
|
||||
data: {
|
||||
teams: { nodes },
|
||||
},
|
||||
} = await linearApiRequest.call(this, body);
|
||||
|
||||
for (const node of nodes) {
|
||||
returnData.push({
|
||||
@@ -135,8 +132,7 @@ export class LinearTrigger implements INodeType {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const teamId = this.getNodeParameter('teamId') as string;
|
||||
const body = {
|
||||
query:
|
||||
`query {
|
||||
query: `query {
|
||||
webhooks {
|
||||
nodes {
|
||||
id
|
||||
@@ -152,12 +148,14 @@ export class LinearTrigger implements INodeType {
|
||||
};
|
||||
// Check all the webhooks which exist already if it is identical to the
|
||||
// one that is supposed to get created.
|
||||
const { data: { webhooks: { nodes } } } = await linearApiRequest.call(this, body);
|
||||
const {
|
||||
data: {
|
||||
webhooks: { nodes },
|
||||
},
|
||||
} = await linearApiRequest.call(this, body);
|
||||
|
||||
for (const node of nodes) {
|
||||
if (node.url === webhookUrl &&
|
||||
node.team.id === teamId &&
|
||||
node.enabled === true) {
|
||||
if (node.url === webhookUrl && node.team.id === teamId && node.enabled === true) {
|
||||
webhookData.webhookId = node.id as string;
|
||||
return true;
|
||||
}
|
||||
@@ -193,7 +191,14 @@ export class LinearTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
const { data: { webhookCreate: { success, webhook: { id } } } } = await linearApiRequest.call(this, body);
|
||||
const {
|
||||
data: {
|
||||
webhookCreate: {
|
||||
success,
|
||||
webhook: { id },
|
||||
},
|
||||
},
|
||||
} = await linearApiRequest.call(this, body);
|
||||
|
||||
if (!success) {
|
||||
return false;
|
||||
@@ -236,9 +241,7 @@ export class LinearTrigger implements INodeType {
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const bodyData = this.getBodyData();
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(bodyData),
|
||||
],
|
||||
workflowData: [this.helpers.returnJsonArray(bodyData)],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user