AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(emailoctopus): add AI actions and output schemas (#16803)
Kishan Parmard3b2ad864dbe
diff --git a/packages/pieces/community/emailoctopus/package.json b/packages/pieces/community/emailoctopus/package.jsonindex ebc65bb424f..1c02f8aa537 100644--- a/packages/pieces/community/emailoctopus/package.json+++ b/packages/pieces/community/emailoctopus/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-emailoctopus",- "version": "0.2.1",+ "version": "0.3.0","type": "commonjs","main": "./dist/src/index.js","types": "./dist/src/index.d.ts",diff --git a/packages/pieces/community/emailoctopus/src/index.ts b/packages/pieces/community/emailoctopus/src/index.tsindex e9a33f8f5c3..d4307a2938e 100644--- a/packages/pieces/community/emailoctopus/src/index.ts+++ b/packages/pieces/community/emailoctopus/src/index.ts@@ -1,57 +1,52 @@-import { createPiece } from "@activepieces/pieces-framework";-import { emailOctopusAuth } from "./lib/common/auth";---import { addOrUpdateContact } from "./lib/actions/add-or-update-contact";-import { unsubscribeContact } from "./lib/actions/unsubscribe-contact";-import { updateContactEmail } from "./lib/actions/update-contact-email";-import { addTagToContact } from "./lib/actions/add-tag-to-contact";-import { removeTagFromContact } from "./lib/actions/remove-tag-from-contact";-import { createList } from "./lib/actions/create-list";-import { findContact } from "./lib/actions/find-contact";-import { PieceCategory } from '@activepieces/pieces-framework';---import { emailBounced } from "./lib/triggers/email-bounced";-import { emailOpened } from "./lib/triggers/email-opened";-import { emailClicked } from "./lib/triggers/email-Clicked";-import { newContact } from "./lib/triggers/new-Contact";-import { contactUnsubscribes } from "./lib/triggers/contact-Unsubscribes";-import { createCustomApiCallAction } from "@activepieces/pieces-common";-import { emailOctopusApiUrl } from "./lib/common/client";+import { createCustomApiCallAction } from '@activepieces/pieces-common';+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';+import { addOrUpdateContactAction } from './lib/actions/add-or-update-contact';+import { addTagToContactAction } from './lib/actions/add-tag-to-contact';+import { createListAction } from './lib/actions/create-list';+import { findContactAction } from './lib/actions/find-contact';+import { removeTagFromContactAction } from './lib/actions/remove-tag-from-contact';+import { unsubscribeContactAction } from './lib/actions/unsubscribe-contact';+import { updateContactEmailAction } from './lib/actions/update-contact-email';+import { emailOctopusAiActions } from './lib/actions/ai';+import { emailOctopusAuth } from './lib/auth';+import { emailOctopusClient } from './lib/common/client';+import { contactUnsubscribesTrigger } from './lib/triggers/contact-unsubscribes';+import { emailBouncedTrigger } from './lib/triggers/email-bounced';+import { emailClickedTrigger } from './lib/triggers/email-clicked';+import { emailOpenedTrigger } from './lib/triggers/email-opened';+import { newContactTrigger } from './lib/triggers/new-contact';export const emailoctopus = createPiece({- displayName: "EmailOctopus",- description: 'Email marketing platform for list management, campaign sending, tagging & unsubscribes. Automate contact management and campaign engagement tracking.',- auth: emailOctopusAuth,- minimumSupportedRelease: '0.36.1',- logoUrl: "https://cdn.activepieces.com/pieces/emailoctopus.png",- categories: [PieceCategory.MARKETING],- authors: ['Pranith124'],- actions: [- addOrUpdateContact,- unsubscribeContact,- updateContactEmail,- addTagToContact,- removeTagFromContact,- createList,- findContact ,- createCustomApiCallAction({- auth:emailOctopusAuth,- baseUrl:()=>emailOctopusApiUrl,- authMapping:async (auth)=>{- return{- Authorization:`Bearer ${auth.secret_text}`- }- }-- })- ],- triggers: [- emailBounced,- emailOpened,- emailClicked,- newContact,- contactUnsubscribes- ],-});\ No newline at end of file+ displayName: 'EmailOctopus',+ description:+ 'Email marketing platform for list management, campaign sending, tagging & unsubscribes. Automate contact management and campaign engagement tracking.',+ auth: emailOctopusAuth,+ minimumSupportedRelease: '0.88.2',+ logoUrl: 'https://cdn.activepieces.com/pieces/emailoctopus.png',+ categories: [PieceCategory.MARKETING],+ authors: ['Pranith124'],+ actions: [+ addOrUpdateContactAction,+ unsubscribeContactAction,+ updateContactEmailAction,+ addTagToContactAction,+ removeTagFromContactAction,+ createListAction,+ findContactAction,+ ...emailOctopusAiActions,+ createCustomApiCallAction({+ auth: emailOctopusAuth,+ baseUrl: () => emailOctopusClient.baseUrl(),+ authMapping: async (auth) => ({+ Authorization: `Bearer ${auth.secret_text}`,+ }),+ }),+ ],+ triggers: [+ emailBouncedTrigger,+ emailOpenedTrigger,+ emailClickedTrigger,+ newContactTrigger,+ contactUnsubscribesTrigger,+ ],+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/add-or-update-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/add-or-update-contact.tsindex 0133cb2c376..eb22b4349c8 100644--- a/packages/pieces/community/emailoctopus/src/lib/actions/add-or-update-contact.ts+++ b/packages/pieces/community/emailoctopus/src/lib/actions/add-or-update-contact.ts@@ -1,74 +1,60 @@-import { createAction, Property } from "@activepieces/pieces-framework";-import { AuthenticationType, httpClient, HttpMethod } from "@activepieces/pieces-common";-import { emailOctopusAuth } from "../common/auth";-import { emailOctopusProps } from "../common/props";+import { createAction, Property } from '@activepieces/pieces-framework';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from '../common/api';+import { emailOctopusProps } from '../common/props';+import { contactOutputSchema } from '../output-schemas';-export const addOrUpdateContact = createAction({- auth: emailOctopusAuth,- name: 'add_or_update_contact',- classification: 'WRITE',- displayName: 'Add / Update Contact',- description: 'Adds a new contact to a list or updates an existing contact if one exists.',- audience: 'both',- aiMetadata: { description: 'Upserts a contact into an EmailOctopus list by email address: creates it if absent, otherwise updates its fields, status, and tags. Use to ensure a subscriber exists or to set/refresh their details in one call. Requires the target list id and email; supplied tags are merged in (existing tags are not removed). Idempotent — repeating with the same input converges to the same contact state.', idempotent: true },- props: {- list_id: emailOctopusProps.listId(),- email_address: Property.ShortText({- displayName: 'Email Address',- description: "The contact's email address.",- required: true,- }),- fields: emailOctopusProps.fields(),- tags: Property.Array({- displayName: 'Tags',- description: 'Tags to associate with the contact. Existing tags will not be removed.',- required: false,- }),- status: Property.StaticDropdown({- displayName: 'Status',- description: 'The status of the contact.',- required: false,- options: {- options: [- { label: 'Subscribed', value: 'subscribed' },- { label: 'Unsubscribed', value: 'unsubscribed' },- { label: 'Pending', value: 'pending' },- ],- },- }),- },-- async run(context) {- const { list_id, email_address, fields, tags, status } = context.propsValue;-- const body: Record<string, unknown> = {- email_address: email_address,- };-- if (fields) {- body['fields'] = Object.fromEntries(- Object.entries(fields).filter(([, value]) => value !== null && value !== undefined && value !== '')- );- }- if (status) {- body['status'] = status;- }- if (tags && (tags as string[]).length > 0) {- body['tags'] = Object.fromEntries(- (tags as string[]).map(tag => [tag, true])- );- }-- const response = await httpClient.sendRequest({- method: HttpMethod.PUT,- url: `https://api.emailoctopus.com/lists/${list_id}/contacts`,- body: body,- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: context.auth.secret_text,- },- });-- return response.body;- },-});\ No newline at end of file+export const addOrUpdateContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'add_or_update_contact',+ outputSchema: contactOutputSchema,+ classification: 'WRITE',+ displayName: 'Add / Update Contact',+ description:+ 'Adds a new contact to a list or updates an existing contact if one exists.',+ audience: 'human',+ aiMetadata: {+ description:+ 'Upserts a contact into an EmailOctopus list by email address: creates it if absent, otherwise updates its fields, status, and tags. Use to ensure a subscriber exists or to set/refresh their details in one call. Requires the target list id and email; supplied tags are merged in (existing tags are not removed). Idempotent — repeating with the same input converges to the same contact state.',+ idempotent: true,+ },+ props: {+ list_id: emailOctopusProps.listId({ required: true }),+ email_address: Property.ShortText({+ displayName: 'Email Address',+ description: "The contact's email address.",+ required: true,+ }),+ fields: emailOctopusProps.fields({ required: true }),+ tags: Property.Array({+ displayName: 'Tags',+ description:+ 'Tags to associate with the contact. Existing tags will not be removed.',+ required: false,+ }),+ status: Property.StaticDropdown({+ displayName: 'Status',+ description: 'The status of the contact.',+ required: false,+ options: {+ options: [+ { label: 'Subscribed', value: 'subscribed' },+ { label: 'Unsubscribed', value: 'unsubscribed' },+ { label: 'Pending', value: 'pending' },+ ],+ },+ }),+ },+ async run(context) {+ const { list_id, email_address, fields, tags, status } =+ context.propsValue;+ return await emailOctopusApi.upsertContact({+ auth: context.auth,+ listId: list_id,+ emailAddress: email_address,+ fields,+ tags: tags?.map(String),+ status,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/add-tag-to-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/add-tag-to-contact.tsindex 7169d8a0839..0556b5982c4 100644--- a/packages/pieces/community/emailoctopus/src/lib/actions/add-tag-to-contact.ts+++ b/packages/pieces/community/emailoctopus/src/lib/actions/add-tag-to-contact.ts@@ -1,55 +1,44 @@-import { createAction, Property } from "@activepieces/pieces-framework";-import { HttpMethod } from "@activepieces/pieces-common";-import { createHash } from "crypto";-import { emailOctopusAuth } from "../common/auth";-import { EmailOctopusClient } from "../common/client";-import { emailOctopusProps } from "../common/props";+import { createAction, Property } from '@activepieces/pieces-framework';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from '../common/api';+import { emailOctopusProps } from '../common/props';+import { contactOutputSchema } from '../output-schemas';-export const addTagToContact = createAction({- auth: emailOctopusAuth,- name: 'add_tag_to_contact',- classification: 'WRITE',- displayName: 'Add Tag to Contact',- description: 'Add one or more tags to a contact in a specified list.',- audience: 'both',- aiMetadata: { description: 'Applies one or more tags to a contact in an EmailOctopus list, located by email address. Use to label or segment a known subscriber. Requires the list id, the contact email, and the tags to add. Idempotent — re-adding tags that are already present leaves the contact unchanged.', idempotent: true },- props: {- list_id: emailOctopusProps.listId(),- email_address: Property.ShortText({- displayName: 'Email Address',- description: "The contact's email address.",- required: true,- }),- tags: Property.Array({- displayName: 'Tags',- description: 'The tags to add to the contact.',- required: true,- }),- },-- async run(context) {- const { list_id, email_address, tags } = context.propsValue;- const client = new EmailOctopusClient(context.auth.secret_text);--- const contactId = createHash('md5')- .update(email_address.toLowerCase())- .digest('hex');--- const tagsObject = Object.fromEntries(- (tags as string[]).map(tag => [tag, true])- );-- const body = {- tags: tagsObject,- };--- return await client.makeRequest(- HttpMethod.PUT,- `/lists/${list_id}/contacts/${contactId}`,- body- );- },-});\ No newline at end of file+export const addTagToContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'add_tag_to_contact',+ outputSchema: contactOutputSchema,+ classification: 'WRITE',+ displayName: 'Add Tag to Contact',+ description: 'Add one or more tags to a contact in a specified list.',+ audience: 'human',+ aiMetadata: {+ description:+ 'Applies one or more tags to a contact in an EmailOctopus list, located by email address. Use to label or segment a known subscriber. Requires the list id, the contact email, and the tags to add. Idempotent — re-adding tags that are already present leaves the contact unchanged.',+ idempotent: true,+ },+ props: {+ list_id: emailOctopusProps.listId({ required: true }),+ email_address: Property.ShortText({+ displayName: 'Email Address',+ description: "The contact's email address.",+ required: true,+ }),+ tags: Property.Array({+ displayName: 'Tags',+ description: 'The tags to add to the contact.',+ required: true,+ }),+ },+ async run(context) {+ const { list_id, email_address, tags } = context.propsValue;+ return await emailOctopusApi.updateContact({+ auth: context.auth,+ listId: list_id,+ contact: email_address,+ update: {+ tags: Object.fromEntries(tags.map((tag) => [String(tag), true])),+ },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-contact.tsnew file mode 100644index 00000000000..4bd41373a5d--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-contact.ts@@ -0,0 +1,54 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { emailOctopusUtils } from '../../common/utils';+import { contactOutputSchema } from '../../output-schemas';++export const createContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_create_contact',+ outputSchema: contactOutputSchema,+ displayName: 'Create Contact',+ description: 'Adds a new contact to a list.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Adds a new contact to an EmailOctopus list. Fails if a contact with that email is already in the list; use Create or Update Contact to upsert instead. Returns the contact with its ID.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ emailAddress: Property.ShortText({+ displayName: 'Email Address',+ description: "The contact's email address.",+ required: true,+ }),+ fields: emailOctopusAiProps.fields({ required: false }),+ tags: Property.Array({+ displayName: 'Tags',+ description: 'Tag names to give the contact.',+ required: false,+ }),+ status: emailOctopusAiProps.status({+ required: false,+ description: 'The contact status. Defaults to subscribed.',+ }),+ },+ async run(context) {+ const { listId, emailAddress, fields, tags, status } = context.propsValue;+ const tagList = emailOctopusUtils.toStringArray({ value: tags, propName: 'Tags' });+ return await emailOctopusApi.createContact({+ auth: context.auth,+ listId,+ contact: {+ email_address: emailAddress,+ ...(fields ? { fields } : {}),+ ...(tagList.length > 0 ? { tags: tagList } : {}),+ ...(status ? { status } : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-field.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-field.tsnew file mode 100644index 00000000000..e5c20472b95--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-field.ts@@ -0,0 +1,82 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { emailOctopusUtils } from '../../common/utils';+import { createFieldOutputSchema } from '../../output-schemas';++export const createFieldAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_create_field',+ outputSchema: createFieldOutputSchema,+ displayName: 'Create Field',+ description: 'Adds a custom field to a list.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Adds a custom contact field to an EmailOctopus list. Choice fields (choice_single, choice_multiple) need Choices; other types must not have them. The field tag is what contact actions use as the key in Fields.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ label: Property.ShortText({+ displayName: 'Label',+ description: 'The human-readable label, e.g. "What is your hometown?".',+ required: true,+ }),+ tag: Property.ShortText({+ displayName: 'Tag',+ description: 'The field key used in contact Fields and in emails, e.g. "Hometown".',+ required: true,+ }),+ type: Property.StaticDropdown({+ displayName: 'Type',+ description: 'The field type.',+ required: true,+ options: {+ disabled: false,+ options: [+ { label: 'Text', value: 'text' },+ { label: 'Number', value: 'number' },+ { label: 'Date', value: 'date' },+ { label: 'Single choice', value: 'choice_single' },+ { label: 'Multiple choice', value: 'choice_multiple' },+ ],+ },+ }),+ choices: Property.Array({+ displayName: 'Choices',+ description: 'The options, for choice_single and choice_multiple fields only.',+ required: false,+ }),+ fallback: Property.ShortText({+ displayName: 'Fallback',+ description: 'Default value shown in campaigns when a contact has no value.',+ required: false,+ }),+ },+ async run(context) {+ const { listId, label, tag, type, choices, fallback } = context.propsValue;+ const choiceList = emailOctopusUtils.toStringArray({ value: choices, propName: 'Choices' });+ const isChoice = type === 'choice_single' || type === 'choice_multiple';+ if (isChoice && choiceList.length === 0) {+ throw new Error('Choices is required for choice_single and choice_multiple fields.');+ }+ if (!isChoice && choiceList.length > 0) {+ throw new Error('Choices is only allowed for choice_single and choice_multiple fields.');+ }+ return await emailOctopusApi.createField({+ auth: context.auth,+ listId,+ field: {+ label,+ tag,+ type,+ ...(isChoice ? { choices: choiceList } : {}),+ ...(fallback ? { fallback } : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-list.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-list.tsnew file mode 100644index 00000000000..1de06f3f3e9--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-list.ts@@ -0,0 +1,33 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusApi } from '../../common/api';+import { listOutputSchema } from '../../output-schemas';++export const createListAiAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_create_list',+ outputSchema: listOutputSchema,+ displayName: 'Create List',+ description: 'Creates a new mailing list.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Creates a new EmailOctopus mailing list and returns it with its ID. Each call makes a new list, even when the name matches an existing one; check List Lists first to avoid duplicates.',+ idempotent: false,+ },+ props: {+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The name of the new list.',+ required: true,+ }),+ },+ async run(context) {+ return await emailOctopusApi.createList({+ auth: context.auth,+ name: context.propsValue.name,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-tag.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-tag.tsnew file mode 100644index 00000000000..2fb967136ca--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/create-tag.ts@@ -0,0 +1,33 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { tagOutputSchema } from '../../output-schemas';++export const createTagAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_create_tag',+ outputSchema: tagOutputSchema,+ displayName: 'Create Tag',+ description: 'Creates a tag on a list.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Creates a tag on an EmailOctopus list. Fails if the tag already exists. Contact actions can also add tags directly, which creates them as needed.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ tag: Property.ShortText({+ displayName: 'Tag',+ description: 'The tag name.',+ required: true,+ }),+ },+ async run(context) {+ const { listId, tag } = context.propsValue;+ return await emailOctopusApi.createTag({ auth: context.auth, listId, tag });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-contact.tsnew file mode 100644index 00000000000..3c60bfd17bf--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-contact.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { deleteContactOutputSchema } from '../../output-schemas';++export const deleteContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_delete_contact',+ outputSchema: deleteContactOutputSchema,+ displayName: 'Delete Contact',+ description: 'Permanently deletes a contact from a list.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently deletes a contact from an EmailOctopus list, found by contact ID or email address. This is a hard delete and cannot be undone; to stop emailing someone but keep the record, use Update Contact with status unsubscribed.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ contact: emailOctopusAiProps.contact({ required: true }),+ },+ async run(context) {+ const { listId, contact } = context.propsValue;+ await emailOctopusApi.deleteContact({ auth: context.auth, listId, contact });+ return { deleted: true, list_id: listId, contact };+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-field.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-field.tsnew file mode 100644index 00000000000..f0e794702d2--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-field.ts@@ -0,0 +1,34 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { deleteFieldOrTagOutputSchema } from '../../output-schemas';++export const deleteFieldAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_delete_field',+ outputSchema: deleteFieldOrTagOutputSchema,+ displayName: 'Delete Field',+ description: 'Deletes a custom field from a list.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ "Permanently deletes a custom field from an EmailOctopus list, along with every contact's value for it. Cannot be undone.",+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ tag: Property.ShortText({+ displayName: 'Field Tag',+ description: 'The tag of the field to delete. Use Get List to see the fields.',+ required: true,+ }),+ },+ async run(context) {+ const { listId, tag } = context.propsValue;+ await emailOctopusApi.deleteField({ auth: context.auth, listId, tag });+ return { deleted: true, list_id: listId, tag };+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-list.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-list.tsnew file mode 100644index 00000000000..77d8c4d2d20--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-list.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { deleteListOutputSchema } from '../../output-schemas';++export const deleteListAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_delete_list',+ outputSchema: deleteListOutputSchema,+ displayName: 'Delete List',+ description: 'Permanently deletes a list and all its contacts.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently deletes an EmailOctopus list together with all of its contacts, fields and tags. Cannot be undone.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ },+ async run(context) {+ const { listId } = context.propsValue;+ await emailOctopusApi.deleteList({ auth: context.auth, listId });+ return { deleted: true, list_id: listId };+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-tag.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-tag.tsnew file mode 100644index 00000000000..edef62c5c8a--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/delete-tag.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { deleteFieldOrTagOutputSchema } from '../../output-schemas';++export const deleteTagAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_delete_tag',+ outputSchema: deleteFieldOrTagOutputSchema,+ displayName: 'Delete Tag',+ description: 'Deletes a tag from a list.',+ audience: 'ai',+ classification: 'DESTRUCTIVE',+ aiMetadata: {+ description:+ 'Permanently deletes a tag from an EmailOctopus list and removes it from every contact. To untag one contact, use Update Contact with Tags to Remove.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ tag: emailOctopusAiProps.tag({ required: true }),+ },+ async run(context) {+ const { listId, tag } = context.propsValue;+ await emailOctopusApi.deleteTag({ auth: context.auth, listId, tag });+ return { deleted: true, list_id: listId, tag };+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-contact-report.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-contact-report.tsnew file mode 100644index 00000000000..e248089f264--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-contact-report.ts@@ -0,0 +1,54 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { campaignContactReportOutputSchema } from '../../output-schemas';++export const getCampaignContactReportAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_get_campaign_contact_report',+ outputSchema: campaignContactReportOutputSchema,+ displayName: 'Get Campaign Contact Report',+ description: 'Lists the contacts who opened, clicked, bounced, … for a campaign.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the contacts of a sent EmailOctopus campaign that match one engagement status (sent, opened, clicked, bounced, complained, unsubscribed, not-opened, not-clicked), one page at a time. Returns `paging.next.starting_after` for the next page with the same status.',+ idempotent: true,+ },+ props: {+ campaignId: emailOctopusAiProps.campaignId({ required: true }),+ status: Property.StaticDropdown({+ displayName: 'Status',+ description: 'Which contacts to list.',+ required: true,+ options: {+ disabled: false,+ options: [+ { label: 'Sent', value: 'sent' },+ { label: 'Opened', value: 'opened' },+ { label: 'Clicked', value: 'clicked' },+ { label: 'Bounced', value: 'bounced' },+ { label: 'Complained', value: 'complained' },+ { label: 'Unsubscribed', value: 'unsubscribed' },+ { label: 'Not opened', value: 'not-opened' },+ { label: 'Not clicked', value: 'not-clicked' },+ ],+ },+ }),+ limit: emailOctopusAiProps.limit({ required: false }),+ startingAfter: emailOctopusAiProps.startingAfter({ required: false }),+ },+ async run(context) {+ const { campaignId, status, limit, startingAfter } = context.propsValue;+ return await emailOctopusApi.getCampaignContactReport({+ auth: context.auth,+ campaignId,+ status,+ limit: limit ?? undefined,+ startingAfter: startingAfter ?? undefined,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-links-report.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-links-report.tsnew file mode 100644index 00000000000..eaf3f4a4d02--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-links-report.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { campaignLinksReportOutputSchema } from '../../output-schemas';++export const getCampaignLinksReportAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_get_campaign_links_report',+ outputSchema: campaignLinksReportOutputSchema,+ displayName: 'Get Campaign Links Report',+ description: 'Gets total and unique clicks for each link in a campaign.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets the click counts (total and unique) for every link in a sent EmailOctopus campaign. To see who clicked, use Get Campaign Contact Report with status clicked.',+ idempotent: true,+ },+ props: {+ campaignId: emailOctopusAiProps.campaignId({ required: true }),+ },+ async run(context) {+ return await emailOctopusApi.getCampaignLinksReport({+ auth: context.auth,+ campaignId: context.propsValue.campaignId,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-summary-report.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-summary-report.tsnew file mode 100644index 00000000000..71eca7e4df1--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign-summary-report.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { campaignSummaryReportOutputSchema } from '../../output-schemas';++export const getCampaignSummaryReportAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_get_campaign_summary_report',+ outputSchema: campaignSummaryReportOutputSchema,+ displayName: 'Get Campaign Summary Report',+ description: 'Gets sent, open, click, bounce and unsubscribe totals for a campaign.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets the engagement totals for a sent EmailOctopus campaign: sent, opened, clicked, bounced, complained and unsubscribed. Use Get Campaign Contact Report for the contacts behind a number.',+ idempotent: true,+ },+ props: {+ campaignId: emailOctopusAiProps.campaignId({ required: true }),+ },+ async run(context) {+ return await emailOctopusApi.getCampaignSummaryReport({+ auth: context.auth,+ campaignId: context.propsValue.campaignId,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign.tsnew file mode 100644index 00000000000..fee41dd70c7--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-campaign.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { campaignOutputSchema } from '../../output-schemas';++export const getCampaignAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_get_campaign',+ outputSchema: campaignOutputSchema,+ displayName: 'Get Campaign',+ description: 'Gets one campaign with its content and recipients.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one EmailOctopus campaign by ID: status, subject, preview text, sender, target lists, content and send time. For engagement numbers use Get Campaign Summary Report.',+ idempotent: true,+ },+ props: {+ campaignId: emailOctopusAiProps.campaignId({ required: true }),+ },+ async run(context) {+ return await emailOctopusApi.getCampaign({+ auth: context.auth,+ campaignId: context.propsValue.campaignId,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-contact.tsnew file mode 100644index 00000000000..58c473e41da--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-contact.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { contactOutputSchema } from '../../output-schemas';++export const getContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_get_contact',+ outputSchema: contactOutputSchema,+ displayName: 'Get Contact',+ description: 'Gets one contact in a list by ID or email address.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one contact in an EmailOctopus list by contact ID or email address, with its fields, tags and status. Fails with 404 when the contact is not in the list. Use List Contacts to browse or filter instead.',+ idempotent: true,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ contact: emailOctopusAiProps.contact({ required: true }),+ },+ async run(context) {+ const { listId, contact } = context.propsValue;+ return await emailOctopusApi.getContact({ auth: context.auth, listId, contact });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-list.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-list.tsnew file mode 100644index 00000000000..2044c126275--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/get-list.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { listOutputSchema } from '../../output-schemas';++export const getListAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_get_list',+ outputSchema: listOutputSchema,+ displayName: 'Get List',+ description: 'Gets one list with its fields, tags and contact counts.',+ audience: 'ai',+ classification: 'READ',+ aiMetadata: {+ description:+ 'Gets one EmailOctopus list by ID, including its custom fields (tag, label, type, choices), tags and contact counts. Use it before writing contact fields, to learn the field tags and types.',+ idempotent: true,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ },+ async run(context) {+ return await emailOctopusApi.getList({+ auth: context.auth,+ listId: context.propsValue.listId,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/index.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/index.tsnew file mode 100644index 00000000000..bd2b818a415--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/index.ts@@ -0,0 +1,53 @@+import { createContactAction } from './create-contact';+import { createFieldAction } from './create-field';+import { createListAiAction } from './create-list';+import { createTagAction } from './create-tag';+import { deleteContactAction } from './delete-contact';+import { deleteFieldAction } from './delete-field';+import { deleteListAction } from './delete-list';+import { deleteTagAction } from './delete-tag';+import { getCampaignAction } from './get-campaign';+import { getCampaignContactReportAction } from './get-campaign-contact-report';+import { getCampaignLinksReportAction } from './get-campaign-links-report';+import { getCampaignSummaryReportAction } from './get-campaign-summary-report';+import { getContactAction } from './get-contact';+import { getListAction } from './get-list';+import { listCampaignsAction } from './list-campaigns';+import { listContactsAction } from './list-contacts';+import { listListsAction } from './list-lists';+import { listTagsAction } from './list-tags';+import { startAutomationAction } from './start-automation';+import { updateContactAction } from './update-contact';+import { updateContactsBatchAction } from './update-contacts-batch';+import { updateFieldAction } from './update-field';+import { updateListAction } from './update-list';+import { updateTagAction } from './update-tag';+import { upsertContactAction } from './upsert-contact';++export const emailOctopusAiActions = [+ getContactAction,+ listContactsAction,+ createContactAction,+ upsertContactAction,+ updateContactAction,+ deleteContactAction,+ updateContactsBatchAction,+ listListsAction,+ getListAction,+ createListAiAction,+ updateListAction,+ deleteListAction,+ createFieldAction,+ updateFieldAction,+ deleteFieldAction,+ listTagsAction,+ createTagAction,+ updateTagAction,+ deleteTagAction,+ listCampaignsAction,+ getCampaignAction,+ getCampaignContactReportAction,+ getCampaignLinksReportAction,+ getCampaignSummaryReportAction,+ startAutomationAction,+];diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-campaigns.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-campaigns.tsnew file mode 100644index 00000000000..531e6951f09--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-campaigns.ts@@ -0,0 +1,33 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { listCampaignsOutputSchema } from '../../output-schemas';++export const listCampaignsAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_list_campaigns',+ outputSchema: listCampaignsOutputSchema,+ displayName: 'List Campaigns',+ description: 'Lists the campaigns in the account.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists EmailOctopus campaigns one page at a time, with status, subject, sender and send time. Use it to find the campaign ID the report actions need. Returns `paging.next.starting_after` for the next page.',+ idempotent: true,+ },+ props: {+ limit: emailOctopusAiProps.limit({ required: false }),+ startingAfter: emailOctopusAiProps.startingAfter({ required: false }),+ },+ async run(context) {+ const { limit, startingAfter } = context.propsValue;+ return await emailOctopusApi.listCampaignsPage({+ auth: context.auth,+ limit: limit ?? undefined,+ startingAfter: startingAfter ?? undefined,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-contacts.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-contacts.tsnew file mode 100644index 00000000000..8889b10c429--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-contacts.ts@@ -0,0 +1,76 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { listContactsOutputSchema } from '../../output-schemas';++export const listContactsAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_list_contacts',+ outputSchema: listContactsOutputSchema,+ displayName: 'List Contacts',+ description: 'Lists contacts in a list, filtered by tag, status or dates.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists contacts in an EmailOctopus list, one page at a time, optionally filtered by tag, status and created or updated date ranges. Without a status filter EmailOctopus returns only subscribed contacts. Returns `paging.next.starting_after` to fetch the next page with the same filters.',+ idempotent: true,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ tag: emailOctopusAiProps.tag({+ required: false,+ description: 'Only contacts with this tag.',+ }),+ status: emailOctopusAiProps.status({+ required: false,+ description: 'Only contacts with this status. Defaults to subscribed.',+ }),+ createdAfter: Property.ShortText({+ displayName: 'Created On or After',+ description: 'ISO 8601 date-time, e.g. 2026-01-31T00:00:00Z.',+ required: false,+ }),+ createdBefore: Property.ShortText({+ displayName: 'Created On or Before',+ description: 'ISO 8601 date-time.',+ required: false,+ }),+ updatedAfter: Property.ShortText({+ displayName: 'Updated On or After',+ description: 'ISO 8601 date-time.',+ required: false,+ }),+ updatedBefore: Property.ShortText({+ displayName: 'Updated On or Before',+ description: 'ISO 8601 date-time.',+ required: false,+ }),+ limit: emailOctopusAiProps.limit({ required: false }),+ startingAfter: emailOctopusAiProps.startingAfter({ required: false }),+ },+ async run(context) {+ const p = context.propsValue;+ const filters = Object.fromEntries(+ Object.entries({+ tag: p.tag,+ status: p.status,+ 'created_at.gte': p.createdAfter,+ 'created_at.lte': p.createdBefore,+ 'last_updated_at.gte': p.updatedAfter,+ 'last_updated_at.lte': p.updatedBefore,+ }).filter(+ (entry): entry is [string, string] => typeof entry[1] === 'string' && entry[1] !== '',+ ),+ );+ return await emailOctopusApi.listContacts({+ auth: context.auth,+ listId: p.listId,+ filters,+ limit: p.limit ?? undefined,+ startingAfter: p.startingAfter ?? undefined,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-lists.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-lists.tsnew file mode 100644index 00000000000..20f47e0fd54--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-lists.ts@@ -0,0 +1,33 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { listListsOutputSchema } from '../../output-schemas';++export const listListsAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_list_lists',+ outputSchema: listListsOutputSchema,+ displayName: 'List Lists',+ description: 'Lists the mailing lists in the account.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ "Lists EmailOctopus mailing lists one page at a time, with each list's ID, name, fields, tags and contact counts. Use it to find the list ID other actions need. Returns `paging.next.starting_after` for the next page.",+ idempotent: true,+ },+ props: {+ limit: emailOctopusAiProps.limit({ required: false }),+ startingAfter: emailOctopusAiProps.startingAfter({ required: false }),+ },+ async run(context) {+ const { limit, startingAfter } = context.propsValue;+ return await emailOctopusApi.listListsPage({+ auth: context.auth,+ limit: limit ?? undefined,+ startingAfter: startingAfter ?? undefined,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-tags.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-tags.tsnew file mode 100644index 00000000000..b9c402f2f07--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/list-tags.ts@@ -0,0 +1,35 @@+import { createAction } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { listTagsOutputSchema } from '../../output-schemas';++export const listTagsAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_list_tags',+ outputSchema: listTagsOutputSchema,+ displayName: 'List Tags',+ description: 'Lists the tags on a list.',+ audience: 'ai',+ classification: 'SEARCH',+ aiMetadata: {+ description:+ 'Lists the tags defined on an EmailOctopus list, one page at a time. Returns `paging.next.starting_after` for the next page.',+ idempotent: true,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ limit: emailOctopusAiProps.limit({ required: false }),+ startingAfter: emailOctopusAiProps.startingAfter({ required: false }),+ },+ async run(context) {+ const { listId, limit, startingAfter } = context.propsValue;+ return await emailOctopusApi.listTags({+ auth: context.auth,+ listId,+ limit: limit ?? undefined,+ startingAfter: startingAfter ?? undefined,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/start-automation.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/start-automation.tsnew file mode 100644index 00000000000..1eecd141ab1--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/start-automation.ts@@ -0,0 +1,38 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusApi } from '../../common/api';+import { startAutomationOutputSchema } from '../../output-schemas';++export const startAutomationAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_start_automation',+ displayName: 'Start Automation',+ description: 'Starts an automation for a contact.',+ audience: 'ai',+ outputSchema: startAutomationOutputSchema,+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Queues one contact into an EmailOctopus automation whose trigger is "started via API". The contact must already be in the automation\'s list. Fails with 409 if the contact already went through it, unless the automation allows repeats.',+ idempotent: false,+ },+ props: {+ automationId: Property.ShortText({+ displayName: 'Automation ID',+ description: "The automation ID (UUID), from the automation's page in EmailOctopus.",+ required: true,+ }),+ contactId: Property.ShortText({+ displayName: 'Contact ID',+ description:+ 'The contact ID (UUID), from Get Contact or List Contacts. An email address does not work here.',+ required: true,+ }),+ },+ async run(context) {+ const { automationId, contactId } = context.propsValue;+ await emailOctopusApi.startAutomation({ auth: context.auth, automationId, contactId });+ return { queued: true, automation_id: automationId, contact_id: contactId };+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-contact.tsnew file mode 100644index 00000000000..bc4b24aecb9--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-contact.ts@@ -0,0 +1,73 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { emailOctopusUtils } from '../../common/utils';+import { contactOutputSchema } from '../../output-schemas';++export const updateContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_update_contact',+ outputSchema: contactOutputSchema,+ displayName: 'Update Contact',+ description: "Updates a contact's email, fields, tags or status.",+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Updates an existing contact in an EmailOctopus list, found by contact ID or email address. Only what you pass changes: new email, field values, fields to clear, tags to add or remove, and status (set unsubscribed to opt the contact out, subscribed to opt back in). Not idempotent when the email changes, because the old email no longer finds the contact; pass the contact ID to repeat safely.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ contact: emailOctopusAiProps.contact({ required: true }),+ newEmailAddress: Property.ShortText({+ displayName: 'New Email Address',+ description: 'A new email address for the contact.',+ required: false,+ }),+ fields: emailOctopusAiProps.fields({ required: false }),+ fieldsToClear: emailOctopusAiProps.fieldsToClear({ required: false }),+ tagsToAdd: emailOctopusAiProps.tagsToAdd({ required: false }),+ tagsToRemove: emailOctopusAiProps.tagsToRemove({ required: false }),+ status: emailOctopusAiProps.status({ required: false }),+ },+ async run(context) {+ const {+ listId,+ contact,+ newEmailAddress,+ fields,+ fieldsToClear,+ tagsToAdd,+ tagsToRemove,+ status,+ } = context.propsValue;+ const fieldChanges = emailOctopusUtils.toFieldChanges({+ fields,+ fieldsToClear: emailOctopusUtils.toStringArray({+ value: fieldsToClear,+ propName: 'Fields to Clear',+ }),+ });+ const tags = emailOctopusUtils.toTagChanges({+ tagsToAdd: emailOctopusUtils.toStringArray({ value: tagsToAdd, propName: 'Tags to Add' }),+ tagsToRemove: emailOctopusUtils.toStringArray({+ value: tagsToRemove,+ propName: 'Tags to Remove',+ }),+ });+ return await emailOctopusApi.updateContact({+ auth: context.auth,+ listId,+ contact,+ update: {+ ...(newEmailAddress ? { email_address: newEmailAddress } : {}),+ ...(fieldChanges ? { fields: fieldChanges } : {}),+ ...(tags ? { tags } : {}),+ ...(status ? { status } : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-contacts-batch.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-contacts-batch.tsnew file mode 100644index 00000000000..c1e2ad8f2ca--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-contacts-batch.ts@@ -0,0 +1,64 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { updateContactsBatchOutputSchema } from '../../output-schemas';++import type { EmailOctopusContactBatchItem } from '../../common/types';++export const updateContactsBatchAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_update_contacts_batch',+ outputSchema: updateContactsBatchOutputSchema,+ displayName: 'Update Contacts in Batch',+ description: 'Updates up to 100 contacts in a list in one call.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Updates up to 100 existing contacts in one EmailOctopus list in a single call. Each item needs the contact `id` (UUID from Get Contact or List Contacts, not an email) plus any of `email_address`, `fields`, `tags` (object of tag name to true/false) and `status`. Items that fail are returned in `failed` while the rest are applied.',+ idempotent: true,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ contacts: Property.Array({+ displayName: 'Contacts',+ description:+ '1-100 objects like {"id": "<contact UUID>", "status": "unsubscribed", "tags": {"vip": true}, "fields": {"FirstName": "Ada"}}.',+ required: true,+ }),+ },+ async run(context) {+ const { listId, contacts } = context.propsValue;+ if (contacts.length < 1 || contacts.length > 100) {+ throw new Error(`Contacts must have 1-100 items; got ${contacts.length}.`);+ }+ if (!contacts.every(isBatchItem)) {+ throw new Error('Every item in Contacts must be an object with a string "id".');+ }+ const result = await emailOctopusApi.updateContactsBatch({+ auth: context.auth,+ listId,+ contacts,+ });+ const updated = (result.success ?? []).map((item) => item.data);+ const failed = result.errors ?? [];+ return {+ success: failed.length === 0,+ updated_count: updated.length,+ updated,+ failed,+ };+ },+});++function isBatchItem(item: unknown): item is EmailOctopusContactBatchItem {+ return (+ typeof item === 'object' &&+ item !== null &&+ 'id' in item &&+ typeof item.id === 'string' &&+ item.id !== ''+ );+}diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-field.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-field.tsnew file mode 100644index 00000000000..35ba517556d--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-field.ts@@ -0,0 +1,67 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { fieldOutputSchema } from '../../output-schemas';++export const updateFieldAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_update_field',+ outputSchema: fieldOutputSchema,+ displayName: 'Update Field',+ description: "Changes a custom field's label, tag or fallback.",+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ "Changes the label, tag or fallback of a text, number or date custom field on an EmailOctopus list. Only what you pass changes; the rest is kept. The API can't change a field's type or update choice fields. Renaming the tag breaks repeats, since the old tag no longer exists.",+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ tag: Property.ShortText({+ displayName: 'Field Tag',+ description: 'The current tag of the field. Use Get List to see the fields.',+ required: true,+ }),+ newLabel: Property.ShortText({+ displayName: 'New Label',+ description: 'A new label.',+ required: false,+ }),+ newTag: Property.ShortText({+ displayName: 'New Tag',+ description: 'A new tag (key) for the field.',+ required: false,+ }),+ newFallback: Property.ShortText({+ displayName: 'New Fallback',+ description: 'A new default value shown in campaigns when a contact has no value.',+ required: false,+ }),+ },+ async run(context) {+ const { listId, tag, newLabel, newTag, newFallback } = context.propsValue;+ const list = await emailOctopusApi.getList({ auth: context.auth, listId });+ const current = list.fields.find((field) => field.tag === tag);+ if (!current) {+ throw new Error(`No field with tag "${tag}" on list ${listId}.`);+ }+ return await emailOctopusApi.updateField({+ auth: context.auth,+ listId,+ tag,+ field: {+ label: newLabel ?? current.label,+ tag: newTag ?? current.tag,+ type: current.type,+ ...(newFallback !== undefined+ ? { fallback: newFallback }+ : current.fallback+ ? { fallback: current.fallback }+ : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-list.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-list.tsnew file mode 100644index 00000000000..674c3aa8bc8--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-list.ts@@ -0,0 +1,33 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { listOutputSchema } from '../../output-schemas';++export const updateListAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_update_list',+ outputSchema: listOutputSchema,+ displayName: 'Rename List',+ description: 'Renames a mailing list.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Renames an EmailOctopus list. The name is the only list setting the API can change; manage fields and tags with their own actions.',+ idempotent: true,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The new name for the list.',+ required: true,+ }),+ },+ async run(context) {+ const { listId, name } = context.propsValue;+ return await emailOctopusApi.updateList({ auth: context.auth, listId, name });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-tag.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-tag.tsnew file mode 100644index 00000000000..c5bb43de447--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/update-tag.ts@@ -0,0 +1,34 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { tagOutputSchema } from '../../output-schemas';++export const updateTagAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_update_tag',+ outputSchema: tagOutputSchema,+ displayName: 'Rename Tag',+ description: 'Renames a tag on a list.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Renames a tag on an EmailOctopus list; contacts with the tag keep it under the new name. A repeat with the old name fails, since that tag no longer exists.',+ idempotent: false,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ tag: emailOctopusAiProps.tag({ required: true }),+ newTag: Property.ShortText({+ displayName: 'New Tag',+ description: 'The new tag name.',+ required: true,+ }),+ },+ async run(context) {+ const { listId, tag, newTag } = context.propsValue;+ return await emailOctopusApi.updateTag({ auth: context.auth, listId, tag, newTag });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/ai/upsert-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/ai/upsert-contact.tsnew file mode 100644index 00000000000..97c86ffdb49--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/actions/ai/upsert-contact.ts@@ -0,0 +1,63 @@+import { createAction, Property } from '@activepieces/pieces-framework';++import { emailOctopusAuth } from '../../auth';+import { emailOctopusAiProps } from '../../common/ai-props';+import { emailOctopusApi } from '../../common/api';+import { emailOctopusUtils } from '../../common/utils';+import { contactOutputSchema } from '../../output-schemas';++export const upsertContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'emailoctopus_upsert_contact',+ outputSchema: contactOutputSchema,+ displayName: 'Create or Update Contact',+ description: 'Creates a contact in a list, or updates it if the email already exists.',+ audience: 'ai',+ classification: 'WRITE',+ aiMetadata: {+ description:+ 'Creates a contact in an EmailOctopus list, or updates the existing contact with the same email address. Only the fields, fields to clear, tags and status you pass change. Use Create Contact when a duplicate should fail instead.',+ idempotent: true,+ },+ props: {+ listId: emailOctopusAiProps.listId({ required: true }),+ emailAddress: Property.ShortText({+ displayName: 'Email Address',+ description: "The contact's email address, used to match an existing contact.",+ required: true,+ }),+ fields: emailOctopusAiProps.fields({ required: false }),+ fieldsToClear: emailOctopusAiProps.fieldsToClear({ required: false }),+ tagsToAdd: emailOctopusAiProps.tagsToAdd({ required: false }),+ tagsToRemove: emailOctopusAiProps.tagsToRemove({ required: false }),+ status: emailOctopusAiProps.status({ required: false }),+ },+ async run(context) {+ const { listId, emailAddress, fields, fieldsToClear, tagsToAdd, tagsToRemove, status } =+ context.propsValue;+ const fieldChanges = emailOctopusUtils.toFieldChanges({+ fields,+ fieldsToClear: emailOctopusUtils.toStringArray({+ value: fieldsToClear,+ propName: 'Fields to Clear',+ }),+ });+ const tags = emailOctopusUtils.toTagChanges({+ tagsToAdd: emailOctopusUtils.toStringArray({ value: tagsToAdd, propName: 'Tags to Add' }),+ tagsToRemove: emailOctopusUtils.toStringArray({+ value: tagsToRemove,+ propName: 'Tags to Remove',+ }),+ });+ return await emailOctopusApi.putContact({+ auth: context.auth,+ listId,+ body: {+ email_address: emailAddress,+ ...(fieldChanges ? { fields: fieldChanges } : {}),+ ...(tags ? { tags } : {}),+ ...(status ? { status } : {}),+ },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/create-list.ts b/packages/pieces/community/emailoctopus/src/lib/actions/create-list.tsindex 708a432790d..19ef8603bb5 100644--- a/packages/pieces/community/emailoctopus/src/lib/actions/create-list.ts+++ b/packages/pieces/community/emailoctopus/src/lib/actions/create-list.ts@@ -1,37 +1,32 @@-import { createAction, Property } from "@activepieces/pieces-framework";-import { HttpMethod } from "@activepieces/pieces-common";-import { emailOctopusAuth } from "../common/auth";-import { EmailOctopusClient } from "../common/client";+import { createAction, Property } from '@activepieces/pieces-framework';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from '../common/api';+import { listOutputSchema } from '../output-schemas';-export const createList = createAction({- auth: emailOctopusAuth,- name: 'create_list',- classification: 'WRITE',- displayName: 'Create List',- description: 'Creates a new mailing list.',- audience: 'both',- aiMetadata: { description: 'Creates a new EmailOctopus mailing list with the given name. Use to set up a fresh list before adding contacts. Requires only a list name. Not idempotent — each call creates a separate list even if the name matches an existing one.', idempotent: false },- props: {- name: Property.ShortText({- displayName: 'List Name',- description: 'The name for the new list.',- required: true,- }),- },-- async run(context) {- const { name } = context.propsValue;- const client = new EmailOctopusClient(context.auth.secret_text);-- const body = {- name,- };--- return await client.makeRequest(- HttpMethod.POST,- `/lists`,- body- );- },-});\ No newline at end of file+export const createListAction = createAction({+ auth: emailOctopusAuth,+ name: 'create_list',+ outputSchema: listOutputSchema,+ classification: 'WRITE',+ displayName: 'Create List',+ description: 'Creates a new mailing list.',+ audience: 'human',+ aiMetadata: {+ description:+ 'Creates a new EmailOctopus mailing list with the given name. Use to set up a fresh list before adding contacts. Requires only a list name. Not idempotent — each call creates a separate list even if the name matches an existing one.',+ idempotent: false,+ },+ props: {+ name: Property.ShortText({+ displayName: 'List Name',+ description: 'The name for the new list.',+ required: true,+ }),+ },+ async run(context) {+ return await emailOctopusApi.createList({+ auth: context.auth,+ name: context.propsValue.name,+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/find-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/find-contact.tsindex 2ea1ae168d3..8d3531c7ede 100644--- a/packages/pieces/community/emailoctopus/src/lib/actions/find-contact.ts+++ b/packages/pieces/community/emailoctopus/src/lib/actions/find-contact.ts@@ -1,55 +1,40 @@-import { createAction, Property } from "@activepieces/pieces-framework";-// 👇 1. Remove `isAxiosError` and import `HttpError` instead-import { HttpError, HttpMethod } from "@activepieces/pieces-common";-import { createHash } from "crypto";-import { emailOctopusAuth } from "../common/auth";-import { EmailOctopusClient } from "../common/client";-import { emailOctopusProps } from "../common/props";+import { createAction, Property } from '@activepieces/pieces-framework';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from '../common/api';+import { emailOctopusProps } from '../common/props';+import { findContactOutputSchema } from '../output-schemas';-export const findContact = createAction({- auth: emailOctopusAuth,- name: 'find_contact',- classification: 'READ',- displayName: 'Find Contact',- description: 'Finds a contact by email address within a given list.',- audience: 'both',- aiMetadata: { description: 'Looks up a single contact by email address within a specific EmailOctopus list and reports whether it was found. Use to check existence or retrieve a contact before acting on it; a missing contact returns a found:false result rather than erroring. Requires the list id and the email. Read-only and idempotent.', idempotent: true },- props: {- list_id: emailOctopusProps.listId(),- email_address: Property.ShortText({- displayName: 'Email Address',- description: 'The email address of the contact to find.',- required: true,- }),- },-- async run(context) {- const { list_id, email_address } = context.propsValue;- const client = new EmailOctopusClient(context.auth.secret_text);-- const contactId = createHash('md5')- .update(email_address.toLowerCase())- .digest('hex');-- try {- const response = await client.makeRequest(- HttpMethod.GET,- `/lists/${list_id}/contacts/${contactId}`- );-- return {- found:true,- result:response- }- } catch (error) {-- if (error instanceof HttpError && error.response.status === 404) {- return {- found:false,- result:{}- };- }- throw error;- }- },-});\ No newline at end of file+export const findContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'find_contact',+ outputSchema: findContactOutputSchema,+ classification: 'READ',+ displayName: 'Find Contact',+ description: 'Finds a contact by email address within a given list.',+ audience: 'human',+ aiMetadata: {+ description:+ 'Looks up a single contact by email address within a specific EmailOctopus list and reports whether it was found. Use to check existence or retrieve a contact before acting on it; a missing contact returns a found:false result rather than erroring. Requires the list id and the email. Read-only and idempotent.',+ idempotent: true,+ },+ props: {+ list_id: emailOctopusProps.listId({ required: true }),+ email_address: Property.ShortText({+ displayName: 'Email Address',+ description: 'The email address of the contact to find.',+ required: true,+ }),+ },+ async run(context) {+ const { list_id, email_address } = context.propsValue;+ const contact = await emailOctopusApi.findContact({+ auth: context.auth,+ listId: list_id,+ emailAddress: email_address,+ });+ if (contact === null) {+ return { found: false, result: {} };+ }+ return { found: true, result: contact };+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/remove-tag-from-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/remove-tag-from-contact.tsindex 57b999dec03..cc7f087a38e 100644--- a/packages/pieces/community/emailoctopus/src/lib/actions/remove-tag-from-contact.ts+++ b/packages/pieces/community/emailoctopus/src/lib/actions/remove-tag-from-contact.ts@@ -1,55 +1,44 @@-import { createAction, Property } from "@activepieces/pieces-framework";-import { HttpMethod } from "@activepieces/pieces-common";-import { createHash } from "crypto";-import { emailOctopusAuth } from "../common/auth";-import { EmailOctopusClient } from "../common/client";-import { emailOctopusProps } from "../common/props";+import { createAction, Property } from '@activepieces/pieces-framework';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from '../common/api';+import { emailOctopusProps } from '../common/props';+import { contactOutputSchema } from '../output-schemas';-export const removeTagFromContact = createAction({- auth: emailOctopusAuth,- name: 'remove_tag_from_contact',- classification: 'WRITE',- displayName: 'Remove Tag from Contact',- description: 'Remove one or more tags from a contact in a specified list.',- audience: 'both',- aiMetadata: { description: 'Removes one or more tags from a contact in an EmailOctopus list, located by email address. Use to unlabel or re-segment a known subscriber. Requires the list id, the contact email, and the tags to remove. Idempotent — removing tags the contact no longer has leaves it unchanged.', idempotent: true },- props: {- list_id: emailOctopusProps.listId(),- email_address: Property.ShortText({- displayName: 'Email Address',- description: "The email address of the contact to modify.",- required: true,- }),- tags: Property.Array({- displayName: 'Tags',- description: 'The tags to remove from the contact.',- required: true,- }),- },-- async run(context) {- const { list_id, email_address, tags } = context.propsValue;- const client = new EmailOctopusClient(context.auth.secret_text);--- const contactId = createHash('md5')- .update(email_address.toLowerCase())- .digest('hex');--- const tagsObject = Object.fromEntries(- (tags as string[]).map(tag => [tag, false])- );-- const body = {- tags: tagsObject,- };--- return await client.makeRequest(- HttpMethod.PUT,- `/lists/${list_id}/contacts/${contactId}`,- body- );- },-});\ No newline at end of file+export const removeTagFromContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'remove_tag_from_contact',+ outputSchema: contactOutputSchema,+ classification: 'WRITE',+ displayName: 'Remove Tag from Contact',+ description: 'Remove one or more tags from a contact in a specified list.',+ audience: 'human',+ aiMetadata: {+ description:+ 'Removes one or more tags from a contact in an EmailOctopus list, located by email address. Use to unlabel or re-segment a known subscriber. Requires the list id, the contact email, and the tags to remove. Idempotent — removing tags the contact no longer has leaves it unchanged.',+ idempotent: true,+ },+ props: {+ list_id: emailOctopusProps.listId({ required: true }),+ email_address: Property.ShortText({+ displayName: 'Email Address',+ description: 'The email address of the contact to modify.',+ required: true,+ }),+ tags: Property.Array({+ displayName: 'Tags',+ description: 'The tags to remove from the contact.',+ required: true,+ }),+ },+ async run(context) {+ const { list_id, email_address, tags } = context.propsValue;+ return await emailOctopusApi.updateContact({+ auth: context.auth,+ listId: list_id,+ contact: email_address,+ update: {+ tags: Object.fromEntries(tags.map((tag) => [String(tag), false])),+ },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/unsubscribe-contact.ts b/packages/pieces/community/emailoctopus/src/lib/actions/unsubscribe-contact.tsindex 9198afb00a7..38c9540469c 100644--- a/packages/pieces/community/emailoctopus/src/lib/actions/unsubscribe-contact.ts+++ b/packages/pieces/community/emailoctopus/src/lib/actions/unsubscribe-contact.ts@@ -1,45 +1,37 @@-import { createAction, Property } from "@activepieces/pieces-framework";-import { HttpMethod } from "@activepieces/pieces-common";-import { createHash } from "crypto";-import { emailOctopusAuth } from "../common/auth";-import { EmailOctopusClient } from "../common/client";-import { emailOctopusProps } from "../common/props";+import { createAction, Property } from '@activepieces/pieces-framework';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from '../common/api';+import { emailOctopusProps } from '../common/props';+import { contactOutputSchema } from '../output-schemas';-export const unsubscribeContact = createAction({- auth: emailOctopusAuth,- name: 'unsubscribe_contact',- classification: 'DESTRUCTIVE',- displayName: 'Unsubscribe Contact',- description: 'Sets a contact\'s status to "Unsubscribed" in a specific list.',- audience: 'both',- aiMetadata: { description: 'Marks a contact as unsubscribed in a specific EmailOctopus list, looked up by email address. Use to opt a known subscriber out of a list. Requires the list id and the contact email. Idempotent — re-running leaves the contact unsubscribed with no additional effect.', idempotent: true },- props: {- list_id: emailOctopusProps.listId(),- email_address: Property.ShortText({- displayName: 'Email Address',- description: "The email address of the contact to unsubscribe.",- required: true,- }),- },-- async run(context) {- const { list_id, email_address } = context.propsValue;- const client = new EmailOctopusClient(context.auth.secret_text);--- const contactId = createHash('md5')- .update(email_address.toLowerCase())- .digest('hex');-- const body = {- status: 'unsubscribed',- };--- return await client.makeRequest(- HttpMethod.PUT,- `/lists/${list_id}/contacts/${contactId}`,- body- );- },-});\ No newline at end of file+export const unsubscribeContactAction = createAction({+ auth: emailOctopusAuth,+ name: 'unsubscribe_contact',+ outputSchema: contactOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Unsubscribe Contact',+ description: 'Sets a contact\'s status to "Unsubscribed" in a specific list.',+ audience: 'human',+ aiMetadata: {+ description:+ 'Marks a contact as unsubscribed in a specific EmailOctopus list, looked up by email address. Use to opt a known subscriber out of a list. Requires the list id and the contact email. Idempotent — re-running leaves the contact unsubscribed with no additional effect.',+ idempotent: true,+ },+ props: {+ list_id: emailOctopusProps.listId({ required: true }),+ email_address: Property.ShortText({+ displayName: 'Email Address',+ description: 'The email address of the contact to unsubscribe.',+ required: true,+ }),+ },+ async run(context) {+ const { list_id, email_address } = context.propsValue;+ return await emailOctopusApi.updateContact({+ auth: context.auth,+ listId: list_id,+ contact: email_address,+ update: { status: 'unsubscribed' },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/actions/update-contact-email.ts b/packages/pieces/community/emailoctopus/src/lib/actions/update-contact-email.tsindex 0f4b3e3d38d..ac1f59705f8 100644--- a/packages/pieces/community/emailoctopus/src/lib/actions/update-contact-email.ts+++ b/packages/pieces/community/emailoctopus/src/lib/actions/update-contact-email.ts@@ -1,50 +1,43 @@-import { createAction, Property } from "@activepieces/pieces-framework";-import { HttpMethod } from "@activepieces/pieces-common";-import { createHash } from "crypto";-import { emailOctopusAuth } from "../common/auth";-import { EmailOctopusClient } from "../common/client";-import { emailOctopusProps } from "../common/props";+import { createAction, Property } from '@activepieces/pieces-framework';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from '../common/api';+import { emailOctopusProps } from '../common/props';+import { contactOutputSchema } from '../output-schemas';-export const updateContactEmail = createAction({- auth: emailOctopusAuth,- name: 'update_contact_email',- classification: 'WRITE',- displayName: "Update Contact's Email Address",- description: "Change the email address of a contact in a list.",- audience: 'both',- aiMetadata: { description: "Changes a contact's email address within an EmailOctopus list, locating the contact by its current email. Use to correct or migrate a subscriber's address. Requires the list id, the current email (used to find the record), and the new email. Not idempotent — once changed, the original email no longer resolves to the contact, so a repeated call with the same inputs will not match.", idempotent: false },- props: {- list_id: emailOctopusProps.listId(),- current_email_address: Property.ShortText({- displayName: 'Current Email Address',- description: "The contact's current email address used to find them.",- required: true,- }),- new_email_address: Property.ShortText({- displayName: 'New Email Address',- description: "The new email address for the contact.",- required: true,- }),- },-- async run(context) {- const { list_id, current_email_address, new_email_address } = context.propsValue;- const client = new EmailOctopusClient(context.auth.secret_text);--- const contactId = createHash('md5')- .update(current_email_address.toLowerCase())- .digest('hex');-- const body = {- email_address: new_email_address,- };--- return await client.makeRequest(- HttpMethod.PUT,- `/lists/${list_id}/contacts/${contactId}`,- body- );- },-});\ No newline at end of file+export const updateContactEmailAction = createAction({+ auth: emailOctopusAuth,+ name: 'update_contact_email',+ outputSchema: contactOutputSchema,+ classification: 'WRITE',+ displayName: "Update Contact's Email Address",+ description: 'Change the email address of a contact in a list.',+ audience: 'human',+ aiMetadata: {+ description:+ "Changes a contact's email address within an EmailOctopus list, locating the contact by its current email. Use to correct or migrate a subscriber's address. Requires the list id, the current email (used to find the record), and the new email. Not idempotent — once changed, the original email no longer resolves to the contact, so a repeated call with the same inputs will not match.",+ idempotent: false,+ },+ props: {+ list_id: emailOctopusProps.listId({ required: true }),+ current_email_address: Property.ShortText({+ displayName: 'Current Email Address',+ description: "The contact's current email address used to find them.",+ required: true,+ }),+ new_email_address: Property.ShortText({+ displayName: 'New Email Address',+ description: 'The new email address for the contact.',+ required: true,+ }),+ },+ async run(context) {+ const { list_id, current_email_address, new_email_address } =+ context.propsValue;+ return await emailOctopusApi.updateContact({+ auth: context.auth,+ listId: list_id,+ contact: current_email_address,+ update: { email_address: new_email_address },+ });+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/auth.ts b/packages/pieces/community/emailoctopus/src/lib/auth.tsnew file mode 100644index 00000000000..aa1ef172400--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/auth.ts@@ -0,0 +1,25 @@+import { AppConnectionType, PieceAuth } from '@activepieces/pieces-framework';++import { emailOctopusApi } from './common/api';++export const emailOctopusAuth = PieceAuth.SecretText({+ displayName: 'API Key',+ description: `+ To get your API key:+ 1. Log in to your EmailOctopus account.+ 2. Go to your **account settings**.+ 3. Generate a new API key.+ **Note:** If you have a 'legacy' key, you must generate a new one for API v2.+ `,+ required: true,+ validate: async ({ auth }) => {+ try {+ await emailOctopusApi.listLists({+ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth },+ });+ return { valid: true };+ } catch {+ return { valid: false, error: 'Invalid API key.' };+ }+ },+});diff --git a/packages/pieces/community/emailoctopus/src/lib/common/ai-props.ts b/packages/pieces/community/emailoctopus/src/lib/common/ai-props.tsnew file mode 100644index 00000000000..845b2172cb2--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/common/ai-props.ts@@ -0,0 +1,117 @@+import { Property } from '@activepieces/pieces-framework';++import type { PropParams } from './props';++function listId<R extends boolean>({+ required,+ displayName = 'List ID',+ description = 'The list ID (UUID). Use List Lists to find it.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function contact<R extends boolean>({+ required,+ displayName = 'Contact',+ description = "The contact's ID (UUID) or its email address. Both work; an email address is matched case-insensitively.",+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function campaignId<R extends boolean>({+ required,+ displayName = 'Campaign ID',+ description = 'The campaign ID (UUID). Use List Campaigns to find it.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function tag<R extends boolean>({+ required,+ displayName = 'Tag',+ description = 'The tag name, exactly as it appears on the list. Use List Tags to find it.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++function fields<R extends boolean>({+ required,+ displayName = 'Fields',+ description = 'Custom field values keyed by field tag, e.g. {"FirstName": "Ada", "Age": 36}. Use Get List to see the list\'s field tags and types.',+}: PropParams<R>) {+ return Property.Json({ displayName, description, required });+}++function fieldsToClear<R extends boolean>({+ required,+ displayName = 'Fields to Clear',+ description = 'Field tags whose value to remove from the contact, e.g. ["FirstName"]. A tag listed here must not also be in Fields.',+}: PropParams<R>) {+ return Property.Array({ displayName, description, required });+}++function status<R extends boolean>({+ required,+ displayName = 'Status',+ description = 'The contact status.',+}: PropParams<R>) {+ return Property.StaticDropdown({+ displayName,+ description,+ required,+ options: {+ disabled: false,+ options: [+ { label: 'Subscribed', value: 'subscribed' },+ { label: 'Unsubscribed', value: 'unsubscribed' },+ { label: 'Pending', value: 'pending' },+ ],+ },+ });+}++function tagsToAdd<R extends boolean>({+ required,+ displayName = 'Tags to Add',+ description = 'Tag names to add to the contact. Tags not listed are left as they are.',+}: PropParams<R>) {+ return Property.Array({ displayName, description, required });+}++function tagsToRemove<R extends boolean>({+ required,+ displayName = 'Tags to Remove',+ description = 'Tag names to remove from the contact. Tags not listed are left as they are.',+}: PropParams<R>) {+ return Property.Array({ displayName, description, required });+}++function limit<R extends boolean>({+ required,+ displayName = 'Limit',+ description = 'Max items to return (1-100). Defaults to 100.',+}: PropParams<R>) {+ return Property.Number({ displayName, description, required });+}++function startingAfter<R extends boolean>({+ required,+ displayName = 'Starting After',+ description = 'Cursor for the next page: `paging.next.starting_after` from the previous call with the same filters. Leave empty for the first page.',+}: PropParams<R>) {+ return Property.ShortText({ displayName, description, required });+}++export const emailOctopusAiProps = {+ listId,+ contact,+ campaignId,+ tag,+ fields,+ fieldsToClear,+ status,+ tagsToAdd,+ tagsToRemove,+ limit,+ startingAfter,+};diff --git a/packages/pieces/community/emailoctopus/src/lib/common/api.ts b/packages/pieces/community/emailoctopus/src/lib/common/api.tsnew file mode 100644index 00000000000..17f92b99516--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/common/api.ts@@ -0,0 +1,549 @@+import { createHash } from 'crypto';++import { HttpError, HttpMethod, QueryParams } from '@activepieces/pieces-common';++import { emailOctopusClient } from './client';++import type {+ EmailOctopusAuthValue,+ EmailOctopusCampaign,+ EmailOctopusCampaignLinksReport,+ EmailOctopusCampaignReport,+ EmailOctopusCampaignSummaryReport,+ EmailOctopusContact,+ EmailOctopusContactBatchItem,+ EmailOctopusContactBatchResult,+ EmailOctopusContactCreate,+ EmailOctopusContactUpdate,+ EmailOctopusFieldInput,+ EmailOctopusList,+ EmailOctopusListDetails,+ EmailOctopusListField,+ EmailOctopusPage,+ EmailOctopusTag,+} from './types';++async function listLists({ auth }: { auth: EmailOctopusAuthValue }): Promise<EmailOctopusList[]> {+ const response = await emailOctopusClient.request<{+ data: EmailOctopusList[];+ }>({ auth, method: HttpMethod.GET, path: '/lists' });+ return response.data;+}++async function listListsPage({+ auth,+ ...page+}: PageParams & { auth: EmailOctopusAuthValue }): Promise<+ EmailOctopusPage<EmailOctopusListDetails>+> {+ return await emailOctopusClient.request<EmailOctopusPage<EmailOctopusListDetails>>({+ auth,+ method: HttpMethod.GET,+ path: '/lists',+ query: pageQuery(page),+ });+}++async function getList({+ auth,+ listId,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+}): Promise<EmailOctopusListDetails> {+ return await emailOctopusClient.request<EmailOctopusListDetails>({+ auth,+ method: HttpMethod.GET,+ path: `/lists/${listId}`,+ });+}++async function createList({+ auth,+ name,+}: {+ auth: EmailOctopusAuthValue;+ name: string;+}): Promise<EmailOctopusList> {+ return await emailOctopusClient.request<EmailOctopusList>({+ auth,+ method: HttpMethod.POST,+ path: '/lists',+ body: { name },+ });+}++async function updateList({+ auth,+ listId,+ name,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ name: string;+}): Promise<EmailOctopusListDetails> {+ return await emailOctopusClient.request<EmailOctopusListDetails>({+ auth,+ method: HttpMethod.PUT,+ path: `/lists/${listId}`,+ body: { name },+ });+}++async function deleteList({+ auth,+ listId,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+}): Promise<void> {+ await emailOctopusClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/lists/${listId}`,+ });+}++async function createField({+ auth,+ listId,+ field,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ field: EmailOctopusFieldInput;+}): Promise<EmailOctopusListField> {+ return await emailOctopusClient.request<EmailOctopusListField>({+ auth,+ method: HttpMethod.POST,+ path: `/lists/${listId}/fields`,+ body: field,+ });+}++async function updateField({+ auth,+ listId,+ tag,+ field,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ tag: string;+ field: EmailOctopusFieldInput;+}): Promise<EmailOctopusListField> {+ return await emailOctopusClient.request<EmailOctopusListField>({+ auth,+ method: HttpMethod.PUT,+ path: `/lists/${listId}/fields/${encodeURIComponent(tag)}`,+ body: field,+ });+}++async function deleteField({+ auth,+ listId,+ tag,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ tag: string;+}): Promise<void> {+ await emailOctopusClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/lists/${listId}/fields/${encodeURIComponent(tag)}`,+ });+}++async function listTags({+ auth,+ listId,+ ...page+}: PageParams & {+ auth: EmailOctopusAuthValue;+ listId: string;+}): Promise<EmailOctopusPage<EmailOctopusTag>> {+ return await emailOctopusClient.request<EmailOctopusPage<EmailOctopusTag>>({+ auth,+ method: HttpMethod.GET,+ path: `/lists/${listId}/tags`,+ query: pageQuery(page),+ });+}++async function createTag({+ auth,+ listId,+ tag,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ tag: string;+}): Promise<EmailOctopusTag> {+ return await emailOctopusClient.request<EmailOctopusTag>({+ auth,+ method: HttpMethod.POST,+ path: `/lists/${listId}/tags`,+ body: { tag },+ });+}++async function updateTag({+ auth,+ listId,+ tag,+ newTag,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ tag: string;+ newTag: string;+}): Promise<EmailOctopusTag> {+ return await emailOctopusClient.request<EmailOctopusTag>({+ auth,+ method: HttpMethod.PUT,+ path: `/lists/${listId}/tags/${encodeURIComponent(tag)}`,+ body: { tag: newTag },+ });+}++async function deleteTag({+ auth,+ listId,+ tag,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ tag: string;+}): Promise<void> {+ await emailOctopusClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/lists/${listId}/tags/${encodeURIComponent(tag)}`,+ });+}++async function listCampaigns({+ auth,+}: {+ auth: EmailOctopusAuthValue;+}): Promise<EmailOctopusCampaign[]> {+ const response = await emailOctopusClient.request<{+ data: EmailOctopusCampaign[];+ }>({ auth, method: HttpMethod.GET, path: '/campaigns' });+ return response.data;+}++async function listCampaignsPage({+ auth,+ ...page+}: PageParams & { auth: EmailOctopusAuthValue }): Promise<EmailOctopusPage<EmailOctopusCampaign>> {+ return await emailOctopusClient.request<EmailOctopusPage<EmailOctopusCampaign>>({+ auth,+ method: HttpMethod.GET,+ path: '/campaigns',+ query: pageQuery(page),+ });+}++async function getCampaign({+ auth,+ campaignId,+}: {+ auth: EmailOctopusAuthValue;+ campaignId: string;+}): Promise<EmailOctopusCampaign> {+ return await emailOctopusClient.request<EmailOctopusCampaign>({+ auth,+ method: HttpMethod.GET,+ path: `/campaigns/${campaignId}`,+ });+}++async function getCampaignContactReport({+ auth,+ campaignId,+ status,+ ...page+}: PageParams & {+ auth: EmailOctopusAuthValue;+ campaignId: string;+ status: string;+}): Promise<EmailOctopusCampaignReport> {+ return await emailOctopusClient.request<EmailOctopusCampaignReport>({+ auth,+ method: HttpMethod.GET,+ path: `/campaigns/${campaignId}/reports`,+ query: { ...pageQuery(page), status },+ });+}++async function getCampaignLinksReport({+ auth,+ campaignId,+}: {+ auth: EmailOctopusAuthValue;+ campaignId: string;+}): Promise<EmailOctopusCampaignLinksReport> {+ return await emailOctopusClient.request<EmailOctopusCampaignLinksReport>({+ auth,+ method: HttpMethod.GET,+ path: `/campaigns/${campaignId}/reports/links`,+ });+}++async function getCampaignSummaryReport({+ auth,+ campaignId,+}: {+ auth: EmailOctopusAuthValue;+ campaignId: string;+}): Promise<EmailOctopusCampaignSummaryReport> {+ return await emailOctopusClient.request<EmailOctopusCampaignSummaryReport>({+ auth,+ method: HttpMethod.GET,+ path: `/campaigns/${campaignId}/reports/summary`,+ });+}++async function listContacts({+ auth,+ listId,+ filters,+ ...page+}: PageParams & {+ auth: EmailOctopusAuthValue;+ listId: string;+ filters: QueryParams;+}): Promise<EmailOctopusPage<EmailOctopusContact>> {+ return await emailOctopusClient.request<EmailOctopusPage<EmailOctopusContact>>({+ auth,+ method: HttpMethod.GET,+ path: `/lists/${listId}/contacts`,+ query: { ...filters, ...pageQuery(page) },+ });+}++async function getContact({+ auth,+ listId,+ contact,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ contact: string;+}): Promise<EmailOctopusContact> {+ return await emailOctopusClient.request<EmailOctopusContact>({+ auth,+ method: HttpMethod.GET,+ path: `/lists/${listId}/contacts/${contactPathId({ contact })}`,+ });+}++async function findContact({+ auth,+ listId,+ emailAddress,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ emailAddress: string;+}): Promise<EmailOctopusContact | null> {+ try {+ return await getContact({ auth, listId, contact: emailAddress });+ } catch (error) {+ if (error instanceof HttpError && error.response.status === 404) {+ return null;+ }+ throw error;+ }+}++async function createContact({+ auth,+ listId,+ contact,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ contact: EmailOctopusContactCreate;+}): Promise<EmailOctopusContact> {+ return await emailOctopusClient.request<EmailOctopusContact>({+ auth,+ method: HttpMethod.POST,+ path: `/lists/${listId}/contacts`,+ body: contact,+ });+}++async function upsertContact({+ auth,+ listId,+ emailAddress,+ fields,+ tags,+ status,+}: UpsertContactParams & {+ auth: EmailOctopusAuthValue;+}): Promise<EmailOctopusContact> {+ const body: Record<string, unknown> = {+ email_address: emailAddress,+ };+ if (fields) {+ body['fields'] = Object.fromEntries(+ Object.entries(fields).filter(+ ([, value]) => value !== null && value !== undefined && value !== '',+ ),+ );+ }+ if (status) {+ body['status'] = status;+ }+ if (tags && tags.length > 0) {+ body['tags'] = Object.fromEntries(tags.map((tag) => [tag, true]));+ }+ return await putContact({ auth, listId, body });+}++async function putContact({+ auth,+ listId,+ body,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ body: object;+}): Promise<EmailOctopusContact> {+ return await emailOctopusClient.request<EmailOctopusContact>({+ auth,+ method: HttpMethod.PUT,+ path: `/lists/${listId}/contacts`,+ body,+ });+}++async function updateContact({+ auth,+ listId,+ contact,+ update,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ contact: string;+ update: EmailOctopusContactUpdate;+}): Promise<EmailOctopusContact> {+ return await emailOctopusClient.request<EmailOctopusContact>({+ auth,+ method: HttpMethod.PUT,+ path: `/lists/${listId}/contacts/${contactPathId({ contact })}`,+ body: update,+ });+}++async function deleteContact({+ auth,+ listId,+ contact,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ contact: string;+}): Promise<void> {+ await emailOctopusClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/lists/${listId}/contacts/${contactPathId({ contact })}`,+ });+}++async function updateContactsBatch({+ auth,+ listId,+ contacts,+}: {+ auth: EmailOctopusAuthValue;+ listId: string;+ contacts: EmailOctopusContactBatchItem[];+}): Promise<EmailOctopusContactBatchResult> {+ return await emailOctopusClient.request<EmailOctopusContactBatchResult>({+ auth,+ method: HttpMethod.PUT,+ path: `/lists/${listId}/contacts/batch`,+ body: { contacts },+ });+}++async function startAutomation({+ auth,+ automationId,+ contactId,+}: {+ auth: EmailOctopusAuthValue;+ automationId: string;+ contactId: string;+}): Promise<void> {+ await emailOctopusClient.request<unknown>({+ auth,+ method: HttpMethod.POST,+ path: `/automations/${automationId}/queue`,+ body: { contact_id: contactId },+ });+}++function contactPathId({ contact }: { contact: string }): string {+ if (!contact.includes('@')) {+ return contact;+ }+ return createHash('md5').update(contact.toLowerCase()).digest('hex');+}++function pageQuery({ limit, startingAfter }: PageParams): QueryParams {+ return {+ ...(limit !== undefined ? { limit: String(limit) } : {}),+ ...(startingAfter ? { starting_after: startingAfter } : {}),+ };+}++export const emailOctopusApi = {+ listLists,+ listListsPage,+ getList,+ createList,+ updateList,+ deleteList,+ createField,+ updateField,+ deleteField,+ listTags,+ createTag,+ updateTag,+ deleteTag,+ listCampaigns,+ listCampaignsPage,+ getCampaign,+ getCampaignContactReport,+ getCampaignLinksReport,+ getCampaignSummaryReport,+ listContacts,+ getContact,+ findContact,+ createContact,+ upsertContact,+ putContact,+ updateContact,+ deleteContact,+ updateContactsBatch,+ startAutomation,+};++type PageParams = { limit?: number; startingAfter?: string };++type UpsertContactParams = {+ listId: string;+ emailAddress: string;+ fields?: Record<string, unknown>;+ tags?: string[];+ status?: string;+};diff --git a/packages/pieces/community/emailoctopus/src/lib/common/auth.ts b/packages/pieces/community/emailoctopus/src/lib/common/auth.tsdeleted file mode 100644index 5922fa47776..00000000000--- a/packages/pieces/community/emailoctopus/src/lib/common/auth.ts+++ /dev/null@@ -1,37 +0,0 @@-import { PieceAuth } from '@activepieces/pieces-framework';-import { httpClient, HttpMethod, AuthenticationType } from '@activepieces/pieces-common';--// The base URL for the EmailOctopus API-const emailOctopusApiUrl = 'https://api.emailoctopus.com';--export const emailOctopusAuth = PieceAuth.SecretText({- displayName: 'API Key',- description: `- To get your API key:- 1. Log in to your EmailOctopus account.- 2. Go to your **account settings**.- 3. Generate a new API key.- **Note:** If you have a 'legacy' key, you must generate a new one for API v2.- `,- required: true,- validate: async ({ auth }) => {- try {- await httpClient.sendRequest({- method: HttpMethod.GET,- url: `${emailOctopusApiUrl}/lists`,- authentication: {- type: AuthenticationType.BEARER_TOKEN,- token: auth,- },- });- return {- valid: true,- };- } catch (e) {- return {- valid: false,- error: 'Invalid API key.',- };- }- },-});\ No newline at end of filediff --git a/packages/pieces/community/emailoctopus/src/lib/common/client.ts b/packages/pieces/community/emailoctopus/src/lib/common/client.tsindex 6eec110a7ad..cc25d4364a4 100644--- a/packages/pieces/community/emailoctopus/src/lib/common/client.ts+++ b/packages/pieces/community/emailoctopus/src/lib/common/client.ts@@ -1,70 +1,36 @@-import { httpClient, HttpMethod, HttpRequest } from "@activepieces/pieces-common";+import { httpClient, HttpMethod, QueryParams } from '@activepieces/pieces-common';+import type { EmailOctopusAuthValue } from './types';-export const emailOctopusApiUrl = 'https://api.emailoctopus.com';---export interface EmailOctopusListDetails extends EmailOctopusList {- fields: {- tag: string;- type: 'text' | 'number' | 'date'|'choice_single'|'choice_multiple'- label: string;- choices:string[]- }[];+function baseUrl(): string {+ return 'https://api.emailoctopus.com';}-export class EmailOctopusClient {- constructor(private apiKey: string) {}-- async makeRequest<T>(method: HttpMethod, url: string, body?: object): Promise<T> {- const request: HttpRequest<object> = {- method,- url: `${emailOctopusApiUrl}${url}`,- body: body,- headers: {- "Accept": "application/json",- "Content-Type": "application/json",- "Authorization":`Bearer ${this.apiKey}`- },- };-- const { body: responseBody } = await httpClient.sendRequest<T>(request);- return responseBody;- }-- async getLists(): Promise<EmailOctopusList[]> {- const response = await this.makeRequest<{ data: EmailOctopusList[] }>(- HttpMethod.GET,- '/lists'- );- return response.data;- }--- async getList(listId: string): Promise<EmailOctopusListDetails> {- return await this.makeRequest<EmailOctopusListDetails>(- HttpMethod.GET,- `/lists/${listId}`- );- }-- async getCampaigns(): Promise<EmailOctopusCampaign[]> {- const response = await this.makeRequest<{ data: EmailOctopusCampaign[] }>(- HttpMethod.GET,- '/campaigns'- );- return response.data;- }+async function request<T>({+ auth,+ method,+ path,+ query,+ body,+}: RequestParams & { auth: EmailOctopusAuthValue }): Promise<T> {+ const response = await httpClient.sendRequest<T>({+ method,+ url: `${baseUrl()}${path}`,+ queryParams: query,+ body,+ headers: {+ Accept: 'application/json',+ 'Content-Type': 'application/json',+ Authorization: `Bearer ${auth.secret_text}`,+ },+ });+ return response.body;}-export interface EmailOctopusList {- id: string;- name: string;- created_at: string;-}+export const emailOctopusClient = { baseUrl, request };-export interface EmailOctopusCampaign {- id: string;- name: string;- status: string;- created_at: string;-}\ No newline at end of file+type RequestParams = {+ method: HttpMethod;+ path: string;+ query?: QueryParams;+ body?: object;+};diff --git a/packages/pieces/community/emailoctopus/src/lib/common/props.ts b/packages/pieces/community/emailoctopus/src/lib/common/props.tsindex 434fa3302bc..fc059333e28 100644--- a/packages/pieces/community/emailoctopus/src/lib/common/props.ts+++ b/packages/pieces/community/emailoctopus/src/lib/common/props.ts@@ -1,143 +1,146 @@import {- Property,- DynamicPropsValue,DropdownState,+ DynamicPropsValue,InputPropertyMap,- PropertyContext,+ Property,} from '@activepieces/pieces-framework';-import { EmailOctopusClient } from './client';-import { emailOctopusAuth } from './auth';+import { emailOctopusAuth } from '../auth';+import { emailOctopusApi } from './api';-type AuthAndProps = {- auth: string | undefined;- propsValue: Record<string, unknown>;-};+function listId<R extends boolean>({+ required,+ displayName = 'List',+ description = 'The mailing list to use.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: emailOctopusAuth,+ displayName,+ description,+ required,+ refreshers: [],+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({ placeholder: 'Connect your account first' });+ }+ const lists = await emailOctopusApi.listLists({ auth });+ return {+ disabled: false,+ options: lists.map((list) => ({ label: list.name, value: list.id })),+ };+ },+ });+}-export const emailOctopusProps = {- listId: (required = true) =>- Property.Dropdown({- auth: emailOctopusAuth,- displayName: 'List',- description: 'The mailing list to use.',- required: required,- refreshers: [],- options: async (context) => {- const { auth } = context;- if (!auth) {- return {- disabled: true,- placeholder: 'Connect your account first',- options: [],- };- }- const client = new EmailOctopusClient(auth.secret_text);- const lists = await client.getLists();- return {- disabled: false,- options: lists.map((list) => ({- label: list.name,- value: list.id,- })),- };- },- }),+function campaignId<R extends boolean>({+ required,+ displayName = 'Campaign',+ description = 'Select a campaign to filter events. Leave blank to trigger for all campaigns.',+}: PropParams<R>) {+ return Property.Dropdown({+ auth: emailOctopusAuth,+ displayName,+ description,+ required,+ refreshers: [],+ options: async ({ auth }) => {+ if (!auth) {+ return disabledOptions({ placeholder: 'Connect your account first' });+ }+ const campaigns = await emailOctopusApi.listCampaigns({ auth });+ return {+ disabled: false,+ options: campaigns.map((campaign) => ({+ label: campaign.name,+ value: campaign.id,+ })),+ };+ },+ });+}- campaignId: (required = false) =>- Property.Dropdown({- auth: emailOctopusAuth,- displayName: 'Campaign',- description:- 'Select a campaign to filter events. Leave blank to trigger for all campaigns.',- required: required,- refreshers: [],- options: async (context) => {- const { auth } = context;- if (!auth) {- return {- disabled: true,- placeholder: 'Connect your account first',- options: [],- };- }- const client = new EmailOctopusClient(auth.secret_text);- const campaigns = await client.getCampaigns();- return {- disabled: false,- options: campaigns.map((campaign) => ({- label: campaign.name,- value: campaign.id,- })),- };- },- }),+function fields<R extends boolean>({+ required,+ displayName = 'Fields',+ description = "The contact's custom fields.",+}: PropParams<R>) {+ return Property.DynamicProperties({+ auth: emailOctopusAuth,+ displayName,+ description,+ required,+ refreshers: ['list_id'],+ props: async ({ auth, list_id }): Promise<InputPropertyMap> => {+ if (!auth || typeof list_id !== 'string' || !list_id) {+ return {};+ }++ const listDetails = await emailOctopusApi.getList({+ auth,+ listId: list_id,+ });- fields: () =>- Property.DynamicProperties({- auth: emailOctopusAuth,- displayName: 'Fields',- description: "The contact's custom fields.",- required: true,- refreshers: ['list_id'],- props: async ({ auth, list_id }): Promise<InputPropertyMap> => {- if (!auth || !list_id) {- return {};+ const fieldProps: DynamicPropsValue = {};+ for (const field of listDetails.fields) {+ if (field.tag === 'EmailAddress') continue;+ const choices = (field.choices ?? []).map((opt) => ({+ label: opt,+ value: opt,+ }));+ switch (field.type) {+ case 'number':+ fieldProps[field.tag] = Property.Number({+ displayName: field.label,+ required: false,+ });+ break;+ case 'date':+ fieldProps[field.tag] = Property.ShortText({+ displayName: field.label,+ description: 'Date in YYYY-MM-DD format.',+ required: false,+ });+ break;+ case 'text':+ fieldProps[field.tag] = Property.ShortText({+ displayName: field.label,+ required: false,+ });+ break;+ case 'choice_single':+ fieldProps[field.tag] = Property.StaticDropdown({+ displayName: field.label,+ required: false,+ options: { disabled: false, options: choices },+ });+ break;+ case 'choice_multiple':+ fieldProps[field.tag] = Property.StaticMultiSelectDropdown({+ displayName: field.label,+ required: false,+ options: { disabled: false, options: choices },+ });+ break;+ default:+ break;}+ }+ return fieldProps;+ },+ });+}- const client = new EmailOctopusClient(auth.secret_text);- const listDetails = await client.getList(list_id as unknown as string);+function disabledOptions({+ placeholder,+}: {+ placeholder: string;+}): DropdownState<never> {+ return { disabled: true, options: [], placeholder };+}- const fields: DynamicPropsValue = {};- for (const field of listDetails.fields) {- if (field.tag === 'EmailAddress') continue;- switch (field.type) {- case 'number':- fields[field.tag] = Property.Number({- displayName: field.label,- required: false,- });- break;- case 'date':- fields[field.tag] = Property.ShortText({- displayName: field.label,- description: 'Date in YYYY-MM-DD format.',- required: false,- });- break;- case 'text':- fields[field.tag] = Property.ShortText({- displayName: field.label,- required: false,- });- break;- case 'choice_single':- fields[field.tag] = Property.StaticDropdown({- displayName: field.label,- required: false,- options: {- disabled: false,- options: field.choices- ? field.choices.map((opt) => ({ label: opt, value: opt }))- : [],- },- });- break;- case 'choice_multiple':- fields[field.tag] = Property.StaticMultiSelectDropdown({- displayName: field.label,- required: false,- options: {- disabled: false,- options: field.choices- ? field.choices.map((opt) => ({ label: opt, value: opt }))- : [],- },- });- break;- default:- break;- }- }- return fields;- },- }),+export const emailOctopusProps = { listId, campaignId, fields };++export type PropParams<R extends boolean> = {+ required: R;+ displayName?: string;+ description?: string;};diff --git a/packages/pieces/community/emailoctopus/src/lib/common/types.ts b/packages/pieces/community/emailoctopus/src/lib/common/types.tsnew file mode 100644index 00000000000..2d60d821184--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/common/types.ts@@ -0,0 +1,112 @@+import type { AppConnectionType } from '@activepieces/pieces-framework';++export type EmailOctopusAuthValue = {+ type: AppConnectionType.SECRET_TEXT;+ secret_text: string;+};++export type EmailOctopusPage<T> = {+ data: T[];+ paging?: { next?: { url?: string; starting_after?: string } | null };+};++export type EmailOctopusList = {+ id: string;+ name: string;+ created_at: string;+};++export type EmailOctopusListField = {+ tag: string;+ type: 'text' | 'number' | 'date' | 'choice_single' | 'choice_multiple';+ label: string;+ choices?: string[];+ fallback?: string | null;+};++export type EmailOctopusListDetails = EmailOctopusList & {+ fields: EmailOctopusListField[];+ double_opt_in?: boolean;+ tags?: string[];+ counts?: Record<string, number>;+ last_updated_at?: string;+};++export type EmailOctopusTag = { tag: string };++export type EmailOctopusCampaign = {+ id: string;+ name: string;+ status: string;+ created_at: string;+ subject?: string;+ preview_text?: string;+ sent_at?: string | null;+};++export type EmailOctopusCampaignReport = EmailOctopusPage<{+ contact_id?: string;+ contact_email_address?: string;+ occurred_at?: string;+}> & { status?: string };++export type EmailOctopusCampaignLinksReport = {+ data: { url?: string; clicked_total?: number; clicked_unique?: number }[];+};++export type EmailOctopusCampaignSummaryReport = {+ id?: string;+ sent?: number;+ bounced?: Record<string, number>;+ opened?: Record<string, number>;+ clicked?: Record<string, number>;+ complained?: number;+ unsubscribed?: number;+};++export type EmailOctopusContact = {+ id?: string;+ email_address?: string;+ fields?: Record<string, unknown>;+ tags?: string[];+ status?: string;+ created_at?: string;+ last_updated_at?: string;+};++export type EmailOctopusContactUpdate = {+ email_address?: string;+ fields?: Record<string, unknown>;+ status?: string;+ tags?: Record<string, boolean>;+};++export type EmailOctopusContactCreate = {+ email_address: string;+ fields?: Record<string, unknown>;+ status?: string;+ tags?: string[];+};++export type EmailOctopusContactBatchItem = EmailOctopusContactUpdate & {+ id: string;+};++export type EmailOctopusContactBatchResult = {+ success?: { success?: boolean; data?: EmailOctopusContact }[];+ errors?: {+ success?: boolean;+ id?: string;+ type?: string;+ title?: string;+ detail?: string;+ }[];+};++export type EmailOctopusFieldInput = {+ label: string;+ tag: string;+ type: string;+ choices?: string[];+ fallback?: string;+};diff --git a/packages/pieces/community/emailoctopus/src/lib/common/utils.ts b/packages/pieces/community/emailoctopus/src/lib/common/utils.tsnew file mode 100644index 00000000000..f15b98e67de--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/common/utils.ts@@ -0,0 +1,61 @@+const builtInTextFields = ['FirstName', 'LastName'];++function toStringArray({+ value,+ propName,+}: {+ value: unknown[] | undefined;+ propName: string;+}): string[] {+ if (value === undefined) {+ return [];+ }+ if (!value.every((item): item is string => typeof item === 'string' && item !== '')) {+ throw new Error(`${propName} must be a list of non-empty strings.`);+ }+ return value;+}++function toTagChanges({+ tagsToAdd,+ tagsToRemove,+}: {+ tagsToAdd: string[];+ tagsToRemove: string[];+}): Record<string, boolean> | undefined {+ if (tagsToAdd.length === 0 && tagsToRemove.length === 0) {+ return undefined;+ }+ const overlap = tagsToAdd.filter((tag) => tagsToRemove.includes(tag));+ if (overlap.length > 0) {+ throw new Error(`Tags to Add and Tags to Remove both contain: ${overlap.join(', ')}.`);+ }+ return {+ ...Object.fromEntries(tagsToAdd.map((tag) => [tag, true])),+ ...Object.fromEntries(tagsToRemove.map((tag) => [tag, false])),+ };+}++function toFieldChanges({+ fields,+ fieldsToClear,+}: {+ fields: Record<string, unknown> | undefined;+ fieldsToClear: string[];+}): Record<string, unknown> | undefined {+ if (fields === undefined && fieldsToClear.length === 0) {+ return undefined;+ }+ const overlap = fieldsToClear.filter((tag) => fields !== undefined && tag in fields);+ if (overlap.length > 0) {+ throw new Error(`Fields and Fields to Clear both contain: ${overlap.join(', ')}.`);+ }+ return {+ ...fields,+ ...Object.fromEntries(+ fieldsToClear.map((tag) => [tag, builtInTextFields.includes(tag) ? '' : null]),+ ),+ };+}++export const emailOctopusUtils = { toStringArray, toTagChanges, toFieldChanges };diff --git a/packages/pieces/community/emailoctopus/src/lib/output-schemas.ts b/packages/pieces/community/emailoctopus/src/lib/output-schemas.tsnew file mode 100644index 00000000000..cb8a1ab6cc7--- /dev/null+++ b/packages/pieces/community/emailoctopus/src/lib/output-schemas.ts@@ -0,0 +1,271 @@+import { OutputSchema } from '@activepieces/pieces-framework';++const contactFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Contact ID' },+ { key: 'email_address', label: 'Email Address', format: 'email' },+ { key: 'fields', label: 'Custom Fields', dynamicKey: true },+ { key: 'tags', label: 'Tags' },+ { key: 'status', label: 'Status' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'last_updated_at', label: 'Last Updated At', format: 'datetime' },+];++const fieldFields: OutputSchema['fields'] = [+ { key: 'label', label: 'Label' },+ { key: 'tag', label: 'Tag' },+ { key: 'type', label: 'Type' },+ { key: 'fallback', label: 'Fallback' },+];++const listFields: OutputSchema['fields'] = [+ { key: 'id', label: 'List ID' },+ { key: 'name', label: 'Name' },+ { key: 'double_opt_in', label: 'Double Opt-In', format: 'boolean' },+ { key: 'fields', label: 'Fields', labelKey: 'label', listItems: fieldFields },+ { key: 'tags', label: 'Tags' },+ {+ key: 'counts',+ label: 'Contact Counts',+ listItems: [+ { key: 'pending', label: 'Pending', format: 'number' },+ { key: 'subscribed', label: 'Subscribed', format: 'number' },+ { key: 'unsubscribed', label: 'Unsubscribed', format: 'number' },+ ],+ },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'last_updated_at', label: 'Last Updated At', format: 'datetime' },+];++const campaignFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Campaign ID' },+ { key: 'status', label: 'Status' },+ { key: 'name', label: 'Name' },+ { key: 'subject', label: 'Subject' },+ { key: 'preview_text', label: 'Preview Text' },+ { key: 'to', label: 'Recipient List IDs' },+ {+ key: 'from',+ label: 'From',+ children: [+ { key: 'name', label: 'Name' },+ { key: 'email_address', label: 'Email Address', format: 'email' },+ ],+ },+ {+ key: 'content',+ label: 'Content',+ children: [{ key: 'html', label: 'HTML', format: 'html' }],+ },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'sent_at', label: 'Sent At', format: 'datetime' },+];++const pagingField: OutputSchema['fields'][number] = {+ key: 'paging',+ label: 'Paging',+ children: [+ {+ key: 'next',+ label: 'Next Page',+ children: [+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'starting_after', label: 'Starting After Cursor' },+ ],+ },+ ],+};++const webhookEventFields: OutputSchema['fields'] = [+ { key: 'id', label: 'Event ID' },+ { key: 'type', label: 'Event Type' },+ { key: 'list_id', label: 'List ID' },+ { key: 'contact_id', label: 'Contact ID' },+ { key: 'contact_email_address', label: 'Contact Email Address', format: 'email' },+ { key: 'occurred_at', label: 'Occurred At', format: 'datetime' },+];++export const contactOutputSchema: OutputSchema = { fields: contactFields };++export const listContactsOutputSchema: OutputSchema = {+ fields: [+ { key: 'data', label: 'Contacts', labelKey: 'email_address', listItems: contactFields },+ pagingField,+ ],+};++export const findContactOutputSchema: OutputSchema = {+ fields: [+ { key: 'found', label: 'Found', format: 'boolean' },+ { key: 'result', label: 'Contact', children: contactFields },+ ],+};++export const deleteContactOutputSchema: OutputSchema = {+ fields: [+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'list_id', label: 'List ID' },+ { key: 'contact', label: 'Contact' },+ ],+};++export const updateContactsBatchOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'All Succeeded', format: 'boolean' },+ { key: 'updated_count', label: 'Updated Count', format: 'number' },+ {+ key: 'updated',+ label: 'Updated Contacts',+ labelKey: 'email_address',+ listItems: contactFields,+ },+ {+ key: 'failed',+ label: 'Failed',+ labelKey: 'title',+ listItems: [+ { key: 'id', label: 'Contact ID' },+ { key: 'type', label: 'Error Type', format: 'url' },+ { key: 'title', label: 'Title' },+ { key: 'detail', label: 'Detail' },+ { key: 'status', label: 'Status', format: 'number' },+ ],+ },+ ],+};++export const listOutputSchema: OutputSchema = { fields: listFields };++export const listListsOutputSchema: OutputSchema = {+ fields: [{ key: 'data', label: 'Lists', labelKey: 'name', listItems: listFields }, pagingField],+};++export const deleteListOutputSchema: OutputSchema = {+ fields: [+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'list_id', label: 'List ID' },+ ],+};++export const fieldOutputSchema: OutputSchema = { fields: fieldFields };++export const createFieldOutputSchema: OutputSchema = {+ fields: [...fieldFields, { key: 'choices', label: 'Choices' }],+};++export const deleteFieldOrTagOutputSchema: OutputSchema = {+ fields: [+ { key: 'deleted', label: 'Deleted', format: 'boolean' },+ { key: 'list_id', label: 'List ID' },+ { key: 'tag', label: 'Tag' },+ ],+};++export const tagOutputSchema: OutputSchema = {+ fields: [{ key: 'tag', label: 'Tag' }],+};++export const listTagsOutputSchema: OutputSchema = {+ fields: [+ { key: 'data', label: 'Tags', labelKey: 'tag', listItems: [{ key: 'tag', label: 'Tag' }] },+ pagingField,+ ],+};++export const campaignOutputSchema: OutputSchema = { fields: campaignFields };++export const listCampaignsOutputSchema: OutputSchema = {+ fields: [+ { key: 'data', label: 'Campaigns', labelKey: 'name', listItems: campaignFields },+ pagingField,+ ],+};++export const campaignContactReportOutputSchema: OutputSchema = {+ fields: [+ { key: 'status', label: 'Status' },+ {+ key: 'data',+ label: 'Contacts',+ labelKey: 'contact_email_address',+ listItems: [+ { key: 'contact_id', label: 'Contact ID' },+ { key: 'contact_email_address', label: 'Contact Email Address', format: 'email' },+ { key: 'occurred_at', label: 'Occurred At', format: 'datetime' },+ ],+ },+ pagingField,+ ],+};++export const campaignLinksReportOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'data',+ label: 'Links',+ labelKey: 'url',+ listItems: [+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'clicked_total', label: 'Total Clicks', format: 'number' },+ { key: 'clicked_unique', label: 'Unique Clicks', format: 'number' },+ ],+ },+ ],+};++export const campaignSummaryReportOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Campaign ID' },+ { key: 'sent', label: 'Sent', format: 'number' },+ {+ key: 'bounced',+ label: 'Bounced',+ children: [+ { key: 'soft', label: 'Soft Bounces', format: 'number' },+ { key: 'hard', label: 'Hard Bounces', format: 'number' },+ ],+ },+ {+ key: 'opened',+ label: 'Opened',+ children: [+ { key: 'total', label: 'Total Opens', format: 'number' },+ { key: 'unique', label: 'Unique Opens', format: 'number' },+ ],+ },+ {+ key: 'clicked',+ label: 'Clicked',+ children: [+ { key: 'total', label: 'Total Clicks', format: 'number' },+ { key: 'unique', label: 'Unique Clicks', format: 'number' },+ ],+ },+ { key: 'complained', label: 'Complaints', format: 'number' },+ { key: 'unsubscribed', label: 'Unsubscribes', format: 'number' },+ ],+};++export const contactEventTriggerOutputSchema: OutputSchema = {+ fields: [+ ...webhookEventFields,+ { key: 'contact_status', label: 'Contact Status' },+ { key: 'contact_tags', label: 'Contact Tags' },+ { key: 'contact_fields', label: 'Contact Custom Fields', dynamicKey: true },+ ],+};++export const emailEventTriggerOutputSchema: OutputSchema = {+ fields: [+ ...webhookEventFields,+ { key: 'campaign_id', label: 'Campaign ID' },+ { key: 'contact_status', label: 'Contact Status' },+ ],+};++export const startAutomationOutputSchema: OutputSchema = {+ fields: [+ { key: 'queued', label: 'Queued', format: 'boolean' },+ { key: 'automation_id', label: 'Automation ID' },+ { key: 'contact_id', label: 'Contact ID' },+ ],+};diff --git a/packages/pieces/community/emailoctopus/src/lib/triggers/contact-Unsubscribes.ts b/packages/pieces/community/emailoctopus/src/lib/triggers/contact-unsubscribes.tssimilarity index 68%rename from packages/pieces/community/emailoctopus/src/lib/triggers/contact-Unsubscribes.tsrename to packages/pieces/community/emailoctopus/src/lib/triggers/contact-unsubscribes.tsindex e2148513823..3f518e08f0b 100644--- a/packages/pieces/community/emailoctopus/src/lib/triggers/contact-Unsubscribes.ts+++ b/packages/pieces/community/emailoctopus/src/lib/triggers/contact-unsubscribes.ts@@ -1,20 +1,10 @@import { Property, createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';-import { emailOctopusAuth } from '../common/auth';+import { emailOctopusAuth } from '../auth';import { emailOctopusProps } from '../common/props';+import { contactEventTriggerOutputSchema } from '../output-schemas';import { MarkdownVariant } from '@activepieces/pieces-framework';-interface EmailOctopusEvent {- type: string;- id: string;- contact_email_address: string;- contact_fields?: Record<string, string>;- contact_tags?: string[];- contact_status?: string;- list_id?: string;- occurred_at?: string;-}--export const contactUnsubscribes = createTrigger({+export const contactUnsubscribesTrigger = createTrigger({auth: emailOctopusAuth,name: 'contactUnsubscribes',classification: 'READ',@@ -24,7 +14,7 @@ export const contactUnsubscribes = createTrigger({description: 'Fires when a contact unsubscribes from an EmailOctopus list (a contact.unsubscribed webhook event), representing an opt-out. Can be scoped to a single list id, or left unfiltered to catch unsubscribes across all lists.',},props: {- list_id: emailOctopusProps.listId(true),+ list_id: emailOctopusProps.listId({ required: true }),liveMarkdown: Property.MarkDown({value: `**Live URL:**@@ -61,6 +51,7 @@ export const contactUnsubscribes = createTrigger({contact_email_address: '[email protected]',contact_tags: ['vip'],},+ outputSchema: contactEventTriggerOutputSchema,type: TriggerStrategy.WEBHOOK,async onEnable() {return;@@ -69,24 +60,15 @@ export const contactUnsubscribes = createTrigger({return;},async run(context) {- const events = context.payload.body;+ const body = context.payload.body as+ | { type?: string; list_id?: string }+ | { type?: string; list_id?: string }[];+ const events = Array.isArray(body) ? body : [body];const listIdFilter = context.propsValue.list_id;-- if (Array.isArray(events)) {- return events.filter(- (event: EmailOctopusEvent) =>- event.type === 'contact.unsubscribed' &&- (!listIdFilter || event.list_id === listIdFilter)- );- }-- if (- (events as EmailOctopusEvent)?.type === 'contact.unsubscribed' &&- (!listIdFilter || (events as EmailOctopusEvent).list_id === listIdFilter)- ) {- return [events];- }-- return [];+ return events.filter(+ (event) =>+ event?.type === 'contact.unsubscribed' &&+ (!listIdFilter || event.list_id === listIdFilter)+ );},});diff --git a/packages/pieces/community/emailoctopus/src/lib/triggers/email-bounced.ts b/packages/pieces/community/emailoctopus/src/lib/triggers/email-bounced.tsindex 6f4954ec192..afa9cc3e4cf 100644--- a/packages/pieces/community/emailoctopus/src/lib/triggers/email-bounced.ts+++ b/packages/pieces/community/emailoctopus/src/lib/triggers/email-bounced.ts@@ -1,9 +1,10 @@import { Property, TriggerStrategy, createTrigger } from "@activepieces/pieces-framework";-import { emailOctopusAuth } from "../common/auth";+import { emailOctopusAuth } from '../auth';import { emailOctopusProps } from "../common/props";+import { emailEventTriggerOutputSchema } from '../output-schemas';import { MarkdownVariant } from '@activepieces/pieces-framework';-export const emailBounced = createTrigger({+export const emailBouncedTrigger = createTrigger({auth: emailOctopusAuth,name: 'email_bounced',classification: 'READ',@@ -13,7 +14,7 @@ export const emailBounced = createTrigger({description: 'Fires when an EmailOctopus campaign email bounces for a recipient (a contact.bounced webhook event), representing a delivery failure. Can be scoped to a single campaign id, or left unfiltered to catch bounces across all campaigns.',},props: {- campaign_id: emailOctopusProps.campaignId(),+ campaign_id: emailOctopusProps.campaignId({ required: false }),liveMarkdown: Property.MarkDown({value: `**Live URL:**@@ -35,6 +36,7 @@ export const emailBounced = createTrigger({`,}),},+ outputSchema: emailEventTriggerOutputSchema,type: TriggerStrategy.WEBHOOK,sampleData: {"id": "42636763-73f9-463e-af8b-3f720bb3d889",@@ -47,8 +49,8 @@ export const emailBounced = createTrigger({"campaign_id": "12345678-1234-1234-1234-123456789abc"},- async onEnable(context) { return },- async onDisable(context) { return },+ async onEnable() { return },+ async onDisable() { return },async run(context) {const payloadBody = context.payload.body as { type: string; campaign_id: string };diff --git a/packages/pieces/community/emailoctopus/src/lib/triggers/email-Clicked.ts b/packages/pieces/community/emailoctopus/src/lib/triggers/email-clicked.tssimilarity index 69%rename from packages/pieces/community/emailoctopus/src/lib/triggers/email-Clicked.tsrename to packages/pieces/community/emailoctopus/src/lib/triggers/email-clicked.tsindex 5a374b3eaa9..b976f47eb23 100644--- a/packages/pieces/community/emailoctopus/src/lib/triggers/email-Clicked.ts+++ b/packages/pieces/community/emailoctopus/src/lib/triggers/email-clicked.ts@@ -1,19 +1,10 @@import { Property, createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';import { emailOctopusProps } from '../common/props';-import { emailOctopusAuth } from '../common/auth';+import { emailEventTriggerOutputSchema } from '../output-schemas';+import { emailOctopusAuth } from '../auth';import { MarkdownVariant } from '@activepieces/pieces-framework';-interface EmailOctopusEvent {- type: string;- id: string;- contact_email_address: string;- campaign_id?: string;- list_id?: string;- contact_id?: string;- occurred_at?: string;-}--export const emailClicked = createTrigger({+export const emailClickedTrigger = createTrigger({auth: emailOctopusAuth,name: 'emailClicked',classification: 'READ',@@ -23,7 +14,7 @@ export const emailClicked = createTrigger({description: 'Fires when a recipient clicks a link inside an EmailOctopus campaign email (a contact.clicked webhook event), representing a click-through engagement. Can be scoped to a single campaign id, or left unfiltered to catch clicks across all campaigns.',},props: {- campaign_id: emailOctopusProps.campaignId(),+ campaign_id: emailOctopusProps.campaignId({ required: false }),liveMarkdown: Property.MarkDown({value: `**Live URL:**@@ -55,6 +46,7 @@ export const emailClicked = createTrigger({contact_email_address: '[email protected]',campaign_id: '12345678-1234-1234-1234-123456789abc',},+ outputSchema: emailEventTriggerOutputSchema,type: TriggerStrategy.WEBHOOK,async onEnable() {return;@@ -63,24 +55,15 @@ export const emailClicked = createTrigger({return;},async run(context) {- const events = context.payload.body;+ const body = context.payload.body as+ | { type?: string; campaign_id?: string }+ | { type?: string; campaign_id?: string }[];+ const events = Array.isArray(body) ? body : [body];const campaignIdFilter = context.propsValue.campaign_id;-- if (Array.isArray(events)) {- return events.filter(- (event: EmailOctopusEvent) =>- event.type === 'contact.clicked' &&- (!campaignIdFilter || event.campaign_id === campaignIdFilter)- );- }-- if (- (events as EmailOctopusEvent)?.type === 'contact.clicked' &&- (!campaignIdFilter || (events as EmailOctopusEvent).campaign_id === campaignIdFilter)- ) {- return [events];- }-- return [];+ return events.filter(+ (event) =>+ event?.type === 'contact.clicked' &&+ (!campaignIdFilter || event.campaign_id === campaignIdFilter)+ );},});diff --git a/packages/pieces/community/emailoctopus/src/lib/triggers/email-opened.ts b/packages/pieces/community/emailoctopus/src/lib/triggers/email-opened.tsindex 676a8a3d5f0..83bdabc854a 100644--- a/packages/pieces/community/emailoctopus/src/lib/triggers/email-opened.ts+++ b/packages/pieces/community/emailoctopus/src/lib/triggers/email-opened.ts@@ -3,11 +3,12 @@ import {TriggerStrategy,createTrigger,} from '@activepieces/pieces-framework';-import { emailOctopusAuth } from '../common/auth';+import { emailOctopusAuth } from '../auth';import { emailOctopusProps } from '../common/props';+import { emailEventTriggerOutputSchema } from '../output-schemas';import { MarkdownVariant } from '@activepieces/pieces-framework';-export const emailOpened = createTrigger({+export const emailOpenedTrigger = createTrigger({auth: emailOctopusAuth,name: 'email_opened',classification: 'READ',@@ -18,7 +19,7 @@ export const emailOpened = createTrigger({description: 'Fires when a recipient opens an EmailOctopus campaign email (a contact.opened webhook event), representing an engagement/open. Can be scoped to a single campaign id, or left unfiltered to catch opens across all campaigns.',},props: {- campaign_id: emailOctopusProps.campaignId(),+ campaign_id: emailOctopusProps.campaignId({ required: false }),liveMarkdown: Property.MarkDown({value: `**Live URL:**@@ -42,6 +43,7 @@ export const emailOpened = createTrigger({`,}),},+ outputSchema: emailEventTriggerOutputSchema,type: TriggerStrategy.WEBHOOK,sampleData: {id: '42636763-73f9-463e-af8b-3f720bb3d889',@@ -53,10 +55,10 @@ export const emailOpened = createTrigger({campaign_id: '12345678-1234-1234-1234-123456789abc',},- async onEnable(context) {+ async onEnable() {return;},- async onDisable(context) {+ async onDisable() {return;},diff --git a/packages/pieces/community/emailoctopus/src/lib/triggers/new-Contact.ts b/packages/pieces/community/emailoctopus/src/lib/triggers/new-contact.tssimilarity index 69%rename from packages/pieces/community/emailoctopus/src/lib/triggers/new-Contact.tsrename to packages/pieces/community/emailoctopus/src/lib/triggers/new-contact.tsindex 8338874bb80..535b3325e69 100644--- a/packages/pieces/community/emailoctopus/src/lib/triggers/new-Contact.ts+++ b/packages/pieces/community/emailoctopus/src/lib/triggers/new-contact.ts@@ -3,24 +3,15 @@ import {createTrigger,TriggerStrategy,} from '@activepieces/pieces-framework';-import { emailOctopusAuth } from '../common/auth';+import { emailOctopusAuth } from '../auth';import { emailOctopusProps } from '../common/props';import { MarkdownVariant } from '@activepieces/pieces-framework';+import { contactEventTriggerOutputSchema } from '../output-schemas';-interface EmailOctopusEvent {- type: string;- id: string;- contact_email_address: string;- contact_fields?: Record<string, string>;- contact_tags?: string[];- contact_status?: string;- list_id?: string;- occurred_at?: string;-}--export const newContact = createTrigger({+export const newContactTrigger = createTrigger({auth: emailOctopusAuth,name: 'newContact',+ outputSchema: contactEventTriggerOutputSchema,classification: 'READ',displayName: 'New Contact',description: 'Triggers when a new contact is added to a particular list.',@@ -28,7 +19,7 @@ export const newContact = createTrigger({description: 'Fires when a new contact is created in EmailOctopus (a contact.created webhook event), representing a new subscriber. Can be scoped to a single list id, or left unfiltered to catch new contacts across all lists.',},props: {- list_id: emailOctopusProps.listId(true),+ list_id: emailOctopusProps.listId({ required: true }),liveMarkdown: Property.MarkDown({value: `**Live URL:**@@ -74,24 +65,15 @@ export const newContact = createTrigger({return;},async run(context) {- const events = context.payload.body;+ const body = context.payload.body as+ | { type?: string; list_id?: string }+ | { type?: string; list_id?: string }[];+ const events = Array.isArray(body) ? body : [body];const listIdFilter = context.propsValue.list_id;-- if (Array.isArray(events)) {- return events.filter(- (event: EmailOctopusEvent) =>- event.type === 'contact.created' &&- (!listIdFilter || event.list_id === listIdFilter)- );- }-- if (- (events as EmailOctopusEvent)?.type === 'contact.created' &&- (!listIdFilter || (events as EmailOctopusEvent).list_id === listIdFilter)- ) {- return [events];- }-- return [];+ return events.filter(+ (event) =>+ event?.type === 'contact.created' &&+ (!listIdFilter || event.list_id === listIdFilter)+ );},});