first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,92 @@
import map from 'lodash/map';
import type {
IDataObject,
IExecuteFunctions,
IHookFunctions,
IHttpRequestMethods,
ILoadOptionsFunctions,
IRequestOptions,
JsonObject,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
export async function mandrillApiRequest(
this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions,
resource: string,
method: IHttpRequestMethods,
action: string,
body: any = {},
headers?: IDataObject,
): Promise<any> {
const credentials = await this.getCredentials('mandrillApi');
const data = Object.assign({}, body, { key: credentials.apiKey });
const endpoint = 'mandrillapp.com/api/1.0';
const options: IRequestOptions = {
headers,
method,
uri: `https://${endpoint}${resource}${action}.json`,
body: data,
json: true,
};
try {
return await this.helpers.request(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export function getToEmailArray(toEmail: string): any {
let toEmailArray;
if (toEmail.split(',').length > 0) {
const array = toEmail.split(',');
toEmailArray = map(array, (email) => {
return {
email,
type: 'to',
};
});
} else {
toEmailArray = [
{
email: toEmail,
type: 'to',
},
];
}
return toEmailArray;
}
export function getGoogleAnalyticsDomainsArray(s: string): string[] {
let array: string[] = [];
if (s.split(',').length > 0) {
array = s.split(',');
} else {
array = [s];
}
return array;
}
export function getTags(s: string): any[] {
let array = [];
if (s.split(',').length > 0) {
array = s.split(',');
} else {
array = [s];
}
return array;
}
export function validateJSON(json: string | undefined): any {
let result;
try {
result = JSON.parse(json!);
} catch (exception) {
result = [];
}
return result;
}
@@ -0,0 +1,25 @@
{
"node": "n8n-nodes-base.mandrill",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Communication", "Development"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/mandrill/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.mandrill/"
}
],
"generic": [
{
"label": "Love at first sight: Ricardos n8n journey",
"icon": "❤️",
"url": "https://n8n.io/blog/love-at-first-sight-ricardos-n8n-journey/"
}
]
}
}
@@ -0,0 +1,906 @@
import isEmpty from 'lodash/isEmpty';
import map from 'lodash/map';
import moment from 'moment-timezone';
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
JsonObject,
} from 'n8n-workflow';
import { NodeConnectionTypes, NodeApiError } from 'n8n-workflow';
import {
getGoogleAnalyticsDomainsArray,
getTags,
getToEmailArray,
mandrillApiRequest,
validateJSON,
} from './GenericFunctions';
interface Attachments {
type: string;
name: string;
content: string;
}
interface Message {
html?: string;
text?: string;
subject?: string;
from_name?: string;
from_email: string;
to: string[];
important?: boolean;
track_opens?: boolean;
track_clicks?: boolean;
auto_text?: boolean;
auto_html?: boolean;
inline_css?: boolean;
url_strip_qs?: boolean;
preserve_recipients?: boolean;
view_content_link?: boolean;
async?: boolean;
subaccount?: string;
google_analytics_campaign?: string;
google_analytics_domains?: string[];
tags?: string[];
ip_pool?: string;
bcc_address?: string;
tracking_domain?: string;
signing_domain?: string;
return_path_domain?: string;
headers?: IDataObject;
metadata?: IDataObject;
global_merge_vars?: [IDataObject];
attachments?: Attachments[];
}
interface Body {
template_content: [];
template_name?: string;
message: Message;
send_at?: string;
}
type Options = IDataObject & {
html: string;
fromName?: string;
text: string;
subject?: string;
important: boolean;
trackOpens: boolean;
trackClicks: boolean;
autoText: boolean;
autoHtml: boolean;
inlineCss: boolean;
urlStripQs: boolean;
preserveRecipients: boolean;
viewContentLink: boolean;
async: boolean;
subaccount: string;
googleAnalyticsCampaign: string;
googleAnalyticsDomains?: string;
tags: string;
ipPool: string;
bccAddress: string;
trackingDomain: string;
signingDomain: string;
returnPathDomain: string;
sendAt: string;
};
export class Mandrill implements INodeType {
description: INodeTypeDescription = {
displayName: 'Mandrill',
name: 'mandrill',
icon: 'file:mandrill.svg',
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume Mandrill API',
defaults: {
name: 'Mandrill',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'mandrillApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Message',
value: 'message',
description: 'Send a message',
},
],
default: 'message',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['message'],
},
},
options: [
{
name: 'Send Template',
value: 'sendTemplate',
description: 'Send message based on template',
action: 'Send a message based on a template',
},
{
name: 'Send HTML',
value: 'sendHtml',
description: 'Send message based on HTML',
action: 'Send a message based on HTML',
},
],
default: 'sendTemplate',
},
{
displayName: 'Template Name or ID',
name: 'template',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTemplates',
},
displayOptions: {
show: {
operation: ['sendTemplate'],
},
},
default: '',
options: [],
required: true,
description:
'The template you want to send. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'From Email',
name: 'fromEmail',
type: 'string',
default: '',
required: true,
placeholder: 'Admin <example@yourdomain.com>',
description: 'Email address of the sender optional with name',
displayOptions: {
show: {
operation: ['sendHtml', 'sendTemplate'],
},
},
},
{
displayName: 'To Email',
name: 'toEmail',
type: 'string',
default: '',
required: true,
placeholder: 'info@example.com',
description: 'Email address of the recipient. Multiple ones can be separated by comma.',
displayOptions: {
show: {
operation: ['sendHtml', 'sendTemplate'],
},
},
},
{
displayName: 'JSON Parameters',
name: 'jsonParameters',
type: 'boolean',
default: false,
displayOptions: {
show: {
operation: ['sendHtml', 'sendTemplate'],
},
},
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
displayOptions: {
show: {
operation: ['sendHtml', 'sendTemplate'],
},
},
options: [
{
displayName: 'Async',
name: 'async',
type: 'boolean',
default: false,
description:
'Whether to enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the \'reject\' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.',
},
{
displayName: 'Auto Text',
name: 'autoText',
type: 'boolean',
default: false,
description:
'Whether or not to automatically generate a text part for messages that are not given text',
},
{
displayName: 'Auto HTML',
name: 'autoHtml',
type: 'boolean',
default: false,
description:
'Whether or not to automatically generate an HTML part for messages that are not given HTML',
},
{
displayName: 'BCC Address',
name: 'bccAddress',
type: 'string',
default: '',
placeholder: 'message.bcc_address@example.com',
description: "An optional address to receive an exact copy of each recipient's email",
},
{
displayName: 'From Name',
name: 'fromName',
type: 'string',
default: '',
placeholder: 'John Doe',
description: 'Optional from name to be used',
},
{
displayName: 'Google Analytics Campaign',
name: 'googleAnalyticsCampaign',
type: 'string',
default: '',
placeholder: '',
description:
"Optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.",
},
{
displayName: 'Google Analytics Domains',
name: 'googleAnalyticsDomains',
type: 'string',
default: '',
placeholder: '',
description:
'An array of strings separated by a comma (,) indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically',
},
{
displayName: 'HTML',
name: 'html',
type: 'string',
default: '',
typeOptions: {
rows: 5,
},
options: [],
description: 'The html you want to send',
},
{
displayName: 'Important',
name: 'important',
type: 'boolean',
default: false,
description:
'Whether or not this message is important, and should be delivered ahead of non-important messages',
},
{
displayName: 'Inline CSS',
name: 'inlineCss',
type: 'boolean',
default: false,
description:
'Whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size',
},
{
displayName: 'Ip Pool',
name: 'ipPool',
type: 'string',
default: '',
placeholder: '',
description:
'The name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.',
},
{
displayName: 'Preserve Recipients',
name: 'preserveRecipients',
type: 'boolean',
default: false,
description: 'Whether or not to expose all recipients in to "To" header for each email',
},
{
displayName: 'Return Path Domain',
name: 'returnPathDomain',
type: 'string',
default: '',
placeholder: '',
description: "A custom domain to use for the messages's return-path",
},
{
displayName: 'Sent At',
name: 'sendAt',
type: 'dateTime',
default: '',
placeholder: '',
description:
'When this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.',
},
{
displayName: 'Signing Domain',
name: 'signingDomain',
type: 'string',
default: '',
placeholder: '',
description:
'A custom domain to use for SPF/DKIM signing instead of mandrill(for "via" or "on behalf of" in email clients)',
},
{
displayName: 'Subaccount',
name: 'subAccount',
type: 'string',
default: '',
placeholder: '',
description:
'The unique ID of a subaccount for this message - must already exist or will fail with an error',
},
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
placeholder: 'My subject line',
description: 'Subject line of the email',
},
{
displayName: 'Tags',
name: 'tags',
type: 'string',
default: '',
placeholder: '',
description:
'An array of string separated by a comma (,) to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.',
},
{
displayName: 'Text',
name: 'text',
type: 'string',
default: '',
typeOptions: {
rows: 5,
},
options: [],
description: 'Example text content',
},
{
displayName: 'Track Clicks',
name: 'trackClicks',
type: 'boolean',
default: false,
description: 'Whether or not to turn on click tracking for the message',
},
{
displayName: 'Track Opens',
name: 'trackOpens',
type: 'boolean',
default: false,
description: 'Whether or not to turn on open tracking for the message',
},
{
displayName: 'Tracking Domain',
name: 'trackingDomain',
type: 'string',
default: '',
placeholder: '',
description:
'A custom domain to use for tracking opens and clicks instead of mandrillapp.com',
},
{
displayName: 'Url Strip Qs',
name: 'urlStripQs',
type: 'boolean',
default: false,
description:
'Whether or not to strip the query string from URLs when aggregating tracked URL data',
},
{
displayName: 'View Content Link',
name: 'viewContentLink',
type: 'boolean',
default: false,
description: 'Whether to remove content logging for sensitive emails',
},
],
},
{
displayName: 'Merge Vars',
name: 'mergeVarsJson',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
placeholder: `[
{
{ "name": "name", "content": "content" }
}
]`,
displayOptions: {
show: {
jsonParameters: [true],
},
},
description: 'Global merge variables',
},
{
displayName: 'Merge Vars',
name: 'mergeVarsUi',
placeholder: 'Add Merge Vars',
type: 'fixedCollection',
default: {},
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [false],
},
},
description: 'Per-recipient merge variables',
options: [
{
name: 'mergeVarsValues',
displayName: 'Vars',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'Content',
name: 'content',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Metadata',
name: 'metadataUi',
placeholder: 'Add Metadata',
type: 'fixedCollection',
default: {},
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [false],
},
},
description:
'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.',
options: [
{
name: 'metadataValues',
displayName: 'Metadata',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: 'Name of the metadata key to add.',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: 'Value to set for the metadata key',
},
],
},
],
},
{
displayName: 'Metadata',
name: 'metadataJson',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
jsonParameters: [true],
},
},
default: '',
placeholder: `{
"website": "www.example.com"
}`,
description:
'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.',
},
{
displayName: 'Attachments',
name: 'attachmentsJson',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
jsonParameters: [true],
},
},
default: '',
placeholder: `[
{
"type": "text/plain" (the MIME type of the attachment),
"name": "myfile.txt" (the file name of the attachment),
"content": "ZXhhbXBsZSBmaWxl" (the content of the attachment as a base64-encoded string)
}
]`,
description: 'An array of supported attachments to add to the message',
},
{
displayName: 'Attachments',
name: 'attachmentsUi',
placeholder: 'Add Attachments',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [false],
},
},
options: [
{
name: 'attachmentsValues',
displayName: 'Attachments Values',
values: [
{
displayName: 'Type',
name: 'type',
type: 'string',
default: '',
placeholder: 'text/plain',
description: 'The MIME type of the attachment',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
placeholder: 'myfile.txt',
description: 'The file name of the attachment',
},
{
displayName: 'Content',
name: 'content',
type: 'string',
default: '',
placeholder: 'ZXhhbXBsZSBmaWxl',
description: 'The content of the attachment as a base64-encoded string',
},
],
},
{
name: 'attachmentsBinary',
displayName: 'Attachments Binary',
values: [
{
displayName: 'Property',
name: 'property',
type: 'string',
default: '',
description:
'Name of the binary properties which contain data which should be added to email as attachment',
},
],
},
],
default: {},
description: 'Array of supported attachments to add to the message',
},
{
displayName: 'Headers',
name: 'headersJson',
type: 'json',
default: '',
placeholder: `{
"Reply-To": "replies@example.com"
}`,
displayOptions: {
show: {
jsonParameters: [true],
},
},
typeOptions: {
alwaysOpenEditWindow: true,
},
description: 'Optional extra headers to add to the message (most headers are allowed)',
},
{
displayName: 'Headers',
name: 'headersUi',
placeholder: 'Add Headers',
type: 'fixedCollection',
default: {},
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [false],
},
},
options: [
{
name: 'headersValues',
displayName: 'Values',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
},
],
},
],
description: 'Optional extra headers to add to the message (most headers are allowed)',
},
],
};
methods = {
loadOptions: {
// Get all the available templates to display them to user so that they can
// select them easily
async getTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
let templates;
try {
templates = await mandrillApiRequest.call(this, '/templates', 'POST', '/list');
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
for (const template of templates) {
const templateName = template.name;
const templateSlug = template.slug;
returnData.push({
name: templateName,
value: templateSlug,
});
}
return returnData;
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const returnData: INodeExecutionData[] = [];
const items = this.getInputData();
let responseData;
let emailSentResponse;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < items.length; i++) {
try {
if (resource === 'message') {
const options = this.getNodeParameter('options', i) as Options;
const fromEmail = this.getNodeParameter('fromEmail', i) as string;
const toEmail = this.getNodeParameter('toEmail', i) as string;
const jsonActive = this.getNodeParameter('jsonParameters', i);
const toEmailArray = getToEmailArray(toEmail);
const message: Message = {
html: options.html ? options.html : '',
text: options.text ? options.text : '',
subject: options.subject ? options.subject : '',
from_email: fromEmail,
to: toEmailArray,
important: options.important ? options.important : false,
track_opens: options.trackOpens ? options.trackOpens : false,
track_clicks: options.trackClicks ? options.trackClicks : false,
auto_text: options.autoText ? options.autoText : false,
auto_html: options.autoHtml ? options.autoHtml : false,
inline_css: options.inlineCss ? options.inlineCss : false,
url_strip_qs: options.urlStripQs ? options.urlStripQs : false,
preserve_recipients: options.preserveRecipients ? options.preserveRecipients : false,
view_content_link: options.viewContentLink ? options.viewContentLink : false,
async: options.async ? options.async : false,
google_analytics_campaign: options.googleAnalyticsCampaign
? options.googleAnalyticsCampaign
: '',
ip_pool: options.ipPool ? options.ipPool : '',
bcc_address: options.bccAddress ? options.bccAddress : '',
tracking_domain: options.trackingDomain ? options.trackingDomain : '',
signing_domain: options.signingDomain ? options.signingDomain : '',
return_path_domain: options.returnPathDomain ? options.returnPathDomain : '',
};
if (options.googleAnalyticsDomains) {
message.google_analytics_domains = getGoogleAnalyticsDomainsArray(
options.googleAnalyticsDomains,
);
}
if (options.tags) {
message.tags = getTags(options.tags);
}
if (options.fromName) {
message.from_name = options.fromName;
}
if (options.subAccount) {
message.subaccount = options.subAccount.toString();
}
const body: Body = {
template_content: [],
message,
};
if (options.sendAt) {
body.send_at = moment(options.sendAt).utc().format('YYYY-MM-DD HH:mm:ss');
}
if (jsonActive) {
body.message.headers = validateJSON(this.getNodeParameter('headersJson', i) as string);
body.message.metadata = validateJSON(
this.getNodeParameter('metadataJson', i) as string,
);
body.message.global_merge_vars = validateJSON(
this.getNodeParameter('mergeVarsJson', i) as string,
);
body.message.attachments = validateJSON(
this.getNodeParameter('attachmentsJson', i) as string,
);
} else {
const headersUi = this.getNodeParameter('headersUi', i) as IDataObject;
if (!isEmpty(headersUi)) {
// @ts-ignore
body.message.headers = map(headersUi.headersValues, (o) => {
const aux: IDataObject = {};
// @ts-ignore
aux[o.name] = o.value;
return aux;
});
}
const metadataUi = this.getNodeParameter('metadataUi', i) as IDataObject;
if (!isEmpty(metadataUi)) {
// @ts-ignore
body.message.metadata = map(metadataUi.metadataValues, (o: IDataObject) => {
const aux: IDataObject = {};
aux[o.name as string] = o.value;
return aux;
});
}
const mergeVarsUi = this.getNodeParameter('mergeVarsUi', i) as IDataObject;
if (!isEmpty(mergeVarsUi)) {
// @ts-ignore
body.message.global_merge_vars = map(
// @ts-ignore
mergeVarsUi.mergeVarsValues,
(o: IDataObject) => {
const aux: IDataObject = {};
aux.name = o.name;
aux.content = o.content;
return aux;
},
);
}
const attachmentsUi = this.getNodeParameter('attachmentsUi', i) as IDataObject;
let attachmentsBinary: Attachments[] = [],
attachmentsValues: Attachments[] = [];
if (!isEmpty(attachmentsUi)) {
if (
attachmentsUi.hasOwnProperty('attachmentsValues') &&
!isEmpty(attachmentsUi.attachmentsValues)
) {
// @ts-ignore
attachmentsValues = map(attachmentsUi.attachmentsValues, (o: IDataObject) => {
const aux: IDataObject = {};
aux.name = o.name;
aux.content = o.content;
aux.type = o.type;
return aux;
});
}
if (
attachmentsUi.hasOwnProperty('attachmentsBinary') &&
!isEmpty(attachmentsUi.attachmentsBinary) &&
items[i].binary
) {
// @ts-ignore
attachmentsBinary = map(attachmentsUi.attachmentsBinary, (o: IDataObject) => {
if (items[i].binary!.hasOwnProperty(o.property as string)) {
const aux: IDataObject = {};
aux.name = items[i].binary![o.property as string].fileName || 'unknown';
aux.content = items[i].binary![o.property as string].data;
aux.type = items[i].binary![o.property as string].mimeType;
return aux;
}
});
}
}
body.message.attachments = attachmentsBinary.concat(attachmentsValues);
}
if (operation === 'sendTemplate') {
const template = this.getNodeParameter('template', i) as string;
body.template_name = template;
emailSentResponse = mandrillApiRequest.call(
this,
'/messages',
'POST',
'/send-template',
body,
);
} else if (operation === 'sendHtml') {
emailSentResponse = mandrillApiRequest.call(this, '/messages', 'POST', '/send', body);
}
responseData = await emailSentResponse;
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
const executionErrorData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionErrorData);
continue;
}
throw error;
}
}
return [returnData];
}
}
@@ -0,0 +1,15 @@
{
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"email": {
"type": "string"
},
"status": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,15 @@
{
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"email": {
"type": "string"
},
"status": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#fff" fill-rule="evenodd" stroke="#000" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 66 53"><use xlink:href="#a" x=".5" y=".5"/><symbol id="a" overflow="visible"><g fill-rule="nonzero" stroke="none"><path fill="#1a1918" d="M32.05 27.487 13.287 0v23.53l10.65 15.72 8.114-11.765"/><path fill="#ed9d4a" d="m32.05 27.487 8.013 11.867 10.65-15.518V0z"/><path fill="#ba7730" d="m31.95 27.487-8.013 11.765 8.013 11.765 8.013-11.765z"/><path fill="#4cb2d4" d="M0 51.12h13.287V23.633L0 4.058z"/><path fill="#1c82ad" d="M0 0v4.057L13.287 23.53V0z"/><path fill="#c02439" d="M50.713 23.836V51.12H64V4.362z"/><path fill="#8f212f" d="M64 0H50.713v23.734L64 4.26z"/></g></symbol></svg>

After

Width:  |  Height:  |  Size: 774 B

@@ -0,0 +1,143 @@
import {
getGoogleAnalyticsDomainsArray,
getTags,
getToEmailArray,
validateJSON,
} from '../GenericFunctions';
describe('Mandrill GenericFunctions', () => {
describe('getToEmailArray', () => {
it('should convert single email to array', () => {
const result = getToEmailArray('test@example.com');
expect(result).toEqual([
{
email: 'test@example.com',
type: 'to',
},
]);
});
it('should convert comma-separated emails to array', () => {
const result = getToEmailArray('test1@example.com,test2@example.com,test3@example.com');
expect(result).toEqual([
{
email: 'test1@example.com',
type: 'to',
},
{
email: 'test2@example.com',
type: 'to',
},
{
email: 'test3@example.com',
type: 'to',
},
]);
});
it('should handle emails with spaces after commas', () => {
const result = getToEmailArray('test1@example.com, test2@example.com, test3@example.com');
expect(result).toEqual([
{
email: 'test1@example.com',
type: 'to',
},
{
email: ' test2@example.com',
type: 'to',
},
{
email: ' test3@example.com',
type: 'to',
},
]);
});
});
describe('getGoogleAnalyticsDomainsArray', () => {
it('should convert single domain to array', () => {
const result = getGoogleAnalyticsDomainsArray('example.com');
expect(result).toEqual(['example.com']);
});
it('should convert comma-separated domains to array', () => {
const result = getGoogleAnalyticsDomainsArray('example.com,test.com,demo.org');
expect(result).toEqual(['example.com', 'test.com', 'demo.org']);
});
it('should handle domains with spaces after commas', () => {
const result = getGoogleAnalyticsDomainsArray('example.com, test.com, demo.org');
expect(result).toEqual(['example.com', ' test.com', ' demo.org']);
});
it('should handle empty string', () => {
const result = getGoogleAnalyticsDomainsArray('');
expect(result).toEqual(['']);
});
});
describe('getTags', () => {
it('should convert single tag to array', () => {
const result = getTags('newsletter');
expect(result).toEqual(['newsletter']);
});
it('should convert comma-separated tags to array', () => {
const result = getTags('newsletter,marketing,promotion');
expect(result).toEqual(['newsletter', 'marketing', 'promotion']);
});
it('should handle tags with spaces after commas', () => {
const result = getTags('newsletter, marketing, promotion');
expect(result).toEqual(['newsletter', ' marketing', ' promotion']);
});
it('should handle empty string', () => {
const result = getTags('');
expect(result).toEqual(['']);
});
});
describe('validateJSON', () => {
it('should parse valid JSON object', () => {
const result = validateJSON('{"Test": "value", "number": 123}');
expect(result).toEqual({ Test: 'value', number: 123 });
});
it('should parse valid JSON array', () => {
const result = validateJSON('[{"name": "Test", "value": "data"}]');
expect(result).toEqual([{ name: 'Test', value: 'data' }]);
});
it('should return empty array for invalid JSON', () => {
const result = validateJSON('invalid json');
expect(result).toEqual([]);
});
it('should return empty array for undefined input', () => {
const result = validateJSON(undefined);
expect(result).toEqual([]);
});
it('should return null for null JSON string', () => {
const result = validateJSON('null');
expect(result).toEqual(null);
});
it('should parse nested JSON correctly', () => {
const result = validateJSON('{"metadata": {"key": "value"}, "array": [1, 2, 3]}');
expect(result).toEqual({
metadata: { key: 'value' },
array: [1, 2, 3],
});
});
it('should handle JSON with special characters', () => {
const result = validateJSON('{"message": "Hello\\nWorld\\t!", "emoji": "🎉"}');
expect(result).toEqual({
message: 'Hello\nWorld\t!',
emoji: '🎉',
});
});
});
});
@@ -0,0 +1,101 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import { mock, mockDeep } from 'jest-mock-extended';
import type { ILoadOptionsFunctions, INode } from 'n8n-workflow';
import nock from 'nock';
import { Mandrill } from '../Mandrill.node';
describe('Test Mandrill Node', () => {
describe('Messages', () => {
const mandrillNock = nock('https://mandrillapp.com/api/1.0');
beforeAll(() => {
// Mock sendTemplate API call with subaccount verification
mandrillNock
.post('/messages/send-template.json', (body) => {
// Verify that subaccount is properly passed to the API
return (
body.message &&
body.message.subaccount === 'test-subaccount' &&
body.template_name === 'test-template'
);
})
.reply(200, [
{
email: 'recipient@example.com',
status: 'sent',
reject_reason: null,
_id: 'test-message-id-456',
},
]);
// Mock sendTemplate API call specifically for subaccount regression test
mandrillNock
.post('/messages/send-template.json', (body) => {
// Verify regression test scenario: subaccount is properly passed
return (
body.message &&
body.message.subaccount === 'regression-test-subaccount' &&
body.template_name === 'test-template-subaccount'
);
})
.reply(200, [
{
email: 'recipient@example.com',
status: 'sent',
reject_reason: null,
_id: 'test-subaccount-message-id',
},
]);
// Mock sendHtml API call
mandrillNock.post('/messages/send.json').reply(200, [
{
email: 'recipient@example.com',
status: 'rejected',
_id: 'test-message-id-123',
reject_reason: 'global-block',
queued_reason: null,
},
]);
});
afterAll(() => mandrillNock.done());
new NodeTestHarness().setupTests({
workflowFiles: [
'sendTemplate.workflow.json',
'sendTemplateWithSubaccount.workflow.json',
'sendHtml.workflow.json',
],
});
});
describe('loadOptions', () => {
describe('getTemplates', () => {
it('should return a list of Mandrill templates', async () => {
const mandrill = new Mandrill();
const loadOptionsFunctions = mockDeep<ILoadOptionsFunctions>();
loadOptionsFunctions.getNode.mockReturnValue(mock<INode>());
loadOptionsFunctions.getCredentials.mockResolvedValue({ apiKey: 'test-api-key' });
loadOptionsFunctions.helpers.request.mockResolvedValue([
{
slug: 'template-1',
name: 'Test Template 1',
},
{
slug: 'template-2',
name: 'Test Template 2',
},
]);
const result = await mandrill.methods.loadOptions.getTemplates.call(loadOptionsFunctions);
expect(result).toEqual([
{ name: 'Test Template 1', value: 'template-1' },
{ name: 'Test Template 2', value: 'template-2' },
]);
});
});
});
});
@@ -0,0 +1,72 @@
{
"name": "sendHtml",
"nodes": [
{
"parameters": {},
"id": "test-trigger-node-id",
"name": "When clicking 'Execute workflow'",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0]
},
{
"parameters": {
"operation": "sendHtml",
"fromEmail": "sender@example.com",
"toEmail": "recipient@example.com",
"options": {
"html": "<h1>Test HTML Content</h1>",
"subject": "Test HTML Subject"
}
},
"id": "test-mandrill-node-id",
"name": "Mandrill",
"type": "n8n-nodes-base.mandrill",
"typeVersion": 1,
"position": [220, 0],
"credentials": {
"mandrillApi": {
"id": "test-credentials-id",
"name": "Test Mandrill API"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "Mandrill",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"Mandrill": [
{
"json": {
"email": "recipient@example.com",
"status": "rejected",
"_id": "test-message-id-123",
"reject_reason": "global-block",
"queued_reason": null
}
}
]
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "test-version-id",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "test-instance-id"
},
"id": "test-workflow-id-2",
"tags": []
}
@@ -0,0 +1,71 @@
{
"name": "sendTemplate",
"nodes": [
{
"parameters": {},
"id": "test-trigger-node-id",
"name": "When clicking 'Execute workflow'",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0]
},
{
"parameters": {
"resource": "message",
"operation": "sendTemplate",
"template": "test-template",
"fromEmail": "sender@example.com",
"toEmail": "recipient@example.com",
"options": {
"subAccount": "test-subaccount"
}
},
"id": "test-mandrill-node-id",
"name": "Mandrill",
"type": "n8n-nodes-base.mandrill",
"typeVersion": 1,
"position": [220, 0],
"credentials": {
"mandrillApi": {
"id": "test-credentials-id",
"name": "Test Mandrill API"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "Mandrill",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"Mandrill": [
{
"json": {
"email": "recipient@example.com",
"status": "sent",
"reject_reason": null,
"_id": "test-message-id-456"
}
}
]
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "test-version-id",
"meta": {
"instanceId": "test-instance"
},
"id": "test-workflow-id",
"tags": []
}
@@ -0,0 +1,72 @@
{
"name": "sendTemplateWithSubaccount",
"nodes": [
{
"parameters": {},
"id": "test-trigger-node-id",
"name": "When clicking 'Execute workflow'",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0]
},
{
"parameters": {
"resource": "message",
"operation": "sendTemplate",
"template": "test-template-subaccount",
"fromEmail": "sender@example.com",
"toEmail": "recipient@example.com",
"options": {
"subAccount": "regression-test-subaccount",
"subject": "Testing subaccount functionality"
}
},
"id": "test-mandrill-node-id",
"name": "Mandrill",
"type": "n8n-nodes-base.mandrill",
"typeVersion": 1,
"position": [220, 0],
"credentials": {
"mandrillApi": {
"id": "test-credentials-id",
"name": "Test Mandrill API"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "Mandrill",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {
"Mandrill": [
{
"json": {
"email": "recipient@example.com",
"status": "sent",
"reject_reason": null,
"_id": "test-subaccount-message-id"
}
}
]
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "test-version-id",
"meta": {
"instanceId": "test-instance"
},
"id": "test-workflow-subaccount-id",
"tags": []
}