From 61b8e0d1607723c011b616ba9cd7ff71a7f60f51 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 16 Jul 2025 14:54:18 -0300 Subject: [PATCH 01/17] package version bump --- components/frontapp/package.json | 4 ++-- pnpm-lock.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/frontapp/package.json b/components/frontapp/package.json index f46650a4cda8d..d5e3ca9658284 100644 --- a/components/frontapp/package.json +++ b/components/frontapp/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/frontapp", - "version": "0.6.0", + "version": "0.7.0", "description": "Pipedream Frontapp Components", "main": "frontapp.app.mjs", "keywords": [ @@ -10,7 +10,7 @@ "homepage": "https://pipedream.com/apps/frontapp", "author": "Pipedream (https://pipedream.com/)", "dependencies": { - "@pipedream/platform": "^3.0.3", + "@pipedream/platform": "^3.1.0", "form-data": "^4.0.0" }, "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a51461c5c41ce..360fbea544711 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5068,8 +5068,8 @@ importers: components/frontapp: dependencies: '@pipedream/platform': - specifier: ^3.0.3 - version: 3.0.3 + specifier: ^3.1.0 + version: 3.1.0 form-data: specifier: ^4.0.0 version: 4.0.1 From 99f6ccf8be6c392531de486cd0aec2454c45ed73 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 16 Jul 2025 19:57:15 -0300 Subject: [PATCH 02/17] Adding new actions and adjusting minor things --- .../actions/create-inbox/create-inbox.mjs | 47 ++++++++ .../create-message-template.mjs | 109 ++++++++++++++++++ .../delete-message-template.mjs | 33 ++++++ .../actions/import-message/import-message.mjs | 2 +- .../list-message-templates.mjs | 55 +++++++++ .../receive-custom-messages.mjs | 4 +- .../reply-to-conversation.mjs | 4 +- .../send-new-message/send-new-message.mjs | 4 +- .../update-conversation.mjs | 4 +- .../update-teammate/update-teammate.mjs | 77 +++++++++++++ components/frontapp/frontapp.app.mjs | 79 +++++++++++++ .../new-conversation-state-change.mjs | 6 +- 12 files changed, 412 insertions(+), 12 deletions(-) create mode 100644 components/frontapp/actions/create-inbox/create-inbox.mjs create mode 100644 components/frontapp/actions/create-message-template/create-message-template.mjs create mode 100644 components/frontapp/actions/delete-message-template/delete-message-template.mjs create mode 100644 components/frontapp/actions/list-message-templates/list-message-templates.mjs create mode 100644 components/frontapp/actions/update-teammate/update-teammate.mjs diff --git a/components/frontapp/actions/create-inbox/create-inbox.mjs b/components/frontapp/actions/create-inbox/create-inbox.mjs new file mode 100644 index 0000000000000..719e2705bbf36 --- /dev/null +++ b/components/frontapp/actions/create-inbox/create-inbox.mjs @@ -0,0 +1,47 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-create-inbox", + name: "Create Inbox", + description: "Create an inbox in the default team (workspace). [See the documentation](https://dev.frontapp.com/reference/create-inbox).", + version: "0.0.1", + type: "action", + props: { + frontApp, + name: { + type: "string", + label: "Name", + description: "The name of the inbox", + }, + teammateIds: { + type: "string[]", + label: "Teammate IDs", + description: "An array of teammate IDs that should have access to the inbox. Alternatively, you can supply teammate emails as a resource alias.", + propDefinition: [ + frontApp, + "teammateId", + ], + optional: true, + }, + }, + async run({ $ }) { + const { + frontApp, + name, + teammateIds, + } = this; + + const data = { + name, + teammate_ids: teammateIds, + }; + + const response = await frontApp.createInbox({ + data, + $, + }); + + $.export("$summary", `Successfully created inbox "${name}"`); + return response; + }, +}; diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs new file mode 100644 index 0000000000000..846a369542e1a --- /dev/null +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -0,0 +1,109 @@ +import FormData from "form-data"; +import { getFileStreamAndMetadata } from "@pipedream/platform"; +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-create-message-template", + name: "Create Message Template", + description: "Create a new message template. [See the documentation](https://dev.frontapp.com/reference/create-message-template).", + version: "0.0.1", + type: "action", + props: { + frontApp, + name: { + type: "string", + label: "Name", + description: "Name of the message template", + }, + subject: { + type: "string", + label: "Subject", + description: "Subject of the message template", + optional: true, + }, + body: { + type: "string", + label: "Body", + description: "Body of the message template. You can supply HTML with inline CSS to structure and style your template.", + }, + folderId: { + propDefinition: [ + frontApp, + "folderId", + ], + description: "ID of the message template folder to place this message template in", + }, + inboxIds: { + type: "string[]", + label: "Inbox IDs", + description: "The specific inboxes this template is available in. If not specified, it will be available in all inboxes.", + propDefinition: [ + frontApp, + "inboxId", + ], + optional: true, + }, + attachments: { + propDefinition: [ + frontApp, + "attachments", + ], + }, + }, + async run({ $ }) { + const { + frontApp, + name, + subject, + body, + folderId, + inboxIds, + attachments, + } = this; + + let data, headers = {}; + + // Handle attachments if provided + if (attachments && attachments.length > 0) { + const formData = new FormData(); + + formData.append("name", name); + formData.append("body", body); + formData.append("subject", subject); + formData.append("folder_id", folderId); + formData.append("inbox_ids", inboxIds); + + for (const attachment of attachments) { + const { + stream, metadata, + } = await getFileStreamAndMetadata(attachment); + formData.append("attachments", stream, { + contentType: metadata.contentType, + knownLength: metadata.size, + filename: metadata.name, + }); + } + + data = formData; + headers = formData.getHeaders(); + } else { + // Simple JSON request without attachments + data = { + name, + subject, + body, + folder_id: folderId, + inbox_ids: inboxIds, + }; + } + + const response = await frontApp.createMessageTemplate({ + data, + headers, + $, + }); + + $.export("$summary", `Successfully created message template "${name}"`); + return response; + }, +}; diff --git a/components/frontapp/actions/delete-message-template/delete-message-template.mjs b/components/frontapp/actions/delete-message-template/delete-message-template.mjs new file mode 100644 index 0000000000000..2a9c28d53a5a6 --- /dev/null +++ b/components/frontapp/actions/delete-message-template/delete-message-template.mjs @@ -0,0 +1,33 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-delete-message-template", + name: "Delete Message Template", + description: "Delete a message template. [See the documentation](https://dev.frontapp.com/reference/delete-message-template).", + version: "0.0.1", + type: "action", + props: { + frontApp, + messageTemplateId: { + propDefinition: [ + frontApp, + "messageTemplateId", + ], + description: "The message template ID", + }, + }, + async run({ $ }) { + const { + frontApp, + messageTemplateId, + } = this; + + const response = await frontApp.deleteMessageTemplate({ + messageTemplateId, + $, + }); + + $.export("$summary", `Successfully deleted message template ${messageTemplateId}`); + return response; + }, +}; diff --git a/components/frontapp/actions/import-message/import-message.mjs b/components/frontapp/actions/import-message/import-message.mjs index 7d21b63cac714..1fbe1be872a1e 100644 --- a/components/frontapp/actions/import-message/import-message.mjs +++ b/components/frontapp/actions/import-message/import-message.mjs @@ -4,7 +4,7 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-import-message", name: "Import Message", - description: "Appends a new message into an inbox. [See the docs here](https://dev.frontapp.com/reference/import-inbox-message).", + description: "Appends a new message into an inbox. [See the documentation](https://dev.frontapp.com/reference/import-inbox-message).", version: "0.1.7", type: "action", props: { diff --git a/components/frontapp/actions/list-message-templates/list-message-templates.mjs b/components/frontapp/actions/list-message-templates/list-message-templates.mjs new file mode 100644 index 0000000000000..451340b548a54 --- /dev/null +++ b/components/frontapp/actions/list-message-templates/list-message-templates.mjs @@ -0,0 +1,55 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-list-message-templates", + name: "List Message Templates", + description: "List the message templates. [See the documentation](https://dev.frontapp.com/reference/list-message-templates).", + version: "0.0.1", + type: "action", + props: { + frontApp, + sortBy: { + type: "string", + label: "Sort By", + description: "Field used to sort the message templates.", + options: [ + "created_at", + "updated_at", + "sort_order", + ], + optional: true, + }, + sortOrder: { + type: "string", + label: "Sort Order", + description: "Order by which results should be sorted", + options: [ + "asc", + "desc", + ], + optional: true, + }, + }, + async run({ $ }) { + const { + frontApp, + sortBy, + sortOrder, + } = this; + + const params = {}; + + if (sortBy) params.sort_by = sortBy; + if (sortOrder) params.sort_order = sortOrder; + + const response = await frontApp.listMessageTemplates({ + params, + $, + }); + + const templates = response._results || []; + $.export("$summary", `Successfully retrieved ${templates.length} message template(s)`); + + return response; + }, +}; diff --git a/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs b/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs index 294c0d1df55d6..bf25964f07d41 100644 --- a/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs +++ b/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-receive-custom-messages", name: "Receive Custom Messages", - description: "Receive a custom message in Front. [See the docs here](https://dev.frontapp.com/reference/post_channels-channel-id-incoming-messages).", - version: "0.0.4", + description: "Receive a custom message in Front. [See the documentation](https://dev.frontapp.com/reference/post_channels-channel-id-incoming-messages).", + version: "0.0.5", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs b/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs index 4f227cc4cc884..2f74ec08aea07 100644 --- a/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs +++ b/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-reply-to-conversation", name: "Reply To Conversation", - description: "Reply to a conversation by sending a message and appending it to the conversation. [See the docs here](https://dev.frontapp.com/reference/post_conversations-conversation-id-messages).", - version: "0.0.3", + description: "Reply to a conversation by sending a message and appending it to the conversation. [See the documentation](https://dev.frontapp.com/reference/post_conversations-conversation-id-messages).", + version: "0.0.4", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/send-new-message/send-new-message.mjs b/components/frontapp/actions/send-new-message/send-new-message.mjs index 748f86e65af4e..3cd9234f34c60 100644 --- a/components/frontapp/actions/send-new-message/send-new-message.mjs +++ b/components/frontapp/actions/send-new-message/send-new-message.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-send-new-message", name: "Send New Message", - description: "Sends a new message from a channel. It will create a new conversation. [See the docs here](https://dev.frontapp.com/reference/post_channels-channel-id-messages).", - version: "0.2.6", + description: "Sends a new message from a channel. It will create a new conversation. [See the documentation](https://dev.frontapp.com/reference/post_channels-channel-id-messages).", + version: "0.2.7", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/update-conversation/update-conversation.mjs b/components/frontapp/actions/update-conversation/update-conversation.mjs index 4d69740438a6a..99206fca0bbf9 100644 --- a/components/frontapp/actions/update-conversation/update-conversation.mjs +++ b/components/frontapp/actions/update-conversation/update-conversation.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-update-conversation", name: "Update Conversation", - description: "Updates a conversation. [See the docs here](https://dev.frontapp.com/reference/patch_conversations-conversation-id).", - version: "0.1.6", + description: "Updates a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id).", + version: "0.1.7", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/update-teammate/update-teammate.mjs b/components/frontapp/actions/update-teammate/update-teammate.mjs new file mode 100644 index 0000000000000..10983f0890f59 --- /dev/null +++ b/components/frontapp/actions/update-teammate/update-teammate.mjs @@ -0,0 +1,77 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-update-teammate", + name: "Update Teammate", + description: "Update a teammate. [See the documentation](https://dev.frontapp.com/reference/update-teammate).", + version: "0.0.1", + type: "action", + props: { + frontApp, + teammateId: { + propDefinition: [ + frontApp, + "teammateId", + ], + description: "The teammate ID. Alternatively, you can supply an email as a resource alias", + }, + username: { + type: "string", + label: "Username", + description: "New username. It must be unique and can only contains lowercase letters, numbers and underscores", + optional: true, + }, + firstName: { + type: "string", + label: "First Name", + description: "New first name", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "New last name", + optional: true, + }, + isAvailable: { + type: "boolean", + label: "Is Available", + description: "New availability status", + optional: true, + }, + customFields: { + type: "object", + label: "Custom Fields", + description: "Custom fields for this teammate. If included, all current custom fields will be replaced with the object supplied here", + optional: true, + }, + }, + async run({ $ }) { + const { + frontApp, + teammateId, + username, + firstName, + lastName, + isAvailable, + customFields, + } = this; + + const data = { + username, + first_name: firstName, + last_name: lastName, + is_available: isAvailable, + custom_fields: customFields, + }; + + const response = await frontApp.updateTeammate({ + teammateId, + data, + $, + }); + + $.export("$summary", `Successfully updated teammate ${teammateId}`); + return response; + }, +}; diff --git a/components/frontapp/frontapp.app.mjs b/components/frontapp/frontapp.app.mjs index 8d3f031c4db91..d9fecde8b629b 100644 --- a/components/frontapp/frontapp.app.mjs +++ b/components/frontapp/frontapp.app.mjs @@ -273,6 +273,41 @@ export default { default: 100, optional: true, }, + messageTemplateId: { + type: "string", + label: "Message Template ID", + description: "The message template ID", + async options({ prevContext }) { + return this.paginateOptions({ + prevContext, + listResourcesFn: this.listMessageTemplates, + mapper: ({ + id, name, + }) => ({ + label: name, + value: id, + }), + }); + }, + }, + folderId: { + type: "string", + label: "Folder ID", + description: "ID of the message template folder", + async options({ prevContext }) { + return this.paginateOptions({ + prevContext, + listResourcesFn: this.listMessageTemplateFolders, + mapper: ({ + id, name, + }) => ({ + label: name, + value: id, + }), + }); + }, + optional: true, + }, }, methods: { getUrl(path, url) { @@ -510,6 +545,50 @@ export default { ...args, }); }, + async listMessageTemplates(args = {}) { + return this.makeRequest({ + path: "/message_templates", + ...args, + }); + }, + async listMessageTemplateFolders(args = {}) { + return this.makeRequest({ + path: "/message_template_folders", + ...args, + }); + }, + async updateTeammate({ + teammateId, ...args + } = {}) { + return this.makeRequest({ + method: "patch", + path: `/teammates/${teammateId}`, + ...args, + }); + }, + async createInbox(args = {}) { + return this.makeRequest({ + method: "post", + path: "/inboxes", + ...args, + }); + }, + async createMessageTemplate(args = {}) { + return this.makeRequest({ + method: "post", + path: "/message_templates", + ...args, + }); + }, + async deleteMessageTemplate({ + messageTemplateId, ...args + } = {}) { + return this.makeRequest({ + method: "delete", + path: `/message_templates/${messageTemplateId}`, + ...args, + }); + }, async paginateOptions({ prevContext, listResourcesFn, diff --git a/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs b/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs index edc90a1610223..549e0814361e2 100644 --- a/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs +++ b/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs @@ -6,8 +6,8 @@ export default { ...common, key: "frontapp-new-conversation-state-change", name: "New Conversation State Change", - description: "Emit new event when a conversation reaches a specific state. [See the docs](https://dev.frontapp.com/reference/list-conversations)", - version: "0.0.2", + description: "Emit new event when a conversation reaches a specific state. [See the documentation](https://dev.frontapp.com/reference/list-conversations)", + version: "0.0.3", type: "source", dedupe: "unique", props: { @@ -15,7 +15,7 @@ export default { types: { type: "string[]", label: "States to Listen For", - description: "Trigger a workflow when a conversation reaches any of these states. [See the docs](https://dev.frontapp.com/reference/list-conversations) for more detail.", + description: "Trigger a workflow when a conversation reaches any of these states. [See the documentation](https://dev.frontapp.com/reference/list-conversations) for more detail.", options: utils.TYPES_OPTIONS, }, }, From 97c7644db62232e46aea76a5f60287010640dc0f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 17 Jul 2025 17:02:30 -0300 Subject: [PATCH 03/17] Description improvements --- .../actions/create-inbox/create-inbox.mjs | 6 ++-- .../create-message-template.mjs | 6 ++-- .../delete-message-template.mjs | 2 +- .../actions/import-message/import-message.mjs | 2 +- .../list-message-templates.mjs | 28 +++++++++++-------- .../update-teammate/update-teammate.mjs | 2 +- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/components/frontapp/actions/create-inbox/create-inbox.mjs b/components/frontapp/actions/create-inbox/create-inbox.mjs index 719e2705bbf36..356f99096c389 100644 --- a/components/frontapp/actions/create-inbox/create-inbox.mjs +++ b/components/frontapp/actions/create-inbox/create-inbox.mjs @@ -14,13 +14,13 @@ export default { description: "The name of the inbox", }, teammateIds: { - type: "string[]", - label: "Teammate IDs", - description: "An array of teammate IDs that should have access to the inbox. Alternatively, you can supply teammate emails as a resource alias.", propDefinition: [ frontApp, "teammateId", ], + type: "string[]", + label: "Teammate IDs", + description: "One or more IDs of teammates that should have access to the inbox", optional: true, }, }, diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs index 846a369542e1a..914b8297e4547 100644 --- a/components/frontapp/actions/create-message-template/create-message-template.mjs +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -24,7 +24,7 @@ export default { body: { type: "string", label: "Body", - description: "Body of the message template. You can supply HTML with inline CSS to structure and style your template.", + description: "Body of the message template. You can supply HTML with inline CSS to structure and style your template", }, folderId: { propDefinition: [ @@ -36,7 +36,7 @@ export default { inboxIds: { type: "string[]", label: "Inbox IDs", - description: "The specific inboxes this template is available in. If not specified, it will be available in all inboxes.", + description: "The specific inboxes this template is available in. If not specified, it will be available in all inboxes", propDefinition: [ frontApp, "inboxId", @@ -64,7 +64,7 @@ export default { let data, headers = {}; // Handle attachments if provided - if (attachments && attachments.length > 0) { + if (attachments?.length > 0) { const formData = new FormData(); formData.append("name", name); diff --git a/components/frontapp/actions/delete-message-template/delete-message-template.mjs b/components/frontapp/actions/delete-message-template/delete-message-template.mjs index 2a9c28d53a5a6..2c0b20477e032 100644 --- a/components/frontapp/actions/delete-message-template/delete-message-template.mjs +++ b/components/frontapp/actions/delete-message-template/delete-message-template.mjs @@ -13,7 +13,7 @@ export default { frontApp, "messageTemplateId", ], - description: "The message template ID", + description: "ID of the message template to delete", }, }, async run({ $ }) { diff --git a/components/frontapp/actions/import-message/import-message.mjs b/components/frontapp/actions/import-message/import-message.mjs index 1fbe1be872a1e..042ff683a122c 100644 --- a/components/frontapp/actions/import-message/import-message.mjs +++ b/components/frontapp/actions/import-message/import-message.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-import-message", name: "Import Message", description: "Appends a new message into an inbox. [See the documentation](https://dev.frontapp.com/reference/import-inbox-message).", - version: "0.1.7", + version: "0.1.8", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-message-templates/list-message-templates.mjs b/components/frontapp/actions/list-message-templates/list-message-templates.mjs index 451340b548a54..e7bdd8db7904c 100644 --- a/components/frontapp/actions/list-message-templates/list-message-templates.mjs +++ b/components/frontapp/actions/list-message-templates/list-message-templates.mjs @@ -11,11 +11,10 @@ export default { sortBy: { type: "string", label: "Sort By", - description: "Field used to sort the message templates.", + description: "Field used to sort the message templates", options: [ "created_at", "updated_at", - "sort_order", ], optional: true, }, @@ -24,8 +23,14 @@ export default { label: "Sort Order", description: "Order by which results should be sorted", options: [ - "asc", - "desc", + { + label: "Ascending", + value: "asc", + }, + { + label: "Descending", + value: "desc", + }, ], optional: true, }, @@ -37,18 +42,19 @@ export default { sortOrder, } = this; - const params = {}; - - if (sortBy) params.sort_by = sortBy; - if (sortOrder) params.sort_order = sortOrder; - const response = await frontApp.listMessageTemplates({ - params, $, + params: { + sort_by: sortBy, + sort_order: sortOrder, + }, }); const templates = response._results || []; - $.export("$summary", `Successfully retrieved ${templates.length} message template(s)`); + const length = templates.length; + $.export("$summary", `Successfully retrieved ${length} message template${length === 1 + ? "" + : "s"}`); return response; }, diff --git a/components/frontapp/actions/update-teammate/update-teammate.mjs b/components/frontapp/actions/update-teammate/update-teammate.mjs index 10983f0890f59..c2c7ea33bf167 100644 --- a/components/frontapp/actions/update-teammate/update-teammate.mjs +++ b/components/frontapp/actions/update-teammate/update-teammate.mjs @@ -13,7 +13,7 @@ export default { frontApp, "teammateId", ], - description: "The teammate ID. Alternatively, you can supply an email as a resource alias", + description: "ID of the teammate to update", }, username: { type: "string", From 25bc805fc750dd0cc23e7d874bd49ff91d0d6d52 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 17 Jul 2025 19:45:48 -0300 Subject: [PATCH 04/17] Adding sources --- .../frontapp/sources/common/polling-ids.mjs | 55 +++++++++++ .../new-conversation-created.mjs | 36 +++++++ .../new-conversation-created/test-event.mjs | 96 +++++++++++++++++++ .../new-message-template-created.mjs | 36 +++++++ .../test-event.mjs | 56 +++++++++++ 5 files changed, 279 insertions(+) create mode 100644 components/frontapp/sources/common/polling-ids.mjs create mode 100644 components/frontapp/sources/new-conversation-created/new-conversation-created.mjs create mode 100644 components/frontapp/sources/new-conversation-created/test-event.mjs create mode 100644 components/frontapp/sources/new-message-template-created/new-message-template-created.mjs create mode 100644 components/frontapp/sources/new-message-template-created/test-event.mjs diff --git a/components/frontapp/sources/common/polling-ids.mjs b/components/frontapp/sources/common/polling-ids.mjs new file mode 100644 index 0000000000000..bbfd443fd25dd --- /dev/null +++ b/components/frontapp/sources/common/polling-ids.mjs @@ -0,0 +1,55 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import frontapp from "../../frontapp.app.mjs"; + +export default { + props: { + frontapp, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getSavedIds() { + return this.db.get("savedIds") || []; + }, + _setSavedIds(ids) { + this.db.set("savedIds", ids); + }, + async startEvent(maxItems) { + const savedIds = this._getSavedIds(); + const items = await this.getItems(savedIds); + + const newIds = []; + for (const item of items) { + const id = this.getItemId(item); + if (!savedIds.includes(id)) { + const meta = this.generateMeta(item); + if (maxItems === undefined || (typeof maxItems === "number" && --maxItems >= 0)) { + this.$emit(item, meta); + } + newIds.push(id); + } + } + + if (newIds.length > 0) { + const ids = [ + ...savedIds, + ...newIds, + ].slice(-100); + this._setSavedIds(ids); + } + }, + }, + async run() { + await this.startEvent(); + }, + hooks: { + async deploy() { + await this.startEvent(5); + }, + }, +}; diff --git a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs new file mode 100644 index 0000000000000..18cfe1327f2c3 --- /dev/null +++ b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs @@ -0,0 +1,36 @@ +import common from "../common/polling-ids.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "frontapp-new-conversation-created", + name: "New Conversation Created", + description: "Emit new event when a conversation is created. [See the documentation](https://dev.frontapp.com/reference/list-conversations)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + generateMeta(conversation) { + return { + id: conversation.id, + summary: `New conversation created: ${conversation.subject}`, + ts: conversation.created_at * 1000, + }; + }, + getItemId(conversation) { + return conversation.id; + }, + async getItems() { + const response = await this.frontapp.listConversations({ + params: { + sort_by: "date", + sort_order: "desc", + }, + }); + + return response._results || []; + }, + }, + sampleEmit, +}; diff --git a/components/frontapp/sources/new-conversation-created/test-event.mjs b/components/frontapp/sources/new-conversation-created/test-event.mjs new file mode 100644 index 0000000000000..0da0e3a74c5db --- /dev/null +++ b/components/frontapp/sources/new-conversation-created/test-event.mjs @@ -0,0 +1,96 @@ +export default { + "_links": { + "self": "string", + "related": { + "events": "string", + "followers": "string", + "messages": "string", + "comments": "string", + "inboxes": "string", + "last_message": "string" + } + }, + "id": "cnv_123abc", + "subject": "New conversation subject", + "status": "open", + "assignee": { + "_links": { + "self": "string", + "related": { + "inboxes": "string", + "conversations": "string" + } + }, + "id": "tea_123abc", + "email": "teammate@example.com", + "username": "teammate", + "first_name": "John", + "last_name": "Doe", + "is_admin": false, + "is_available": true, + "is_blocked": false, + "custom_fields": {} + }, + "recipient": { + "_links": { + "related": { + "contact": "string" + } + }, + "name": "Customer Name", + "handle": "customer@example.com", + "role": "from" + }, + "tags": [ + { + "_links": { + "self": "string", + "related": { + "conversations": "string", + "owner": "string", + "children": "string" + } + }, + "id": "tag_123abc", + "name": "urgent", + "description": "Urgent conversations", + "highlight": "red", + "is_private": false, + "is_visible_in_conversation_lists": true, + "created_at": 1640995200, + "updated_at": 1640995200 + } + ], + "links": [ + { + "_links": { + "self": "string" + }, + "id": "link_123abc", + "name": "Related Ticket", + "type": "string", + "external_url": "https://example.com/ticket/123", + "custom_fields": {} + } + ], + "custom_fields": {}, + "created_at": 1640995200, + "is_private": false, + "scheduled_reminders": [ + { + "_links": { + "related": { + "owner": "string" + } + }, + "created_at": 1640995200, + "scheduled_at": 1641081600, + "updated_at": 1640995200 + } + ], + "metadata": { + "external_conversation_ids": [ + "external_123" + ] + } +}; \ No newline at end of file diff --git a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs new file mode 100644 index 0000000000000..6d8a28ed94f47 --- /dev/null +++ b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs @@ -0,0 +1,36 @@ +import common from "../common/polling-ids.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "frontapp-new-message-template-created", + name: "New Message Template Created", + description: "Emit new event when a message template is created. [See the documentation](https://dev.frontapp.com/reference/list-message-templates)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + generateMeta(template) { + return { + id: template.id, + summary: `New message template created: ${template.name}`, + ts: template.created_at * 1000, + }; + }, + getItemId(template) { + return template.id; + }, + async getItems() { + const response = await this.frontapp.listMessageTemplates({ + params: { + sort_by: "created_at", + sort_order: "desc", + }, + }); + + return response._results || []; + }, + }, + sampleEmit, +}; diff --git a/components/frontapp/sources/new-message-template-created/test-event.mjs b/components/frontapp/sources/new-message-template-created/test-event.mjs new file mode 100644 index 0000000000000..8ee6c9cac0632 --- /dev/null +++ b/components/frontapp/sources/new-message-template-created/test-event.mjs @@ -0,0 +1,56 @@ +export default { + "_links": { + "self": "string", + "related": { + "folder": "string", + "inboxes": "string" + } + }, + "id": "tpl_123abc", + "name": "Welcome Email Template", + "subject": "Welcome to our service!", + "body": "

Welcome to our service! We're excited to have you on board.

Best regards,
The Team

", + "folder_id": "fol_123abc", + "inbox_ids": [ + "inb_123abc", + "inb_456def" + ], + "attachments": [ + { + "filename": "welcome-guide.pdf", + "url": "string", + "content_type": "application/pdf", + "size": 1024000 + } + ], + "created_at": 1640995200, + "updated_at": 1640995200, + "is_available_for_all_inboxes": false, + "folder": { + "_links": { + "self": "string", + "related": { + "owner": "string" + } + }, + "id": "fol_123abc", + "name": "Customer Onboarding", + "description": "Templates for customer onboarding process" + }, + "inboxes": [ + { + "_links": { + "self": "string", + "related": { + "conversations": "string", + "teammates": "string", + "channels": "string", + "owner": "string" + } + }, + "id": "inb_123abc", + "name": "Support Inbox", + "is_private": false + } + ] +}; \ No newline at end of file From 10ae11be54241087ff8444b48625e39210bed2ce Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 17 Jul 2025 20:02:26 -0300 Subject: [PATCH 05/17] Version bumps --- components/frontapp/actions/add-comment/add-comment.mjs | 2 +- .../actions/archive-conversation/archive-conversation.mjs | 2 +- .../actions/assign-conversation/assign-conversation.mjs | 2 +- .../frontapp/actions/create-draft-reply/create-draft-reply.mjs | 2 +- components/frontapp/actions/create-draft/create-draft.mjs | 2 +- components/frontapp/actions/get-comment/get-comment.mjs | 2 +- components/frontapp/actions/get-teammate/get-teammate.mjs | 2 +- .../actions/list-comment-mentions/list-comment-mentions.mjs | 2 +- components/frontapp/actions/list-comments/list-comments.mjs | 2 +- .../frontapp/actions/list-conversations/list-conversations.mjs | 2 +- components/frontapp/actions/list-teammates/list-teammates.mjs | 2 +- .../frontapp/actions/tag-conversation/tag-conversation.mjs | 2 +- .../sources/new-conversation-tag/new-conversation-tag.mjs | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/frontapp/actions/add-comment/add-comment.mjs b/components/frontapp/actions/add-comment/add-comment.mjs index 399742563e934..72e214fe8840f 100644 --- a/components/frontapp/actions/add-comment/add-comment.mjs +++ b/components/frontapp/actions/add-comment/add-comment.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-add-comment", name: "Add Comment", description: "Add a comment to a conversation. [See the documentation](https://dev.frontapp.com/reference/add-comment)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/archive-conversation/archive-conversation.mjs b/components/frontapp/actions/archive-conversation/archive-conversation.mjs index ea17d398d66b3..e5d3f85ac5c61 100644 --- a/components/frontapp/actions/archive-conversation/archive-conversation.mjs +++ b/components/frontapp/actions/archive-conversation/archive-conversation.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-archive-conversation", name: "Archive Conversation", description: "Archives a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/assign-conversation/assign-conversation.mjs b/components/frontapp/actions/assign-conversation/assign-conversation.mjs index 2332fa1c45639..e2229f8c4d79f 100644 --- a/components/frontapp/actions/assign-conversation/assign-conversation.mjs +++ b/components/frontapp/actions/assign-conversation/assign-conversation.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-assign-conversation", name: "Assign Conversation", description: "Assign or unassign a conversation. [See the documentation](https://dev.frontapp.com/reference/update-conversation-assignee)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs b/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs index 56fa9c241505a..5a1da95bcb01e 100644 --- a/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs +++ b/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-create-draft-reply", name: "Create Draft Reply", description: "Create a new draft as a reply to the last message in the conversation. [See the documentation](https://dev.frontapp.com/reference/create-draft-reply)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/create-draft/create-draft.mjs b/components/frontapp/actions/create-draft/create-draft.mjs index c324eac39cd55..38b22e07992eb 100644 --- a/components/frontapp/actions/create-draft/create-draft.mjs +++ b/components/frontapp/actions/create-draft/create-draft.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-create-draft", name: "Create Draft", description: "Create a draft message which is the first message of a new conversation. [See the documentation](https://dev.frontapp.com/reference/create-draft)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/get-comment/get-comment.mjs b/components/frontapp/actions/get-comment/get-comment.mjs index c51214587acdf..6d0f12a67c0a0 100644 --- a/components/frontapp/actions/get-comment/get-comment.mjs +++ b/components/frontapp/actions/get-comment/get-comment.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-get-comment", name: "Get Comment", description: "Retrieve a comment from a conversation. [See the documentation](https://dev.frontapp.com/reference/get-comment)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/get-teammate/get-teammate.mjs b/components/frontapp/actions/get-teammate/get-teammate.mjs index c0cac11fc155c..89c0f41598908 100644 --- a/components/frontapp/actions/get-teammate/get-teammate.mjs +++ b/components/frontapp/actions/get-teammate/get-teammate.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-get-teammate", name: "Get Teammate", description: "Retrieve a teammate by ID. [See the documentation](https://dev.frontapp.com/reference/get-teammate)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs b/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs index f371f9009d5c4..da31a3f5e230b 100644 --- a/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs +++ b/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-comment-mentions", name: "List Comment Mentions", description: "List the teammates mentioned in a comment. [See the documentation](https://dev.frontapp.com/reference/list-comment-mentions)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-comments/list-comments.mjs b/components/frontapp/actions/list-comments/list-comments.mjs index 72331db31cea7..c659f7816b392 100644 --- a/components/frontapp/actions/list-comments/list-comments.mjs +++ b/components/frontapp/actions/list-comments/list-comments.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-comments", name: "List Conversation Comments", description: "List the comments in a conversation. [See the documentation](https://dev.frontapp.com/reference/list-conversation-comments)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-conversations/list-conversations.mjs b/components/frontapp/actions/list-conversations/list-conversations.mjs index ee19fe0e67ad9..b458621046c19 100644 --- a/components/frontapp/actions/list-conversations/list-conversations.mjs +++ b/components/frontapp/actions/list-conversations/list-conversations.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-conversations", name: "List Conversations", description: "List conversations in the company. [See the documentation](https://dev.frontapp.com/reference/list-conversations)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-teammates/list-teammates.mjs b/components/frontapp/actions/list-teammates/list-teammates.mjs index 5c1076b955cda..b8867a1aa5c0e 100644 --- a/components/frontapp/actions/list-teammates/list-teammates.mjs +++ b/components/frontapp/actions/list-teammates/list-teammates.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-teammates", name: "List Teammate", description: "List teammates in the company. [See the documentation](https://dev.frontapp.com/reference/list-teammates)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/tag-conversation/tag-conversation.mjs b/components/frontapp/actions/tag-conversation/tag-conversation.mjs index cda17006754ff..8ef633625ddff 100644 --- a/components/frontapp/actions/tag-conversation/tag-conversation.mjs +++ b/components/frontapp/actions/tag-conversation/tag-conversation.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-tag-conversation", name: "Tag Conversation", description: "Add tags to a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs b/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs index f3a71bffa3ee9..6b25ebb92789f 100644 --- a/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs +++ b/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs @@ -6,7 +6,7 @@ export default { key: "frontapp-new-conversation-tag", name: "New Conversation Tag", description: "Emit new event when a conversation is tagged with a specific tag or any tag. [See the documentation](https://dev.frontapp.com/reference/events)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", props: { From 4b38191a2d112bb0261c6466961097b90eb9a4c2 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 18 Jul 2025 17:16:42 -0300 Subject: [PATCH 06/17] Checking for undefined values on formData --- .../create-message-template.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs index 914b8297e4547..062c58fdada86 100644 --- a/components/frontapp/actions/create-message-template/create-message-template.mjs +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -69,9 +69,15 @@ export default { formData.append("name", name); formData.append("body", body); - formData.append("subject", subject); - formData.append("folder_id", folderId); - formData.append("inbox_ids", inboxIds); + if (subject !== undefined) { + formData.append("subject", subject); + } + if (folderId !== undefined) { + formData.append("folder_id", folderId); + } + if (inboxIds !== undefined) { + formData.append("inbox_ids", inboxIds); + } for (const attachment of attachments) { const { From 43b137a4120e2a4e96784e375bf72e7fd3b6ff65 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 21 Jul 2025 17:23:16 -0300 Subject: [PATCH 07/17] Adjusting pagination for 'list message templates' --- .../list-message-templates.mjs | 53 +++++-------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/components/frontapp/actions/list-message-templates/list-message-templates.mjs b/components/frontapp/actions/list-message-templates/list-message-templates.mjs index e7bdd8db7904c..c41230d943ce8 100644 --- a/components/frontapp/actions/list-message-templates/list-message-templates.mjs +++ b/components/frontapp/actions/list-message-templates/list-message-templates.mjs @@ -8,54 +8,27 @@ export default { type: "action", props: { frontApp, - sortBy: { - type: "string", - label: "Sort By", - description: "Field used to sort the message templates", - options: [ - "created_at", - "updated_at", + maxResults: { + propDefinition: [ + frontApp, + "maxResults", ], - optional: true, - }, - sortOrder: { - type: "string", - label: "Sort Order", - description: "Order by which results should be sorted", - options: [ - { - label: "Ascending", - value: "asc", - }, - { - label: "Descending", - value: "desc", - }, - ], - optional: true, }, }, async run({ $ }) { - const { - frontApp, - sortBy, - sortOrder, - } = this; - - const response = await frontApp.listMessageTemplates({ + const items = this.frontApp.paginate({ + fn: this.frontApp.listMessageTemplates, + maxResults: this.maxResults, $, - params: { - sort_by: sortBy, - sort_order: sortOrder, - }, }); - const templates = response._results || []; - const length = templates.length; - $.export("$summary", `Successfully retrieved ${length} message template${length === 1 + const results = []; + for await (const item of items) { + results.push(item); + } + $.export("$summary", `Successfully retrieved ${results?.length} message template${results?.length === 1 ? "" : "s"}`); - - return response; + return results; }, }; From 75af305fa658404e6bc8e3b127652e7375d57faa Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 21 Jul 2025 17:30:18 -0300 Subject: [PATCH 08/17] pnpm --- pnpm-lock.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index afc7243577332..b1d3ee77b6eb0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11493,8 +11493,7 @@ importers: components/rewardful: {} - components/rewiser: - specifiers: {} + components/rewiser: {} components/rex: dependencies: @@ -37258,6 +37257,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: From 065f312725901b72d67e7c71425be0792ac95cdf Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 21 Jul 2025 19:54:31 -0300 Subject: [PATCH 09/17] Updating sources to timestamp-based --- components/frontapp/sources/common/base.mjs | 14 ++++- .../frontapp/sources/common/polling-ids.mjs | 55 ------------------- .../new-conversation-created.mjs | 26 ++++----- .../new-message-template-created.mjs | 26 ++++----- 4 files changed, 33 insertions(+), 88 deletions(-) delete mode 100644 components/frontapp/sources/common/polling-ids.mjs diff --git a/components/frontapp/sources/common/base.mjs b/components/frontapp/sources/common/base.mjs index be15ec62602a5..894d006ec8734 100644 --- a/components/frontapp/sources/common/base.mjs +++ b/components/frontapp/sources/common/base.mjs @@ -19,7 +19,7 @@ export default { _setLastTs(lastTs) { this.db.set("lastTs", lastTs); }, - async startEvent(maxResults = 0) { + async startEvent(maxResults = 0, filterFn = null) { const lastTs = this._getLastTs(); const items = this.frontapp.paginate({ fn: this._getFunction(), @@ -30,10 +30,18 @@ export default { let responseArray = []; for await (const item of items) { - responseArray.push(item); + // If filterFn is provided, use it to filter items, otherwise add all items + if (!filterFn || filterFn(item, lastTs)) { + responseArray.push(item); + } } - if (responseArray.length) this._setLastTs(responseArray[0].emitted_at); + if (responseArray.length) { + if (filterFn) { + responseArray.sort((a, b) => b.created_at - a.created_at); + } + this._setLastTs(responseArray[0].emitted_at); + } for (const item of responseArray.reverse()) { this.$emit( diff --git a/components/frontapp/sources/common/polling-ids.mjs b/components/frontapp/sources/common/polling-ids.mjs deleted file mode 100644 index bbfd443fd25dd..0000000000000 --- a/components/frontapp/sources/common/polling-ids.mjs +++ /dev/null @@ -1,55 +0,0 @@ -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -import frontapp from "../../frontapp.app.mjs"; - -export default { - props: { - frontapp, - db: "$.service.db", - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, - }, - }, - }, - methods: { - _getSavedIds() { - return this.db.get("savedIds") || []; - }, - _setSavedIds(ids) { - this.db.set("savedIds", ids); - }, - async startEvent(maxItems) { - const savedIds = this._getSavedIds(); - const items = await this.getItems(savedIds); - - const newIds = []; - for (const item of items) { - const id = this.getItemId(item); - if (!savedIds.includes(id)) { - const meta = this.generateMeta(item); - if (maxItems === undefined || (typeof maxItems === "number" && --maxItems >= 0)) { - this.$emit(item, meta); - } - newIds.push(id); - } - } - - if (newIds.length > 0) { - const ids = [ - ...savedIds, - ...newIds, - ].slice(-100); - this._setSavedIds(ids); - } - }, - }, - async run() { - await this.startEvent(); - }, - hooks: { - async deploy() { - await this.startEvent(5); - }, - }, -}; diff --git a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs index 18cfe1327f2c3..d67ebdab448e8 100644 --- a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs +++ b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs @@ -1,4 +1,4 @@ -import common from "../common/polling-ids.mjs"; +import common from "../common/base.mjs"; import sampleEmit from "./test-event.mjs"; export default { @@ -11,26 +11,22 @@ export default { dedupe: "unique", methods: { ...common.methods, - generateMeta(conversation) { + _getFunction() { + return this.frontapp.listConversations; + }, + _getParams() { + return { + sort_by: "date", + sort_order: "desc", + }; + }, + _getEmit(conversation) { return { id: conversation.id, summary: `New conversation created: ${conversation.subject}`, ts: conversation.created_at * 1000, }; }, - getItemId(conversation) { - return conversation.id; - }, - async getItems() { - const response = await this.frontapp.listConversations({ - params: { - sort_by: "date", - sort_order: "desc", - }, - }); - - return response._results || []; - }, }, sampleEmit, }; diff --git a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs index 6d8a28ed94f47..8893eca8240cf 100644 --- a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs +++ b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs @@ -1,4 +1,4 @@ -import common from "../common/polling-ids.mjs"; +import common from "../common/base.mjs"; import sampleEmit from "./test-event.mjs"; export default { @@ -11,26 +11,22 @@ export default { dedupe: "unique", methods: { ...common.methods, - generateMeta(template) { + _getFunction() { + return this.frontapp.listMessageTemplates; + }, + _getParams() { + return { + sort_by: "created_at", + sort_order: "desc", + }; + }, + _getEmit(template) { return { id: template.id, summary: `New message template created: ${template.name}`, ts: template.created_at * 1000, }; }, - getItemId(template) { - return template.id; - }, - async getItems() { - const response = await this.frontapp.listMessageTemplates({ - params: { - sort_by: "created_at", - sort_order: "desc", - }, - }); - - return response._results || []; - }, }, sampleEmit, }; From aed9e7479bb4a39320f41662be4a1e4efac6d8dd Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 21 Jul 2025 22:16:11 -0300 Subject: [PATCH 10/17] Adjusting timestamp setting --- components/frontapp/sources/common/base.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/frontapp/sources/common/base.mjs b/components/frontapp/sources/common/base.mjs index 894d006ec8734..d3932bf4468d8 100644 --- a/components/frontapp/sources/common/base.mjs +++ b/components/frontapp/sources/common/base.mjs @@ -40,7 +40,7 @@ export default { if (filterFn) { responseArray.sort((a, b) => b.created_at - a.created_at); } - this._setLastTs(responseArray[0].emitted_at); + this._setLastTs(this._getEmit(responseArray[0]).ts); } for (const item of responseArray.reverse()) { From 808b816abf56633bcebd37790dfcd2d553abce61 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Jul 2025 04:38:25 -0300 Subject: [PATCH 11/17] Adding syncDir prop --- .../create-message-template/create-message-template.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs index 062c58fdada86..648d75c0b5acc 100644 --- a/components/frontapp/actions/create-message-template/create-message-template.mjs +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -49,6 +49,12 @@ export default { "attachments", ], }, + syncDir: { + type: "dir", + accessMode: "read", + sync: true, + optional: true, + }, }, async run({ $ }) { const { From f388c240ec6f7720c7a2b3bff6ca8f72ab5445d5 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Jul 2025 14:58:27 -0300 Subject: [PATCH 12/17] Re-adding sortBy and sortOrder --- .../list-message-templates.mjs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/components/frontapp/actions/list-message-templates/list-message-templates.mjs b/components/frontapp/actions/list-message-templates/list-message-templates.mjs index c41230d943ce8..719779b414f74 100644 --- a/components/frontapp/actions/list-message-templates/list-message-templates.mjs +++ b/components/frontapp/actions/list-message-templates/list-message-templates.mjs @@ -8,6 +8,38 @@ export default { type: "action", props: { frontApp, + sortBy: { + type: "string", + label: "Sort By Field", + description: "Field used to sort the message templates", + options: [ + { + label: "Created At", + value: "created_at", + }, + { + label: "Updated At", + value: "updated_at", + }, + ], + optional: true, + }, + sortOrder: { + type: "string", + label: "Sort Order", + description: "Order by which results should be sorted", + options: [ + { + label: "Ascending", + value: "asc", + }, + { + label: "Descending", + value: "desc", + }, + ], + optional: true, + }, maxResults: { propDefinition: [ frontApp, @@ -18,6 +50,10 @@ export default { async run({ $ }) { const items = this.frontApp.paginate({ fn: this.frontApp.listMessageTemplates, + params: { + sort_by: this.sortBy, + sort_order: this.sortOrder, + }, maxResults: this.maxResults, $, }); From f4799696f88dcef6fdddee63c6ea107543e85c26 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 22 Jul 2025 16:10:44 -0300 Subject: [PATCH 13/17] Re-adding missing filterFn calls --- .../new-conversation-created/new-conversation-created.mjs | 8 ++++++++ .../new-message-template-created.mjs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs index d67ebdab448e8..6409b22425881 100644 --- a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs +++ b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs @@ -27,6 +27,14 @@ export default { ts: conversation.created_at * 1000, }; }, + hooks: { + async deploy() { + await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); + }, + }, + async run() { + await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + }, }, sampleEmit, }; diff --git a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs index 8893eca8240cf..1161795554fa1 100644 --- a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs +++ b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs @@ -27,6 +27,14 @@ export default { ts: template.created_at * 1000, }; }, + hooks: { + async deploy() { + await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); + }, + }, + async run() { + await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + }, }, sampleEmit, }; From 48f1c7db8f9040e4f72d2d31fd1d6e19faa26830 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 03:04:39 -0300 Subject: [PATCH 14/17] Adjusting form data checking --- components/frontapp/common/utils.mjs | 2 +- components/frontapp/frontapp.app.mjs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/frontapp/common/utils.mjs b/components/frontapp/common/utils.mjs index aac27a8eca825..6245a23112828 100644 --- a/components/frontapp/common/utils.mjs +++ b/components/frontapp/common/utils.mjs @@ -89,7 +89,7 @@ function buildFormData(formData, data, parentKey) { buildFormData(formData, data[key], parentKey && `${parentKey}[${key}]` || key); }); - } else if (data && parentKey.includes("attachment")) { + } else if (data && parentKey?.includes("attachment")) { formData.append(parentKey, createReadStream(data)); } else if (data) { diff --git a/components/frontapp/frontapp.app.mjs b/components/frontapp/frontapp.app.mjs index d9fecde8b629b..82b79386b7df1 100644 --- a/components/frontapp/frontapp.app.mjs +++ b/components/frontapp/frontapp.app.mjs @@ -314,7 +314,7 @@ export default { return url || `${constants.BASE_URL}${path}`; }, hasMultipartHeader(headers) { - return headers && headers["Content-Type"].includes("multipart/form-data"); + return headers?.["Content-Type"]?.includes("multipart/form-data"); }, getHeaders(headers) { return { @@ -328,7 +328,10 @@ export default { headers, path, url, data: originalData, ...args } = {}) { const hasMultipartHeader = this.hasMultipartHeader(headers); - const data = hasMultipartHeader && utils.getFormData(originalData) || originalData; + const isFormData = originalData instanceof FormData; + const data = (!isFormData && hasMultipartHeader) + ? utils.getFormData(originalData) + : originalData; const currentHeaders = this.getHeaders(headers); const builtHeaders = hasMultipartHeader ? { From a561db5ad9e0aa2a493fa32dfcab1e12711a07fa Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 03:11:43 -0300 Subject: [PATCH 15/17] Fixing bug on sources --- .../new-conversation-created.mjs | 14 +++++++------- .../new-message-template-created.mjs | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs index 6409b22425881..153451f347c60 100644 --- a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs +++ b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs @@ -27,14 +27,14 @@ export default { ts: conversation.created_at * 1000, }; }, - hooks: { - async deploy() { - await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); - }, - }, - async run() { - await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + }, + hooks: { + async deploy() { + await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); }, }, + async run() { + await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + }, sampleEmit, }; diff --git a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs index 1161795554fa1..f6ea60f92f299 100644 --- a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs +++ b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs @@ -27,14 +27,14 @@ export default { ts: template.created_at * 1000, }; }, - hooks: { - async deploy() { - await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); - }, - }, - async run() { - await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + }, + hooks: { + async deploy() { + await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); }, }, + async run() { + await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + }, sampleEmit, }; From a0296444f15de6f679a7c996460dcda1ada6f59b Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 25 Jul 2025 00:38:25 -0300 Subject: [PATCH 16/17] Adjusting inboxIds array format --- .../create-message-template/create-message-template.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs index 648d75c0b5acc..d22e078e3b164 100644 --- a/components/frontapp/actions/create-message-template/create-message-template.mjs +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -81,8 +81,12 @@ export default { if (folderId !== undefined) { formData.append("folder_id", folderId); } - if (inboxIds !== undefined) { + if (typeof inboxIds === "string") { formData.append("inbox_ids", inboxIds); + } else if (Array.isArray(inboxIds)) { + for (const inboxId of inboxIds) { + formData.append("inbox_ids", inboxId); + } } for (const attachment of attachments) { From 6a67cb7bb8e7a2dac0c4612c041b8a598cc74aeb Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 25 Jul 2025 03:09:30 -0300 Subject: [PATCH 17/17] Timestamp fix for event emission --- components/frontapp/sources/common/base.mjs | 3 +++ .../new-conversation-created/new-conversation-created.mjs | 6 +++--- .../new-message-template-created.mjs | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/frontapp/sources/common/base.mjs b/components/frontapp/sources/common/base.mjs index d3932bf4468d8..69c839c4704d2 100644 --- a/components/frontapp/sources/common/base.mjs +++ b/components/frontapp/sources/common/base.mjs @@ -19,6 +19,9 @@ export default { _setLastTs(lastTs) { this.db.set("lastTs", lastTs); }, + _getItemTs(item) { + return item.created_at * 1000; + }, async startEvent(maxResults = 0, filterFn = null) { const lastTs = this._getLastTs(); const items = this.frontapp.paginate({ diff --git a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs index 153451f347c60..32c8973f538fa 100644 --- a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs +++ b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs @@ -23,18 +23,18 @@ export default { _getEmit(conversation) { return { id: conversation.id, - summary: `New conversation created: ${conversation.subject}`, + summary: `New conversation: ${conversation.subject}`, ts: conversation.created_at * 1000, }; }, }, hooks: { async deploy() { - await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); + await this.startEvent(25, (item, lastTs) => this._getItemTs(item) > lastTs); }, }, async run() { - await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + await this.startEvent(0, (item, lastTs) => this._getItemTs(item) > lastTs); }, sampleEmit, }; diff --git a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs index f6ea60f92f299..c28549fc98ea9 100644 --- a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs +++ b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs @@ -23,18 +23,18 @@ export default { _getEmit(template) { return { id: template.id, - summary: `New message template created: ${template.name}`, + summary: `New template: ${template.name}`, ts: template.created_at * 1000, }; }, }, hooks: { async deploy() { - await this.startEvent(25, (item, lastTs) => item.created_at > lastTs); + await this.startEvent(25, (item, lastTs) => this._getItemTs(item) > lastTs); }, }, async run() { - await this.startEvent(0, (item, lastTs) => item.created_at > lastTs); + await this.startEvent(0, (item, lastTs) => this._getItemTs(item) > lastTs); }, sampleEmit, };