Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/frontapp/actions/add-comment/add-comment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/frontapp/actions/create-draft/create-draft.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/frontapp/actions/create-inbox/create-inbox.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.3",
version: "0.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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.3",
version: "0.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "frontapp-create-message",
name: "Create Message",
description: "Send a new message from a channel. [See the documentation](https://dev.frontapp.com/reference/create-message).",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.3",
version: "0.0.4",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/frontapp/actions/get-comment/get-comment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "frontapp-get-conversation",
name: "Get Conversation",
description: "Retrieve a conversation by its ID from Front. [See the documentation](https://dev.frontapp.com/reference/get-conversation-by-id)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/frontapp/actions/get-message/get-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "frontapp-get-message",
name: "Get Message",
description: "Retrieve a message by its ID. [See the documentation](https://dev.frontapp.com/reference/get-message)",
version: "0.0.3",
version: "0.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
2 changes: 1 addition & 1 deletion components/frontapp/actions/get-teammate/get-teammate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.10",
version: "0.1.11",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.3",
version: "0.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "frontapp-receive-custom-messages",
name: "Receive Custom Messages",
description: "Receive a custom message in Front. [See the documentation](https://dev.frontapp.com/reference/post_channels-channel-id-incoming-messages).",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 documentation](https://dev.frontapp.com/reference/post_conversations-conversation-id-messages).",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 documentation](https://dev.frontapp.com/reference/post_channels-channel-id-messages).",
version: "0.2.9",
version: "0.2.10",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "frontapp-update-conversation",
name: "Update Conversation",
description: "Updates a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id).",
version: "0.1.9",
version: "0.1.10",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.3",
version: "0.0.4",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
72 changes: 65 additions & 7 deletions components/frontapp/frontapp.app.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { axios } from "@pipedream/platform";
import retry from "async-retry";
import constants from "./common/constants.mjs";
import utils from "./common/utils.mjs";

Expand Down Expand Up @@ -350,12 +351,61 @@ export default {
$ = this, ...args
} = {}) {
const config = this.getConfig(args);
try {
return await axios($, config);
} catch (error) {
console.log("error", error.response?.data);
throw error;
}
let retryAfterDelay = null;

const retryOpts = {
retries: 3,
maxTimeout: 30000,
onRetry: async (err, attempt) => {
const status = err.response?.status;

if (status === 429) {
const retryAfter = err.response?.headers?.["retry-after"];
if (retryAfter) {
retryAfterDelay = parseInt(retryAfter) * 1000;
console.log(`Rate limit exceeded. Waiting ${retryAfter} seconds before retry (attempt ${attempt}/${retryOpts.retries})`);
// Wait for the Retry-After period
await new Promise((resolve) => setTimeout(resolve, retryAfterDelay));
} else {
console.log(`Rate limit exceeded. Using exponential backoff (attempt ${attempt}/${retryOpts.retries})`);
}
} else {
console.log(`Request failed with status ${status}. Retrying (attempt ${attempt}/${retryOpts.retries})`);
}
},
};

return retry(async (bail) => {
try {
const response = await axios($, config);

// Log rate limit info for monitoring
const remaining = response.headers?.["x-ratelimit-remaining"];
if (remaining !== undefined && parseInt(remaining) < 5) {
console.log(`Warning: Only ${remaining} API requests remaining before rate limit`);
}

return response;
} catch (error) {
const status = error.response?.status;

// Don't retry on client errors (except 429)
if (status && status >= 400 && status < 500 && status !== 429) {
console.log("error", error.response?.data);
bail(error);
return;
}

// Retry on 429 and 5xx errors
if (status === 429 || (status && status >= 500)) {
throw error;
}

// For other errors, don't retry
console.log("error", error.response?.data || error.message);
bail(error);
}
}, retryOpts);
},
async importMessage({
inboxId, ...args
Expand Down Expand Up @@ -641,13 +691,21 @@ export default {
};
},
async *paginate({
fn, params = {}, maxResults = null, ...args
fn, params = {}, maxResults = null, delayMs = 1000, ...args
}) {
let hasMore = false;
let count = 0;
let pageToken = null;
let isFirstPage = true;

do {
// Add delay between pagination requests to avoid rate limits
// Skip delay on first page to maintain backward compatibility
if (!isFirstPage && delayMs > 0) {
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
isFirstPage = false;

const {
_results: data,
_pagination: { next },
Expand Down
3 changes: 2 additions & 1 deletion components/frontapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/frontapp",
"version": "0.8.2",
"version": "0.8.1",
"description": "Pipedream Frontapp Components",
"main": "frontapp.app.mjs",
"keywords": [
Expand All @@ -11,6 +11,7 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"dependencies": {
"@pipedream/platform": "^3.1.0",
"async-retry": "^1.3.3",
"form-data": "^4.0.0"
},
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
Expand Down
1 change: 1 addition & 0 deletions components/frontapp/sources/common/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
fn: this._getFunction(),
params: this._getParams(lastTs),
maxResults,
delayMs: 1200, // 1.2 second delay between pages to respect rate limits
});

let responseArray = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
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.4",
version: "0.0.5",
type: "source",
dedupe: "unique",
methods: {
Expand All @@ -23,7 +23,7 @@ export default {
_getEmit(conversation) {
return {
id: conversation.id,
summary: `New conversation: ${conversation.subject}`,
summary: `New conversation: ${conversation.subject || conversation.id}`,
ts: conversation.created_at * 1000,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "frontapp-new-conversation-state-change",
name: "New Conversation State Change",
description: "Emit new event when a conversation reaches a specific state. [See the documentation](https://dev.frontapp.com/reference/list-events)",
version: "0.0.6",
version: "0.0.7",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.6",
version: "0.0.7",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
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.4",
version: "0.0.5",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Loading
Loading