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,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const emailOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const emailOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
resource: ['email'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -34,7 +30,6 @@ export const emailOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const emailFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* email:send */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -46,12 +41,8 @@ export const emailFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
placeholder: 'admin@example.com',
|
||||
@@ -67,12 +58,8 @@ export const emailFields: INodeProperties[] = [
|
||||
description: 'Email address of the recipient. Multiple ones can be separated by comma.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -93,12 +80,8 @@ export const emailFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -113,12 +96,8 @@ export const emailFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -131,12 +110,8 @@ export const emailFields: INodeProperties[] = [
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -148,12 +123,8 @@ export const emailFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -255,15 +226,9 @@ export const emailFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -278,15 +243,9 @@ export const emailFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['send'],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
placeholder: 'Add Variable',
|
||||
@@ -323,12 +282,8 @@ export const emailFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['sendTemplate'],
|
||||
},
|
||||
},
|
||||
placeholder: 'admin@example.com',
|
||||
@@ -344,12 +299,8 @@ export const emailFields: INodeProperties[] = [
|
||||
description: 'Email address of the recipient. Multiple ones can be separated by comma.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['sendTemplate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -357,7 +308,8 @@ export const emailFields: INodeProperties[] = [
|
||||
displayName: 'Template Name or ID',
|
||||
name: 'templateId',
|
||||
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: 'getTemplates',
|
||||
},
|
||||
@@ -365,12 +317,8 @@ export const emailFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['sendTemplate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -381,12 +329,8 @@ export const emailFields: INodeProperties[] = [
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['sendTemplate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -398,12 +342,8 @@ export const emailFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['sendTemplate'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -477,15 +417,9 @@ export const emailFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
jsonParameters: [
|
||||
false,
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['sendTemplate'],
|
||||
jsonParameters: [false],
|
||||
},
|
||||
},
|
||||
placeholder: 'Add Variable',
|
||||
@@ -520,15 +454,9 @@ export const emailFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
operation: [
|
||||
'sendTemplate',
|
||||
],
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
resource: ['email'],
|
||||
operation: ['sendTemplate'],
|
||||
jsonParameters: [true],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
JsonObject,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function mailjetApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
import { IDataObject, IHookFunctions, JsonObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function mailjetApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
path: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
|
||||
let credentialType;
|
||||
|
||||
if (resource === 'email' || this.getNode().type.includes('Trigger')) {
|
||||
credentialType = 'mailjetEmailApi';
|
||||
const { sandboxMode } = await this.getCredentials('mailjetEmailApi') as
|
||||
{ sandboxMode: boolean };
|
||||
const { sandboxMode } = (await this.getCredentials('mailjetEmailApi')) as {
|
||||
sandboxMode: boolean;
|
||||
};
|
||||
|
||||
if (!this.getNode().type.includes('Trigger')) {
|
||||
Object.assign(body, { SandboxMode: sandboxMode });
|
||||
}
|
||||
|
||||
} else {
|
||||
credentialType = 'mailjetSmsApi';
|
||||
}
|
||||
@@ -57,8 +55,15 @@ export async function mailjetApiRequest(this: IExecuteFunctions | IExecuteSingle
|
||||
}
|
||||
}
|
||||
|
||||
export async function mailjetApiRequestAllItems(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function mailjetApiRequestAllItems(
|
||||
this: IExecuteFunctions | 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 returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -67,16 +72,17 @@ export async function mailjetApiRequestAllItems(this: IExecuteFunctions | IHookF
|
||||
query.Offset = 0;
|
||||
|
||||
do {
|
||||
responseData = await mailjetApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true });
|
||||
responseData = await mailjetApiRequest.call(this, method, endpoint, body, query, undefined, {
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
returnData.push.apply(returnData, responseData.body);
|
||||
query.Offset = query.Offset + query.Limit;
|
||||
} while (
|
||||
responseData.length !== 0
|
||||
);
|
||||
} while (responseData.length !== 0);
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): IDataObject | undefined { // tslint:disable-line:no-any
|
||||
// tslint:disable-next-line:no-any
|
||||
export function validateJSON(json: string | undefined): IDataObject | undefined {
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
@@ -87,7 +93,7 @@ export function validateJSON(json: string | undefined): IDataObject | undefined
|
||||
}
|
||||
|
||||
export interface IMessage {
|
||||
From?: { Email?: string, Name?: string };
|
||||
From?: { Email?: string; Name?: string };
|
||||
Subject?: string;
|
||||
To?: IDataObject[];
|
||||
Cc?: IDataObject[];
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -13,21 +11,11 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
IMessage,
|
||||
mailjetApiRequest,
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
import { IMessage, mailjetApiRequest, validateJSON } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
emailFields,
|
||||
emailOperations,
|
||||
} from './EmailDescription';
|
||||
import { emailFields, emailOperations } from './EmailDescription';
|
||||
|
||||
import {
|
||||
smsFields,
|
||||
smsOperations,
|
||||
} from './SmsDescription';
|
||||
import { smsFields, smsOperations } from './SmsDescription';
|
||||
export class Mailjet implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Mailjet',
|
||||
@@ -48,9 +36,7 @@ export class Mailjet implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'email',
|
||||
],
|
||||
resource: ['email'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -59,9 +45,7 @@ export class Mailjet implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'sms',
|
||||
],
|
||||
resource: ['sms'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -151,11 +135,17 @@ export class Mailjet implements INodeType {
|
||||
const variablesJson = this.getNodeParameter('variablesJson', i) as string;
|
||||
const parsedJson = validateJSON(variablesJson);
|
||||
if (parsedJson === undefined) {
|
||||
throw new NodeOperationError(this.getNode(),`Parameter 'Variables (JSON)' has a invalid JSON`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Parameter 'Variables (JSON)' has a invalid JSON`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
body.Variables = parsedJson;
|
||||
} else {
|
||||
const variables = (this.getNodeParameter('variablesUi', i) as IDataObject).variablesValues as IDataObject[] || [];
|
||||
const variables =
|
||||
((this.getNodeParameter('variablesUi', i) as IDataObject)
|
||||
.variablesValues as IDataObject[]) || [];
|
||||
for (const variable of variables) {
|
||||
body.Variables![variable.name as string] = variable.value;
|
||||
}
|
||||
@@ -204,9 +194,10 @@ export class Mailjet implements INodeType {
|
||||
if (additionalFields.priority) {
|
||||
body.Priority = additionalFields.priority as number;
|
||||
}
|
||||
responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', { Messages: [body] });
|
||||
responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', {
|
||||
Messages: [body],
|
||||
});
|
||||
responseData = responseData.Messages;
|
||||
|
||||
}
|
||||
//https://dev.mailjet.com/email/guides/send-api-v31/#use-a-template
|
||||
if (operation === 'sendTemplate') {
|
||||
@@ -239,11 +230,17 @@ export class Mailjet implements INodeType {
|
||||
const variablesJson = this.getNodeParameter('variablesJson', i) as string;
|
||||
const parsedJson = validateJSON(variablesJson);
|
||||
if (parsedJson === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `Parameter 'Variables (JSON)' has a invalid JSON`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Parameter 'Variables (JSON)' has a invalid JSON`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
body.Variables = parsedJson;
|
||||
} else {
|
||||
const variables = (this.getNodeParameter('variablesUi', i) as IDataObject).variablesValues as IDataObject[] || [];
|
||||
const variables =
|
||||
((this.getNodeParameter('variablesUi', i) as IDataObject)
|
||||
.variablesValues as IDataObject[]) || [];
|
||||
for (const variable of variables) {
|
||||
body.Variables![variable.name as string] = variable.value;
|
||||
}
|
||||
@@ -286,7 +283,9 @@ export class Mailjet implements INodeType {
|
||||
if (additionalFields.priority) {
|
||||
body.Priority = additionalFields.priority as number;
|
||||
}
|
||||
responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', { Messages: [body] });
|
||||
responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', {
|
||||
Messages: [body],
|
||||
});
|
||||
responseData = responseData.Messages;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
mailjetApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { mailjetApiRequest } from './GenericFunctions';
|
||||
|
||||
export class MailjetTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -77,7 +67,6 @@ export class MailjetTrigger implements INodeType {
|
||||
description: 'Determines which resource events the webhook is triggered for',
|
||||
},
|
||||
],
|
||||
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
@@ -121,7 +110,7 @@ export class MailjetTrigger implements INodeType {
|
||||
const endpoint = `/v3/rest/eventcallbackurl/${webhookData.webhookId}`;
|
||||
try {
|
||||
await mailjetApiRequest.call(this, 'DELETE', endpoint);
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
delete webhookData.webhookId;
|
||||
@@ -134,9 +123,7 @@ export class MailjetTrigger implements INodeType {
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(req.body),
|
||||
],
|
||||
workflowData: [this.helpers.returnJsonArray(req.body)],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ export const smsOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'sms',
|
||||
],
|
||||
resource: ['sms'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -26,10 +24,9 @@ export const smsOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const smsFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* sms:send */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* sms:send */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'From',
|
||||
name: 'from',
|
||||
@@ -38,15 +35,12 @@ export const smsFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'sms',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['sms'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
description: 'Customizable sender name. Should be between 3 and 11 characters in length, only alphanumeric characters are allowed.',
|
||||
description:
|
||||
'Customizable sender name. Should be between 3 and 11 characters in length, only alphanumeric characters are allowed.',
|
||||
},
|
||||
{
|
||||
displayName: 'To',
|
||||
@@ -56,15 +50,12 @@ export const smsFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'sms',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['sms'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
description: 'Message recipient. Should be between 3 and 15 characters in length. The number always starts with a plus sign followed by a country code, followed by the number. Phone numbers are expected to comply with the E.164 format.',
|
||||
description:
|
||||
'Message recipient. Should be between 3 and 15 characters in length. The number always starts with a plus sign followed by a country code, followed by the number. Phone numbers are expected to comply with the E.164 format.',
|
||||
},
|
||||
{
|
||||
displayName: 'Text',
|
||||
@@ -77,12 +68,8 @@ export const smsFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'sms',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['sms'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user