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,35 @@
export interface CustomField {
name: string;
key: string;
}
export interface SubscriberFields {
city: string | null;
company: string | null;
country: string | null;
last_name: string | null;
name: string | null;
phone: string | null;
state: string | null;
z_i_p: string | null;
}
export interface Subscriber {
id: string;
email: string;
status: string;
source: string;
sent: number;
opens_count: number;
clicks_count: number;
open_rate: number;
click_rate: number;
ip_address: string | null;
subscribed_at: string;
unsubscribed_at: string | null;
created_at: string;
updated_at: string;
fields: SubscriberFields;
opted_in_at: string | null;
optin_ip: string | null;
}
@@ -0,0 +1,179 @@
import {
type IHookFunctions,
type IWebhookFunctions,
type IDataObject,
type INodeType,
type INodeTypeDescription,
type IWebhookResponseData,
type INodeTypeBaseDescription,
NodeConnectionTypes,
} from 'n8n-workflow';
import { mailerliteApiRequest } from '../GenericFunctions';
export class MailerLiteTriggerV2 implements INodeType {
description: INodeTypeDescription;
constructor(baseDescription: INodeTypeBaseDescription) {
this.description = {
...baseDescription,
displayName: 'MailerLite Trigger',
name: 'mailerLiteTrigger',
group: ['trigger'],
version: [2],
description: 'Starts the workflow when MailerLite events occur',
defaults: {
name: 'MailerLite Trigger',
},
inputs: [],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'mailerLiteApi',
required: true,
},
],
webhooks: [
{
name: 'default',
httpMethod: 'POST',
responseMode: 'onReceived',
path: 'webhook',
},
],
properties: [
{
displayName: 'Events',
name: 'events',
type: 'multiOptions',
options: [
{
name: 'Campaign Sent',
value: 'campaign.sent',
description: 'Fired when campaign is sent',
},
{
name: 'Subscriber Added to Group',
value: 'subscriber.added_to_group',
description: 'Fired when a subscriber is added to a group',
},
{
name: 'Subscriber Automation Completed',
value: 'subscriber.automation_completed',
description: 'Fired when subscriber finishes automation',
},
{
name: 'Subscriber Automation Triggered',
value: 'subscriber.automation_triggered',
description: 'Fired when subscriber starts automation',
},
{
name: 'Subscriber Bounced',
value: 'subscriber.bounced',
description: 'Fired when an email address bounces',
},
{
name: 'Subscriber Created',
value: 'subscriber.created',
description: 'Fired when a new subscriber is added to an account',
},
{
name: 'Subscriber Removed From Group',
value: 'subscriber.removed_from_group',
description: 'Fired when a subscriber is removed from a group',
},
{
name: 'Subscriber Spam Reported',
value: 'subscriber.spam_reported',
description: 'Fired when subscriber marks a campaign as a spam',
},
{
name: 'Subscriber Unsubscribe',
value: 'subscriber.unsubscribed',
description: 'Fired when a subscriber becomes unsubscribed',
},
{
name: 'Subscriber Updated',
value: 'subscriber.updated',
description: "Fired when any of the subscriber's custom fields are updated",
},
],
required: true,
default: [],
description: 'The events to listen to',
},
],
};
}
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const webhookData = this.getWorkflowStaticData('node');
const events = this.getNodeParameter('events') as string[];
// Check all the webhooks which exist already if it is identical to the
// one that is supposed to get created.
const endpoint = '/webhooks';
const { data } = await mailerliteApiRequest.call(this, 'GET', endpoint, {});
for (const webhook of data) {
if (webhook.url === webhookUrl && webhook.events === events) {
// Set webhook-id to be sure that it can be deleted
webhookData.webhookId = webhook.id as string;
return true;
}
}
return false;
},
async create(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
const webhookUrl = this.getNodeWebhookUrl('default');
const events = this.getNodeParameter('events') as string[];
const endpoint = '/webhooks';
const body = {
url: webhookUrl,
events,
};
const { data } = await mailerliteApiRequest.call(this, 'POST', endpoint, body);
if (data.id === undefined) {
// Required data is missing so was not successful
return false;
}
webhookData.webhookId = data.id as string;
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
if (webhookData.webhookId !== undefined) {
const endpoint = `/webhooks/${webhookData.webhookId}`;
try {
await mailerliteApiRequest.call(this, 'DELETE', endpoint);
} catch (error) {
return false;
}
// Remove from the static workflow data so that it is clear
// that no webhooks are registered anymore
delete webhookData.webhookId;
}
return true;
},
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const body = this.getBodyData();
const data = body.fields as IDataObject[];
return {
workflowData: [this.helpers.returnJsonArray(data)],
};
}
}
@@ -0,0 +1,207 @@
import type {
IExecuteFunctions,
IDataObject,
INodeExecutionData,
INodeType,
INodeTypeDescription,
INodeTypeBaseDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes } from 'n8n-workflow';
import type { Subscriber } from './MailerLite.Interface';
import { subscriberFields, subscriberOperations } from './SubscriberDescription';
import {
getCustomFields,
mailerliteApiRequest,
mailerliteApiRequestAllItems,
} from '../GenericFunctions';
export class MailerLiteV2 implements INodeType {
description: INodeTypeDescription;
constructor(baseDescription: INodeTypeBaseDescription) {
this.description = {
...baseDescription,
displayName: 'MailerLite',
name: 'mailerLite',
group: ['input'],
version: [2],
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume Mailer Lite API',
defaults: {
name: 'MailerLite',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'mailerLiteApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Subscriber',
value: 'subscriber',
},
],
default: 'subscriber',
},
...subscriberOperations,
...subscriberFields,
],
};
}
methods = {
loadOptions: {
getCustomFields,
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < length; i++) {
try {
if (resource === 'subscriber') {
//https://developers.mailerlite.com/reference#create-a-subscriber
if (operation === 'create') {
const email = this.getNodeParameter('email', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i);
const body: IDataObject = {
email,
fields: [],
};
Object.assign(body, additionalFields);
if (additionalFields.customFieldsUi) {
const customFieldsValues = (additionalFields.customFieldsUi as IDataObject)
.customFieldsValues as IDataObject[];
if (customFieldsValues) {
const fields = {};
for (const customFieldValue of customFieldsValues) {
//@ts-ignore
fields[customFieldValue.fieldId] = customFieldValue.value;
}
body.fields = fields;
delete body.customFieldsUi;
}
}
responseData = await mailerliteApiRequest.call(this, 'POST', '/subscribers', body);
responseData = responseData.data;
}
//https://developers.mailerlite.com/reference#single-subscriber
if (operation === 'get') {
const subscriberId = this.getNodeParameter('subscriberId', i) as string;
responseData = await mailerliteApiRequest.call(
this,
'GET',
`/subscribers/${subscriberId}`,
);
responseData = responseData.data as Subscriber[];
}
//https://developers.mailerlite.com/reference#subscribers
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
const filters = this.getNodeParameter('filters', i);
if (filters.status) {
qs['filter[status]'] = filters.status as string;
}
if (returnAll) {
responseData = await mailerliteApiRequestAllItems.call(
this,
'GET',
'/subscribers',
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', i);
responseData = await mailerliteApiRequest.call(this, 'GET', '/subscribers', {}, qs);
responseData = responseData.data;
}
}
//https://developers.mailerlite.com/reference#update-subscriber
if (operation === 'update') {
const subscriberId = this.getNodeParameter('subscriberId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i);
const body: IDataObject = {};
Object.assign(body, additionalFields);
if (additionalFields.customFieldsUi) {
const customFieldsValues = (additionalFields.customFieldsUi as IDataObject)
.customFieldsValues as IDataObject[];
if (customFieldsValues) {
const fields = {};
for (const customFieldValue of customFieldsValues) {
//@ts-ignore
fields[customFieldValue.fieldId] = customFieldValue.value;
}
body.fields = fields;
delete body.customFieldsUi;
}
}
responseData = await mailerliteApiRequest.call(
this,
'PUT',
`/subscribers/${subscriberId}`,
body,
);
}
}
} 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;
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
return [returnData];
}
}
@@ -0,0 +1,304 @@
import type { INodeProperties } from 'n8n-workflow';
export const subscriberOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['subscriber'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new subscriber',
action: 'Create a subscriber',
},
{
name: 'Get',
value: 'get',
description: 'Get an subscriber',
action: 'Get a subscriber',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many subscribers',
action: 'Get many subscribers',
},
{
name: 'Update',
value: 'update',
description: 'Update an subscriber',
action: 'Update a subscriber',
},
],
default: 'create',
},
];
export const subscriberFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* subscriber:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
required: true,
default: '',
displayOptions: {
show: {
resource: ['subscriber'],
operation: ['create'],
},
},
description: 'Email of new subscriber',
},
/* -------------------------------------------------------------------------- */
/* subscriber:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Subscriber Email',
name: 'subscriberId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['subscriber'],
operation: ['update'],
},
},
default: '',
description: 'Email of subscriber',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['subscriber'],
operation: ['update', 'create'],
},
},
options: [
{
displayName: 'Custom Fields',
name: 'customFieldsUi',
placeholder: 'Add Custom Field',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
description: 'Filter by custom fields',
default: {},
options: [
{
name: 'customFieldsValues',
displayName: 'Custom Field',
values: [
{
displayName: 'Field Name or ID',
name: 'fieldId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCustomFields',
},
default: '',
description:
'The ID of the field to add custom field to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: 'The value to set on custom field',
},
],
},
],
},
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'Active',
value: 'active',
},
{
name: 'Bounced',
value: 'bounced',
},
{
name: 'Junk',
value: 'junk',
},
{
name: 'Unconfirmed',
value: 'unconfirmed',
},
{
name: 'Unsubscribed',
value: 'unsubscribed',
},
],
default: '',
},
{
displayName: 'Subscribed At',
name: 'subscribed_at',
type: 'dateTime',
default: '',
},
{
displayName: 'IP Address',
name: 'ip_address',
type: 'string',
default: '',
},
{
displayName: 'Opted In At',
name: 'opted_in_at',
type: 'dateTime',
default: '',
},
{
displayName: 'Opt In IP',
name: 'optin_ip',
type: 'string',
default: '',
},
{
displayName: 'Unsubscribed At',
name: 'unsubscribed_at',
type: 'dateTime',
default: '',
},
],
},
/* -------------------------------------------------------------------------- */
/* subscriber:delete */
/* -------------------------------------------------------------------------- */
{
displayName: 'Subscriber Email',
name: 'subscriberId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['subscriber'],
operation: ['delete'],
},
},
default: '',
description: 'Email of subscriber to delete',
},
/* -------------------------------------------------------------------------- */
/* subscriber:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Subscriber Email',
name: 'subscriberId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['subscriber'],
operation: ['get'],
},
},
default: '',
description: 'Email of subscriber to get',
},
/* -------------------------------------------------------------------------- */
/* subscriber:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['subscriber'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['subscriber'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['subscriber'],
},
},
default: {},
options: [
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'Active',
value: 'active',
},
{
name: 'Bounced',
value: 'bounced',
},
{
name: 'Junk',
value: 'junk',
},
{
name: 'Unconfirmed',
value: 'unconfirmed',
},
{
name: 'Unsubscribed',
value: 'unsubscribed',
},
],
default: '',
},
],
},
];