-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Frontapp new components #17689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GTFalcao
wants to merge
5
commits into
master
Choose a base branch
from
17465-front
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+715
−30
Open
Frontapp new components #17689
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: { | ||
propDefinition: [ | ||
frontApp, | ||
"teammateId", | ||
], | ||
type: "string[]", | ||
label: "Teammate IDs", | ||
description: "One or more IDs of teammates that should have access to the inbox", | ||
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; | ||
}, | ||
}; |
109 changes: 109 additions & 0 deletions
109
components/frontapp/actions/create-message-template/create-message-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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?.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; | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
components/frontapp/actions/delete-message-template/delete-message-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: "ID of the message template to delete", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
frontApp, | ||
messageTemplateId, | ||
} = this; | ||
|
||
const response = await frontApp.deleteMessageTemplate({ | ||
messageTemplateId, | ||
$, | ||
}); | ||
|
||
$.export("$summary", `Successfully deleted message template ${messageTemplateId}`); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
components/frontapp/actions/list-message-templates/list-message-templates.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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", | ||
], | ||
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({ | ||
$, | ||
params: { | ||
sort_by: sortBy, | ||
sort_order: sortOrder, | ||
}, | ||
}); | ||
|
||
const templates = response._results || []; | ||
const length = templates.length; | ||
$.export("$summary", `Successfully retrieved ${length} message template${length === 1 | ||
? "" | ||
: "s"}`); | ||
|
||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify handling of optional fields in FormData.
The code appends
subject
andinboxIds
to FormData without checking if they're defined. This could potentially appendundefined
values.🏁 Script executed:
Length of output: 2638
Length of output: 1339
Add guards before appending optional FormData fields
To keep the FormData payload consistent (and avoid sending
"undefined"
), wrap the optionalsubject
andinbox_ids
appends in presence checks:• File:
components/frontapp/actions/create-message-template/create-message-template.mjs
• Change the block around lines 72–74 to:
This ensures neither key is sent when its value is unset.
📝 Committable suggestion
🤖 Prompt for AI Agents